@adyen/adyen-web 6.40.2 → 6.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +49 -41
  4. package/dist/es/components/ANCV/ANCV.js +1 -1
  5. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  6. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  7. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  8. package/dist/es/components/Card/Card.js +1 -1
  9. package/dist/es/components/Card/Card.js.map +1 -1
  10. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  11. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  12. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  13. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  14. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  15. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  16. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  17. package/dist/es/components/Dropin/Dropin.js +1 -1
  18. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  19. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  20. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  21. package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
  22. package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
  23. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  24. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  26. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  27. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  28. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  29. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  30. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  31. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  32. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  33. package/dist/es/components/Giftcard/components/GiftcardPinField.js +1 -1
  34. package/dist/es/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  35. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  36. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  37. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  38. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  39. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  40. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  41. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  42. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  43. package/dist/es/components/internal/Button/Button.js +1 -1
  44. package/dist/es/components/internal/Button/Button.js.map +1 -1
  45. package/dist/es/components/internal/Button/CopyButton.js +1 -1
  46. package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
  47. package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
  48. package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
  49. package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
  50. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  51. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
  56. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  57. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  58. package/dist/es/components/internal/Modal/Modal.js +1 -1
  59. package/dist/es/components/internal/Modal/Modal.js.map +1 -1
  60. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  61. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  62. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  63. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  64. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
  65. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
  69. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
  70. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  71. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  72. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  73. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  74. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  75. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  76. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  77. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  78. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  79. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  80. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  81. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  82. package/dist/es/core/config.js +1 -1
  83. package/dist/es/index.d.ts +49 -41
  84. package/dist/es/utils/commonUtils.js +1 -1
  85. package/dist/es/utils/commonUtils.js.map +1 -1
  86. package/dist/es/utils/promiseTimeout.js.map +1 -1
  87. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  88. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  89. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  90. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  91. package/dist/es-legacy/components/Card/Card.js +1 -1
  92. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  93. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  94. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  95. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  96. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  97. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  98. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  99. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  100. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  101. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  102. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  103. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  104. package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
  105. package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
  106. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  107. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  108. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  109. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  110. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  111. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  112. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  113. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  114. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  115. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  116. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js +1 -1
  117. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  118. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  119. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  120. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  121. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  122. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  123. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  124. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  125. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  126. package/dist/es-legacy/components/internal/Button/Button.js +1 -1
  127. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  128. package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
  129. package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
  130. package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
  131. package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
  132. package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
  133. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  134. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  135. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  136. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  137. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
  138. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
  139. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  140. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  141. package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
  142. package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
  143. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  144. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  145. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  146. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  147. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
  148. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  149. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  150. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  151. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
  152. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
  153. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  154. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  155. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  156. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  157. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  158. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  159. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  160. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  161. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  162. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  163. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  164. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  165. package/dist/es-legacy/core/config.js +1 -1
  166. package/dist/es-legacy/utils/commonUtils.js +1 -1
  167. package/dist/es-legacy/utils/commonUtils.js.map +1 -1
  168. package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
  169. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import {\n h,\n RefCallback,\n InputHTMLAttributes,\n GenericEventHandler,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedFocusEvent,\n TargetedEvent\n} from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport { AutocompleteValue } from './types';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends InputHTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n /**\n * WCAG 2.2 autocomplete token for browser autofill.\n * Pass undefined to omit the attribute entirely.\n * @see https://www.w3.org/TR/WCAG22/#input-purposes\n */\n autocomplete: AutocompleteValue;\n}\n\nexport default function InputBase({ setRef, ...props }: Readonly<InputBaseProps>) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellcheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const {\n classNameModifiers: cnm,\n uniqueId: uid,\n isInvalid: iiv,\n isValid: iv,\n addContextualElement: ace,\n 'aria-describedby': ariaDescribedByProp,\n autocomplete,\n ...restProps\n } = props;\n\n const internalDescribedBy = uniqueId ? `${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}` : null;\n const extraDescribedBy = typeof ariaDescribedByProp === 'string' && ariaDescribedByProp ? ariaDescribedByProp : null;\n const mergedAriaDescribedBy = [extraDescribedBy, internalDescribedBy].filter(Boolean).join(' ') || null;\n\n return (\n <input\n id={uniqueId}\n {...restProps}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'autocomplete'\n autocomplete={autocomplete}\n aria-required={restProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'spellcheck'\n spellcheck={spellcheck}\n autoCorrect={autoCorrect}\n aria-describedby={mergedAriaDescribedBy}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellcheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","ariaDescribedByProp","autocomplete","restProps","mergedAriaDescribedBy","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","filter","Boolean","join","h","input","id","aria-required","required","readOnly","aria-describedby","aria-invalid","onFocus","ref","defaultProps"],"mappings":"4RA8Ce,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,EACfC,IACGnB,EAAMoB,QAAQD,IAElB,CAACnB,EAAMoB,UAULC,EAAiBH,EAClBC,IACOnB,GAAOsB,YAAYtB,EAAMsB,WAAWH,IAE5C,CAACnB,GAAOsB,aASNC,EAAcL,EACfC,IACOnB,GAAOwB,SAASxB,EAAMwB,QAAQL,IAEtC,CAACnB,GAAOwB,UAGNC,EAAaP,EACdC,IACGnB,GAAO0B,gBAAgBP,GAEnBnB,EAAM2B,aACLR,EAAMS,OAA4BC,MAAQV,EAAOS,OAA4BC,MAAMC,QAGxF9B,GAAO+B,SAASZ,IAEpB,CAACnB,EAAM+B,OAAQ/B,EAAM0B,gBAGnBM,EAAcd,EACfC,IACGnB,GAAOiC,iBAAiBd,IAE5B,CAACnB,EAAMiC,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B5B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,GAEpCF,EAAmBkC,IAAIC,GAAK,0BAA0BA,OAKtDnC,mBAAoBoC,EACpB9B,SAAU+B,EACVpC,UAAWqC,EACXpC,QAASqC,EACTC,qBAAsBC,EACtB,mBAAoBC,EAAmBC,aACvCA,KACGC,GACH9C,EAIE+C,EAAwB,CAD0B,iBAAxBH,GAAoCA,EAAsBA,EAAsB,KADpFpC,EAAW,GAAGA,IAAWL,EAAY6C,EAAoBC,IAAwB,MAEvCC,OAAOC,SAASC,KAAK,MAAQ,KAEnG,OACIC,EAACC,QAAAA,CACGC,GAAI/C,KACAsC,EAEJD,aAAcA,EACdW,gBAAeV,EAAUW,SACzBlD,KAAMA,EACNG,UAAWwB,EACXwB,SAAUrD,EAEVC,WAAYA,EACZL,YAAaA,EACb0D,mBAAkBZ,EAClBa,eAAczD,EACdiB,QAASH,EACTc,OAAQN,EACRoC,QAAS7B,EACTR,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACVqD,IAAK/D,GAGjB,CAEAD,EAAUiE,aAAe,CACrBxD,KAAM,OACNL,mBAAoB"}
1
+ {"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import {\n h,\n RefCallback,\n InputHTMLAttributes,\n GenericEventHandler,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedFocusEvent,\n TargetedEvent\n} from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport { AutocompleteValue } from './types';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends InputHTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n /**\n * WCAG 2.2 autocomplete token for browser autofill.\n * Pass undefined to omit the attribute entirely.\n * @see https://www.w3.org/TR/WCAG22/#input-purposes\n */\n autocomplete: AutocompleteValue;\n}\n\nexport default function InputBase({ setRef, ...props }: Readonly<InputBaseProps>) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellcheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n const handleKeyDown = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyDown) props.onKeyDown(event);\n },\n [props?.onKeyDown]\n );\n\n const handleBlur = useCallback(\n (event: TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const {\n classNameModifiers: cnm,\n uniqueId: uid,\n isInvalid: iiv,\n isValid: iv,\n addContextualElement: ace,\n 'aria-describedby': ariaDescribedByProp,\n autocomplete,\n ...restProps\n } = props;\n\n const internalDescribedBy = uniqueId ? `${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}` : null;\n const extraDescribedBy = typeof ariaDescribedByProp === 'string' && ariaDescribedByProp ? ariaDescribedByProp : null;\n const mergedAriaDescribedBy = [extraDescribedBy, internalDescribedBy].filter(Boolean).join(' ') || null;\n\n return (\n <input\n id={uniqueId}\n {...restProps}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'autocomplete'\n autocomplete={autocomplete}\n aria-required={restProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'spellcheck'\n spellcheck={spellcheck}\n autoCorrect={autoCorrect}\n aria-describedby={mergedAriaDescribedBy}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellcheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyDown","onKeyDown","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","ariaDescribedByProp","autocomplete","restProps","mergedAriaDescribedBy","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","filter","Boolean","join","h","input","id","aria-required","required","readOnly","aria-describedby","aria-invalid","onFocus","ref","defaultProps"],"mappings":"4RA8Ce,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,EACfC,IACGnB,EAAMoB,QAAQD,IAElB,CAACnB,EAAMoB,UAGLC,EAAgBH,EACjBC,IACOnB,GAAOsB,WAAWtB,EAAMsB,UAAUH,IAE1C,CAACnB,GAAOsB,YAGNC,EAAaL,EACdC,IACGnB,GAAOwB,gBAAgBL,GAEnBnB,EAAMyB,aACLN,EAAMO,OAA4BC,MAAQR,EAAOO,OAA4BC,MAAMC,QAGxF5B,GAAO6B,SAASV,IAEpB,CAACnB,EAAM6B,OAAQ7B,EAAMwB,gBAGnBM,EAAcZ,EACfC,IACGnB,GAAO+B,iBAAiBZ,IAE5B,CAACnB,EAAM+B,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B1B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,GAEpCF,EAAmBgC,IAAIC,GAAK,0BAA0BA,OAKtDjC,mBAAoBkC,EACpB5B,SAAU6B,EACVlC,UAAWmC,EACXlC,QAASmC,EACTC,qBAAsBC,EACtB,mBAAoBC,EAAmBC,aACvCA,KACGC,GACH5C,EAIE6C,EAAwB,CAD0B,iBAAxBH,GAAoCA,EAAsBA,EAAsB,KADpFlC,EAAW,GAAGA,IAAWL,EAAY2C,EAAoBC,IAAwB,MAEvCC,OAAOC,SAASC,KAAK,MAAQ,KAEnG,OACIC,EAACC,QAAAA,CACGC,GAAI7C,KACAoC,EAEJD,aAAcA,EACdW,gBAAeV,EAAUW,SACzBhD,KAAMA,EACNG,UAAWsB,EACXwB,SAAUnD,EAEVC,WAAYA,EACZL,YAAaA,EACbwD,mBAAkBZ,EAClBa,eAAcvD,EACdiB,QAASH,EACTY,OAAQN,EACRoC,QAAS7B,EACTR,UAAWD,EACXZ,SAAUA,EACVmD,IAAK7D,GAGjB,CAEAD,EAAU+D,aAAe,CACrBtD,KAAM,OACNL,mBAAoB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as s}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../_virtual/index.js";import{useModal as a}from"./useModal.js";const t=({children:t,classNameModifiers:i=[],isOpen:l,onClose:n,isDismissible:c=!0,labelledBy:d,describedBy:m,focusFirst:p,focusAfterClose:u,...f})=>{const k=r(),{closeModal:y,handleClickOutside:h}=a({modalElement:k.current,isOpen:l,isDismissible:c,focusFirst:p,focusAfterClose:u,onClose:n});return s(()=>{if(!k.current)return;const e=e=>{"Enter"!==e.key&&"Enter"!==e.code||e.stopPropagation()};return k.current.addEventListener("keypress",e,{capture:!0}),()=>{k.current.removeEventListener("keypress",e)}},[k.current]),e("div",{className:o("adyen-checkout__modal-wrapper",i.map(e=>`adyen-checkout__modal-wrapper--${e}`),{"adyen-checkout__modal-wrapper--open":l}),role:"dialog","aria-labelledby":d,"aria-describedby":m,"aria-modal":"true","aria-hidden":!l,onClick:h,...f},e("div",{className:"adyen-checkout__modal",ref:k},t({onCloseModal:y})))};export{t as Modal};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import s from"../../../_virtual/index.js";import{useModal as a}from"./useModal.js";const t=({children:t,classNameModifiers:i=[],isOpen:n,onClose:l,isDismissible:c=!0,labelledBy:d,describedBy:m,focusFirst:u,focusAfterClose:p,...f})=>{const k=r(),{closeModal:y,handleClickOutside:h}=a({modalElement:k.current,isOpen:n,isDismissible:c,focusFirst:u,focusAfterClose:p,onClose:l});return o(()=>{if(!k.current)return;const e=e=>{"Enter"!==e.key&&"Enter"!==e.code||e.stopPropagation()};return k.current.addEventListener("keydown",e,{capture:!0}),()=>{k.current.removeEventListener("keydown",e)}},[k.current]),e("div",{className:s("adyen-checkout__modal-wrapper",i.map(e=>`adyen-checkout__modal-wrapper--${e}`),{"adyen-checkout__modal-wrapper--open":n}),role:"dialog","aria-labelledby":d,"aria-describedby":m,"aria-modal":"true","aria-hidden":!n,onClick:h,...f},e("div",{className:"adyen-checkout__modal",ref:k},t({onCloseModal:y})))};export{t as Modal};
2
2
  //# sourceMappingURL=Modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../../../../../src/components/internal/Modal/Modal.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport cx from 'classnames';\nimport './Modal.scss';\nimport { useModal } from './useModal';\n\ntype ModalRenderFnProps = {\n /**\n * Function used to properly trigger the Modal close mechanism. It takes into account the element that the Modal needs\n * to set focus when it is dismissed.\n */\n onCloseModal(): void;\n};\n\ntype ModalProps = {\n children: ({ onCloseModal }: ModalRenderFnProps) => ComponentChildren;\n classNameModifiers?: string[];\n onClose(): void;\n isOpen: boolean;\n isDismissible?: boolean;\n labelledBy: string;\n describedBy: string;\n /**\n * Reference to the element that should be focused when the modal is opened\n */\n focusFirst: HTMLElement;\n /**\n * Reference to the element that should be focused when the modal is closed\n */\n focusAfterClose: HTMLElement;\n};\n\nconst Modal = ({\n children,\n classNameModifiers = [],\n isOpen,\n onClose,\n isDismissible = true,\n labelledBy,\n describedBy,\n focusFirst,\n focusAfterClose,\n ...props\n}: Readonly<ModalProps>) => {\n const modalContainerRef = useRef<HTMLDivElement>();\n const { closeModal, handleClickOutside } = useModal({\n modalElement: modalContainerRef.current,\n isOpen,\n isDismissible,\n focusFirst,\n focusAfterClose,\n onClose\n });\n\n /**\n * It shouldn't propagate ENTER key event to the parent component. This effect suppress the event propagation\n * (e.g. ENTER key press might trigger the payment flow for Card)\n */\n useEffect(() => {\n if (!modalContainerRef.current) return;\n\n const suppressKeyPress = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.code === 'Enter') event.stopPropagation();\n };\n\n modalContainerRef.current.addEventListener('keypress', suppressKeyPress, { capture: true });\n return () => {\n modalContainerRef.current.removeEventListener('keypress', suppressKeyPress);\n };\n }, [modalContainerRef.current]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <div\n className={cx(\n 'adyen-checkout__modal-wrapper',\n classNameModifiers.map(m => `adyen-checkout__modal-wrapper--${m}`),\n { 'adyen-checkout__modal-wrapper--open': isOpen }\n )}\n role=\"dialog\"\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-modal=\"true\"\n aria-hidden={!isOpen}\n onClick={handleClickOutside}\n {...props}\n >\n <div className=\"adyen-checkout__modal\" ref={modalContainerRef}>\n {children({ onCloseModal: closeModal })}\n </div>\n </div>\n );\n};\n\nexport { Modal };\n"],"names":["Modal","children","classNameModifiers","isOpen","onClose","isDismissible","labelledBy","describedBy","focusFirst","focusAfterClose","props","modalContainerRef","useRef","closeModal","handleClickOutside","useModal","modalElement","current","useEffect","suppressKeyPress","event","key","code","stopPropagation","addEventListener","capture","removeEventListener","h","div","className","cx","map","m","role","aria-labelledby","aria-describedby","aria-modal","aria-hidden","onClick","ref","onCloseModal"],"mappings":"gPAgCA,MAAMA,EAAQ,EACVC,WACAC,qBAAqB,GACrBC,SACAC,UACAC,iBAAgB,EAChBC,aACAC,cACAC,aACAC,qBACGC,MAEH,MAAMC,EAAoBC,KACpBC,WAAEA,EAAUC,mBAAEA,GAAuBC,EAAS,CAChDC,aAAcL,EAAkBM,QAChCd,SACAE,gBACAG,aACAC,kBACAL,YAoBJ,OAbAc,EAAU,KACN,IAAKP,EAAkBM,QAAS,OAEhC,MAAME,EAAoBC,IACJ,UAAdA,EAAMC,KAAkC,UAAfD,EAAME,MAAkBF,EAAMG,mBAI/D,OADAZ,EAAkBM,QAAQO,iBAAiB,WAAYL,EAAkB,CAAEM,SAAS,IAC7E,KACHd,EAAkBM,QAAQS,oBAAoB,WAAYP,KAE/D,CAACR,EAAkBM,UAIlBU,EAACC,MAAAA,CACGC,UAAWC,EACP,gCACA5B,EAAmB6B,IAAIC,GAAK,kCAAkCA,KAC9D,CAAE,sCAAuC7B,IAE7C8B,KAAK,SACLC,kBAAiB5B,EACjB6B,mBAAkB5B,EAClB6B,aAAW,OACXC,eAAclC,EACdmC,QAASxB,KACLJ,GAEJiB,EAACC,MAAAA,CAAIC,UAAU,wBAAwBU,IAAK5B,GACvCV,EAAS,CAAEuC,aAAc3B"}
1
+ {"version":3,"file":"Modal.js","sources":["../../../../../src/components/internal/Modal/Modal.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport cx from 'classnames';\nimport './Modal.scss';\nimport { useModal } from './useModal';\n\ntype ModalRenderFnProps = {\n /**\n * Function used to properly trigger the Modal close mechanism. It takes into account the element that the Modal needs\n * to set focus when it is dismissed.\n */\n onCloseModal(): void;\n};\n\ntype ModalProps = {\n children: ({ onCloseModal }: ModalRenderFnProps) => ComponentChildren;\n classNameModifiers?: string[];\n onClose(): void;\n isOpen: boolean;\n isDismissible?: boolean;\n labelledBy: string;\n describedBy: string;\n /**\n * Reference to the element that should be focused when the modal is opened\n */\n focusFirst: HTMLElement;\n /**\n * Reference to the element that should be focused when the modal is closed\n */\n focusAfterClose: HTMLElement;\n};\n\nconst Modal = ({\n children,\n classNameModifiers = [],\n isOpen,\n onClose,\n isDismissible = true,\n labelledBy,\n describedBy,\n focusFirst,\n focusAfterClose,\n ...props\n}: Readonly<ModalProps>) => {\n const modalContainerRef = useRef<HTMLDivElement>();\n const { closeModal, handleClickOutside } = useModal({\n modalElement: modalContainerRef.current,\n isOpen,\n isDismissible,\n focusFirst,\n focusAfterClose,\n onClose\n });\n\n /**\n * It shouldn't propagate ENTER key event to the parent component. This effect suppress the event propagation\n * (e.g. ENTER key press might trigger the payment flow for Card)\n */\n useEffect(() => {\n if (!modalContainerRef.current) return;\n\n const suppressKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.code === 'Enter') event.stopPropagation();\n };\n\n modalContainerRef.current.addEventListener('keydown', suppressKeyDown, { capture: true });\n return () => {\n modalContainerRef.current.removeEventListener('keydown', suppressKeyDown);\n };\n }, [modalContainerRef.current]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <div\n className={cx(\n 'adyen-checkout__modal-wrapper',\n classNameModifiers.map(m => `adyen-checkout__modal-wrapper--${m}`),\n { 'adyen-checkout__modal-wrapper--open': isOpen }\n )}\n role=\"dialog\"\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-modal=\"true\"\n aria-hidden={!isOpen}\n onClick={handleClickOutside}\n {...props}\n >\n <div className=\"adyen-checkout__modal\" ref={modalContainerRef}>\n {children({ onCloseModal: closeModal })}\n </div>\n </div>\n );\n};\n\nexport { Modal };\n"],"names":["Modal","children","classNameModifiers","isOpen","onClose","isDismissible","labelledBy","describedBy","focusFirst","focusAfterClose","props","modalContainerRef","useRef","closeModal","handleClickOutside","useModal","modalElement","current","useEffect","suppressKeyDown","event","key","code","stopPropagation","addEventListener","capture","removeEventListener","h","div","className","cx","map","m","role","aria-labelledby","aria-describedby","aria-modal","aria-hidden","onClick","ref","onCloseModal"],"mappings":"gPAgCA,MAAMA,EAAQ,EACVC,WACAC,qBAAqB,GACrBC,SACAC,UACAC,iBAAgB,EAChBC,aACAC,cACAC,aACAC,qBACGC,MAEH,MAAMC,EAAoBC,KACpBC,WAAEA,EAAUC,mBAAEA,GAAuBC,EAAS,CAChDC,aAAcL,EAAkBM,QAChCd,SACAE,gBACAG,aACAC,kBACAL,YAoBJ,OAbAc,EAAU,KACN,IAAKP,EAAkBM,QAAS,OAEhC,MAAME,EAAmBC,IACH,UAAdA,EAAMC,KAAkC,UAAfD,EAAME,MAAkBF,EAAMG,mBAI/D,OADAZ,EAAkBM,QAAQO,iBAAiB,UAAWL,EAAiB,CAAEM,SAAS,IAC3E,KACHd,EAAkBM,QAAQS,oBAAoB,UAAWP,KAE9D,CAACR,EAAkBM,UAIlBU,EAACC,MAAAA,CACGC,UAAWC,EACP,gCACA5B,EAAmB6B,IAAIC,GAAK,kCAAkCA,KAC9D,CAAE,sCAAuC7B,IAE7C8B,KAAK,SACLC,kBAAiB5B,EACjB6B,mBAAkB5B,EAClB6B,aAAW,OACXC,eAAclC,EACdmC,QAASxB,KACLJ,GAEJiB,EAACC,MAAAA,CAAIC,UAAU,wBAAwBU,IAAK5B,GACvCV,EAAS,CAAEuC,aAAc3B"}
@@ -1,2 +1,2 @@
1
- import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as s,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import n from"../lib/CSF/initCSF.js";import r from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as m}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as f}from"../../../../core/Errors/constants.js";import{TxVariants as C}from"../../../tx-variants.js";function y(t,s,e){return s in t?Object.defineProperty(t,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[s]=e,t}class F extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=s(this.rootNode),i=t.reduce(e,{});this.setState({valid:i}),t.forEach(t=>{this.numCharsInField[t]=0}),this.numDateFields=t.filter(t=>t.match(/Expiry/)).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):(this.props.componentType===C.customCard&&console.debug('You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a "data-cse" attribute e.g. <div data-cse="encryptedCardNumber"></div>'),this.handleOnNoDataRequired())}componentDidUpdate(){this.checkForKCPFields(),this.props.onStateUpdate?.(this.state)}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){let s=this.props.loadingContext;const e={rootNode:t,type:this.props.type,componentType:this.props.componentType,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,onSubmitAnalytics:this.props.onSubmitAnalytics,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyPressed:this.handleKeyPressed},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:this.props.placeholders??{},showContextualElement:this.props.showContextualElement};this.csf=n(e),this.csfLoadFailTimeout=setTimeout(()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))},this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:{...t.data,[a]:void 0},valid:{...t.valid,[a]:!1},errors:{...t.errors,[a]:null},hasKoreanFields:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.removeSecuredField(a),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:{...t.valid,[a]:!1},hasKoreanFields:!0,isSfpValid:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.addSecuredField(a),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const s=!!t.error;return s&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,s),this.csf&&this.csf.hasUnsupportedCard(h,t.error),s}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}getRootNode(){return this.rootNode}showValidation(){const{numDateFields:t,state:s}=this;Object.keys(s.valid).reduce(i(t,s),[]).forEach(t=>{const e=o(t,this.rootNode,s);this.handleOnError(e,!!s.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,e.error)})}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce((t,s)=>{const e=this.state.errors[s];return t[s]=e?{isValid:!1,errorMessage:m(e,f),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode,...this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}}:null,t},{})}processBinLookupResponse(t,s){if(this.state.detectedUnsupportedBrands&&(this.setState(t=>({errors:{...t.errors,[h]:null},detectedUnsupportedBrands:null})),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=t?.issuingCountryCode?.toLowerCase();const e=s?.brand,i=e&&l.includes(s.brand);i&&this.setState(s,()=>{this.props.onChange(this.state)}),this.csf&&this.csf.brandsFromBinLookup(t,i?s:null)}render(t,s){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},s)}constructor(t){super(t),y(this,"csfLoadFailTimeout",void 0),y(this,"csfLoadFailTimeoutMS",void 0),y(this,"csfConfigFailTimeout",void 0),y(this,"csfConfigFailTimeoutMS",void 0),y(this,"numCharsInField",void 0),y(this,"rootNode",void 0),y(this,"numDateFields",void 0),y(this,"csf",void 0),y(this,"handleOnLoad",void 0),y(this,"handleOnConfigSuccess",void 0),y(this,"handleOnFieldValid",void 0),y(this,"handleOnAllValid",void 0),y(this,"handleOnBrand",void 0),y(this,"handleFocus",void 0),y(this,"handleOnError",void 0),y(this,"handleOnAutoComplete",void 0),y(this,"handleOnNoDataRequired",void 0),y(this,"handleOnTouchstartIOS",void 0),y(this,"handleKeyPressed",void 0),y(this,"state",void 0),y(this,"props",void 0),y(this,"issuingCountryCode",void 0),y(this,"setRootNode",t=>{this.rootNode=t});const s={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=s,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=r.handleOnLoad.bind(this),this.handleOnConfigSuccess=r.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=r.handleOnFieldValid.bind(this),this.handleOnAllValid=r.handleOnAllValid.bind(this),this.handleOnBrand=r.handleOnBrand.bind(this),this.handleFocus=r.handleFocus.bind(this),this.handleOnError=r.handleOnError.bind(this),this.handleOnNoDataRequired=r.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=r.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=r.handleOnTouchstartIOS.bind(this),this.handleKeyPressed=r.handleKeyPressed.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}y(F,"defaultProps",d);export{F as default};
1
+ import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as s,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import n from"../lib/CSF/initCSF.js";import r from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as m}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as f}from"../../../../core/Errors/constants.js";import{TxVariants as C}from"../../../tx-variants.js";function y(t,s,e){return s in t?Object.defineProperty(t,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[s]=e,t}class F extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=s(this.rootNode),i=t.reduce(e,{});this.setState({valid:i}),t.forEach(t=>{this.numCharsInField[t]=0}),this.numDateFields=t.filter(t=>t.match(/Expiry/)).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):(this.props.componentType===C.customCard&&console.debug('You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a "data-cse" attribute e.g. <div data-cse="encryptedCardNumber"></div>'),this.handleOnNoDataRequired())}componentDidUpdate(){this.checkForKCPFields(),this.props.onStateUpdate?.(this.state)}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){let s=this.props.loadingContext;const e={rootNode:t,type:this.props.type,componentType:this.props.componentType,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,onSubmitAnalytics:this.props.onSubmitAnalytics,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyDown:this.handleKeyDown},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:this.props.placeholders??{},showContextualElement:this.props.showContextualElement};this.csf=n(e),this.csfLoadFailTimeout=setTimeout(()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))},this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:{...t.data,[a]:void 0},valid:{...t.valid,[a]:!1},errors:{...t.errors,[a]:null},hasKoreanFields:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.removeSecuredField(a),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:{...t.valid,[a]:!1},hasKoreanFields:!0,isSfpValid:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.addSecuredField(a),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const s=!!t.error;return s&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,s),this.csf&&this.csf.hasUnsupportedCard(h,t.error),s}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}getRootNode(){return this.rootNode}showValidation(){const{numDateFields:t,state:s}=this;Object.keys(s.valid).reduce(i(t,s),[]).forEach(t=>{const e=o(t,this.rootNode,s);this.handleOnError(e,!!s.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,e.error)})}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce((t,s)=>{const e=this.state.errors[s];return t[s]=e?{isValid:!1,errorMessage:m(e,f),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode,...this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}}:null,t},{})}processBinLookupResponse(t,s){if(this.state.detectedUnsupportedBrands&&(this.setState(t=>({errors:{...t.errors,[h]:null},detectedUnsupportedBrands:null})),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=t?.issuingCountryCode?.toLowerCase();const e=s?.brand,i=e&&l.includes(s.brand);i&&this.setState(s,()=>{this.props.onChange(this.state)}),this.csf&&this.csf.brandsFromBinLookup(t,i?s:null)}render(t,s){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},s)}constructor(t){super(t),y(this,"csfLoadFailTimeout",void 0),y(this,"csfLoadFailTimeoutMS",void 0),y(this,"csfConfigFailTimeout",void 0),y(this,"csfConfigFailTimeoutMS",void 0),y(this,"numCharsInField",void 0),y(this,"rootNode",void 0),y(this,"numDateFields",void 0),y(this,"csf",void 0),y(this,"handleOnLoad",void 0),y(this,"handleOnConfigSuccess",void 0),y(this,"handleOnFieldValid",void 0),y(this,"handleOnAllValid",void 0),y(this,"handleOnBrand",void 0),y(this,"handleFocus",void 0),y(this,"handleOnError",void 0),y(this,"handleOnAutoComplete",void 0),y(this,"handleOnNoDataRequired",void 0),y(this,"handleOnTouchstartIOS",void 0),y(this,"handleKeyDown",void 0),y(this,"state",void 0),y(this,"props",void 0),y(this,"issuingCountryCode",void 0),y(this,"setRootNode",t=>{this.rootNode=t});const s={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=s,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=r.handleOnLoad.bind(this),this.handleOnConfigSuccess=r.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=r.handleOnFieldValid.bind(this),this.handleOnAllValid=r.handleOnAllValid.bind(this),this.handleOnBrand=r.handleOnBrand.bind(this),this.handleFocus=r.handleFocus.bind(this),this.handleOnError=r.handleOnError.bind(this),this.handleOnNoDataRequired=r.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=r.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=r.handleOnTouchstartIOS.bind(this),this.handleKeyDown=r.handleKeyDown.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}y(F,"defaultProps",d);export{F as default};
2
2
  //# sourceMappingURL=SecuredFieldsProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj,\n SFFieldType\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { TxVariants } from '../../../tx-variants';\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: HTMLElement;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props: SFPProps;\n private issuingCountryCode: string;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static readonly 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();\n this.initializeCSF(this.rootNode);\n } else {\n if (this.props.componentType === (TxVariants.customCard as string)) {\n console.debug(\n 'You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a \"data-cse\" attribute e.g. <div data-cse=\"encryptedCardNumber\"></div>'\n );\n }\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n // Pass all the state data up - Used right now for loading status\n this.props.onStateUpdate?.(this.state);\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 const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n componentType: this.props.componentType,\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 onSubmitAnalytics: this.props.onSubmitAnalytics,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: null },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: SFFieldType): 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 as SFFieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public getRootNode(): HTMLElement {\n return this.rootNode;\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: SFFieldType) => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: null },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state: SFPState) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","componentType","TxVariants","customCard","console","debug","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","onStateUpdate","state","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","onSubmitAnalytics","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","getRootNode","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","hasBrandedResetObj","brand","mustResetDedicatedBrand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"20BAgCA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAA,GAEhDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,QAAQC,IACXX,KAAKY,gBAAgBD,GAAS,IAIlCX,KAAKa,cAAgBT,EAAOU,OAAOC,GAAKA,EAAEC,MAAM,WAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,YAEpBF,KAAKC,MAAMmB,gBAAmBC,EAAWC,YACzCC,QAAQC,MACJ,yOAGRxB,KAAKyB,yBAEb,CAEOC,kBAAAA,GACH1B,KAAK2B,oBAEL3B,KAAKC,MAAM2B,gBAAgB5B,KAAK6B,MACpC,CAEOC,oBAAAA,GACH9B,KAAK+B,IAAM,KACXC,aAAahC,KAAKiC,oBAClBD,aAAahC,KAAKkC,qBACtB,CAEQf,aAAAA,CAAcgB,GAClB,IAAIC,EAAiBpC,KAAKC,MAAMmC,eAOhC,MAAMC,EAA8B,CAChCnC,SAAUiC,EACVG,KAAMtC,KAAKC,MAAMqC,KACjBlB,cAAepB,KAAKC,MAAMmB,cAC1BmB,UAAWvC,KAAKC,MAAMsC,UACtBC,eAA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0J,EAvEE7J,EAuEqBuK,eAAeA"}
1
+ {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyDownObj,\n SFFieldType\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { TxVariants } from '../../../tx-variants';\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 readonly csfLoadFailTimeoutMS: number;\n private readonly csfConfigFailTimeout: number;\n private readonly csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode: HTMLElement;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private readonly handleOnLoad: (obj: CardLoadData) => void;\n private readonly handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private readonly handleOnFieldValid: (obj: CardFieldValidData) => void;\n private readonly handleOnAllValid: (obj: CardAllValidData) => void;\n private readonly handleOnBrand: (obj: CardBrandData) => void;\n private readonly handleFocus: (obj: CardFocusData) => void;\n private readonly handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private readonly handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private readonly handleOnNoDataRequired: () => void;\n private readonly handleOnTouchstartIOS: (obj) => void;\n private readonly handleKeyDown: (obj: SFKeyDownObj) => void;\n public state: SFPState;\n public props: SFPProps;\n private issuingCountryCode: string;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyDown = handlers.handleKeyDown.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static readonly 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();\n this.initializeCSF(this.rootNode);\n } else {\n if (this.props.componentType === (TxVariants.customCard as string)) {\n console.debug(\n 'You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a \"data-cse\" attribute e.g. <div data-cse=\"encryptedCardNumber\"></div>'\n );\n }\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n // Pass all the state data up - Used right now for loading status\n this.props.onStateUpdate?.(this.state);\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 const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n componentType: this.props.componentType,\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 onSubmitAnalytics: this.props.onSubmitAnalytics,\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 onKeyDown: this.handleKeyDown\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: null },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: SFFieldType): 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 as SFFieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public getRootNode(): HTMLElement {\n return this.rootNode;\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: SFFieldType) => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: null },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state: SFPState) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","componentType","TxVariants","customCard","console","debug","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","onStateUpdate","state","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","onSubmitAnalytics","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyDown","handleKeyDown","isKCP","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","getRootNode","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","hasBrandedResetObj","brand","mustResetDedicatedBrand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"20BAgCA,MAAMA,UAA8BC,EAyEzBC,i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,KAAKuD,sBAAwB2G,EAAS3G,sBAAsB4G,KAAKnK,MACjEA,KAAKyD,mBAAqByG,EAASzG,mBAAmB0G,KAAKnK,MAC3DA,KAAK2D,iBAAmBuG,EAASvG,iBAAiBwG,KAAKnK,MACvDA,KAAK6D,cAAgBqG,EAASrG,cAAcsG,KAAKnK,MACjDA,KAAKiE,YAAciG,EAASjG,YAAYkG,KAAKnK,MAC7CA,KAAK+D,cAAgBmG,EAASnG,cAAcoG,KAAKnK,MACjDA,KAAKyB,uBAAyByI,EAASzI,uBAAuB0I,KAAKnK,MACnEA,KAAKoE,qBAAuB8F,EAAS9F,qBAAqB+F,KAAKnK,MAC/DA,KAAKwE,sBAAwB0F,EAAS1F,sBAAsB2F,KAAKnK,MACjEA,KAAK0E,cAAgBwF,EAASxF,cAAcyF,KAAKnK,MAEjDA,KAAK6I,yBAA2B7I,KAAK6I,yBAAyBsB,KAAKnK,MAGnEA,KAAKoH,WAAapH,KAAKoH,WAAW+C,KAAKnK,MACvCA,KAAKuH,aAAevH,KAAKuH,aAAa4C,KAAKnK,MAC3CA,KAAK6G,sBAAwB7G,KAAK6G,sBAAsBsD,KAAKnK,MAC7DA,KAAK4H,eAAiB5H,KAAK4H,eAAeuC,KAAKnK,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQiJ,KAAKnK,KACrC,EAEA0J,EAvEE7J,EAuEqBuK,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{getCardImageUrl as e}from"../utils.js";import{ENCRYPTED_CARD_NUMBER as t,ENCRYPTED_SECURITY_CODE as s,ENCRYPTED_EXPIRY_DATE as i,ENCRYPTED_EXPIRY_MONTH as n,ENCRYPTED_EXPIRY_YEAR as r,DATE_POLICY_REQUIRED as o,CVC_POLICY_REQUIRED as a,OPTIONAL as l,HIDDEN as d}from"../lib/constants.js";import{existy as h}from"../../../../utils/commonUtils.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";function p(e,t,s,i){return(t!==l&&t!==d||0!==s[e])&&i[e]}var c={handleFocus:function(e){this.numCharsInField[e.fieldType]=e.numChars,this.props.onFocus(e)},handleOnAllValid:function(e){return!this.state.detectedUnsupportedBrands&&(this.setState({isSfpValid:e.allValid},()=>{this.props.onChange(this.state,{event:"handleOnAllValid"}),this.props.onAllValid(e)}),!0)},handleOnAutoComplete:function(e){this.setState({autoCompleteName:e.value},()=>{this.props.onChange(this.state,{event:"handleOnAutoComplete",fieldType:e.fieldType}),this.setState({autoCompleteName:null})}),this.props.onAutoComplete(e)},handleOnFieldValid:function(e){return(!this.state.detectedUnsupportedBrands||e.fieldType!==t)&&(this.setState(t=>({data:{...t.data,[e.encryptedFieldName]:e.blob},valid:{...t.valid,[e.encryptedFieldName]:e.valid},errors:{...t.errors,[e.fieldType]:t.errors[e.fieldType]??null}}),()=>{this.props.onChange(this.state,{event:"handleOnFieldValid",fieldType:e.fieldType}),this.props.onFieldValid(e)}),!0)},handleOnLoad:function(e){clearTimeout(this.csfLoadFailTimeout),this.csfLoadFailTimeout=null,this.props.onLoad(e),this.csfConfigFailTimeout=setTimeout(()=>{"ready"!==this.state.status&&(this.setState({status:"csfConfigFailure"}),this.props.onError(new u("ERROR","secured fields have failed to configure")))},this.csfConfigFailTimeoutMS)},handleOnConfigSuccess:function(e){clearTimeout(this.csfConfigFailTimeout),this.csfConfigFailTimeout=null,this.setState({status:"ready"},()=>{this.props.onConfigSuccess(e)})},handleOnBrand:function(t){this.setState(e=>{const l=p(s,t.cvcPolicy,this.numCharsInField,e.errors),d=1===this.numDateFields?p(i,t.expiryDatePolicy,this.numCharsInField,e.errors):null,u=2===this.numDateFields?p(n,t.expiryDatePolicy,this.numCharsInField,e.errors):null,c=2===this.numDateFields?p(r,t.expiryDatePolicy,this.numCharsInField,e.errors):null;return{brand:t.brand,cvcPolicy:t.cvcPolicy??a,showSocialSecurityNumber:t.showSocialSecurityNumber,errors:{...e.errors,...h(l)&&{[s]:l},...h(d)&&{[i]:d},...h(u)&&{[n]:u},...h(c)&&{[r]:c}},expiryDatePolicy:t.expiryDatePolicy??o}},()=>{this.props.onChange(this.state,{event:"handleOnBrand"});const s=this.props.brandsConfiguration[t.brand]?.icon??e(t.brand,this.props.resources);this.props.onBrand({...t,brandImageUrl:s})})},handleOnError:function(e,s=null){const i=e.error;return this.setState(n=>({errors:{...n.errors,[e.fieldType]:i||null},...s&&{data:{...n.data,[t]:void 0}},...s&&{valid:{...n.valid,[t]:!1}},...s&&{isSfpValid:!1}}),()=>{this.props.onChange(this.state,{event:"handleOnError",fieldType:e.fieldType})}),!0},handleOnNoDataRequired:function(){this.setState({status:"ready"},()=>this.props.onChange({isSfpValid:!0}))},handleOnTouchstartIOS:function(e){this.props.disableIOSArrowKeys?.(e)},handleKeyPressed:function(e){if("enterKeyPressed"===e.action){const e=new KeyboardEvent("keypress",{bubbles:!0,cancelable:!0,key:"Enter",code:"Enter"});this.props.handleKeyPress?.(e)}}};export{c as default};
1
+ import{getCardImageUrl as e}from"../utils.js";import{ENCRYPTED_CARD_NUMBER as t,ENCRYPTED_SECURITY_CODE as i,ENCRYPTED_EXPIRY_DATE as s,ENCRYPTED_EXPIRY_MONTH as n,ENCRYPTED_EXPIRY_YEAR as o,DATE_POLICY_REQUIRED as r,CVC_POLICY_REQUIRED as a,OPTIONAL as l,HIDDEN as d}from"../lib/constants.js";import{existy as h}from"../../../../utils/commonUtils.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";function p(e,t,i,s){return(t!==l&&t!==d||0!==i[e])&&s[e]}var c={handleFocus:function(e){this.numCharsInField[e.fieldType]=e.numChars,this.props.onFocus(e)},handleOnAllValid:function(e){return!this.state.detectedUnsupportedBrands&&(this.setState({isSfpValid:e.allValid},()=>{this.props.onChange(this.state,{event:"handleOnAllValid"}),this.props.onAllValid(e)}),!0)},handleOnAutoComplete:function(e){this.setState({autoCompleteName:e.value},()=>{this.props.onChange(this.state,{event:"handleOnAutoComplete",fieldType:e.fieldType}),this.setState({autoCompleteName:null})}),this.props.onAutoComplete(e)},handleOnFieldValid:function(e){return(!this.state.detectedUnsupportedBrands||e.fieldType!==t)&&(this.setState(t=>({data:{...t.data,[e.encryptedFieldName]:e.blob},valid:{...t.valid,[e.encryptedFieldName]:e.valid},errors:{...t.errors,[e.fieldType]:t.errors[e.fieldType]??null}}),()=>{this.props.onChange(this.state,{event:"handleOnFieldValid",fieldType:e.fieldType}),this.props.onFieldValid(e)}),!0)},handleOnLoad:function(e){clearTimeout(this.csfLoadFailTimeout),this.csfLoadFailTimeout=null,this.props.onLoad(e),this.csfConfigFailTimeout=setTimeout(()=>{"ready"!==this.state.status&&(this.setState({status:"csfConfigFailure"}),this.props.onError(new u("ERROR","secured fields have failed to configure")))},this.csfConfigFailTimeoutMS)},handleOnConfigSuccess:function(e){clearTimeout(this.csfConfigFailTimeout),this.csfConfigFailTimeout=null,this.setState({status:"ready"},()=>{this.props.onConfigSuccess(e)})},handleOnBrand:function(t){this.setState(e=>{const l=p(i,t.cvcPolicy,this.numCharsInField,e.errors),d=1===this.numDateFields?p(s,t.expiryDatePolicy,this.numCharsInField,e.errors):null,u=2===this.numDateFields?p(n,t.expiryDatePolicy,this.numCharsInField,e.errors):null,c=2===this.numDateFields?p(o,t.expiryDatePolicy,this.numCharsInField,e.errors):null;return{brand:t.brand,cvcPolicy:t.cvcPolicy??a,showSocialSecurityNumber:t.showSocialSecurityNumber,errors:{...e.errors,...h(l)&&{[i]:l},...h(d)&&{[s]:d},...h(u)&&{[n]:u},...h(c)&&{[o]:c}},expiryDatePolicy:t.expiryDatePolicy??r}},()=>{this.props.onChange(this.state,{event:"handleOnBrand"});const i=this.props.brandsConfiguration[t.brand]?.icon??e(t.brand,this.props.resources);this.props.onBrand({...t,brandImageUrl:i})})},handleOnError:function(e,i=null){const s=e.error;return this.setState(n=>({errors:{...n.errors,[e.fieldType]:s||null},...i&&{data:{...n.data,[t]:void 0}},...i&&{valid:{...n.valid,[t]:!1}},...i&&{isSfpValid:!1}}),()=>{this.props.onChange(this.state,{event:"handleOnError",fieldType:e.fieldType})}),!0},handleOnNoDataRequired:function(){this.setState({status:"ready"},()=>this.props.onChange({isSfpValid:!0}))},handleOnTouchstartIOS:function(e){this.props.disableIOSArrowKeys?.(e)},handleKeyDown:function(e){if("enterKeyPressed"===e.action){const e=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,key:"Enter",code:"Enter"});this.props.handleKeyDown?.(e)}}};export{c as default};
2
2
  //# sourceMappingURL=SecuredFieldsProviderHandlers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecuredFieldsProviderHandlers.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.ts"],"sourcesContent":["import { getCardImageUrl } from '../utils';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE,\n OPTIONAL,\n HIDDEN,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../lib/constants';\nimport {\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { existy } from '../../../../utils/commonUtils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Emits the onLoad event\n * Here we can assume all securedFields iframes have fired their 'load' event\n */\nfunction handleOnLoad(cbObj: CardLoadData): void {\n // Clear 'loading' timeout\n clearTimeout(this.csfLoadFailTimeout);\n this.csfLoadFailTimeout = null;\n\n // Propagate onLoad event\n this.props.onLoad(cbObj);\n\n /**\n * Having seen that the securedFields iframes have loaded some kind of content (we don't know what, yet)\n * - setTimeout since we expect to get a successful configuration message \"within a reasonable time\"\n *\n * Now we catch clientKey & environment mismatch in core.ts - this timeout being called indicates that the securedFields have not all configured\n * - so we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n this.csfConfigFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfConfigFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured fields have failed to configure'));\n }\n }, this.csfConfigFailTimeoutMS);\n}\n\n/**\n * Emits the onConfigSuccess (ready) event\n * Here we can assume CSF is loaded, configured and ready to be used\n */\nfunction handleOnConfigSuccess(cbObj: CardConfigSuccessData): void {\n // Clear 'config' timeout\n clearTimeout(this.csfConfigFailTimeout);\n this.csfConfigFailTimeout = null;\n\n this.setState({ status: 'ready' }, () => {\n // Propagate onConfigSuccess event\n this.props.onConfigSuccess(cbObj);\n });\n}\n\n/**\n * Emits the onAllValid event\n */\nfunction handleOnAllValid(status: CardAllValidData): boolean {\n // Form cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands) {\n return false;\n }\n\n this.setState({ isSfpValid: status.allValid }, () => {\n // New - fixes maestro-with-error-on-optional-cvc-field bug\n this.props.onChange(this.state, { event: 'handleOnAllValid' });\n // Propagate onAllValid event\n this.props.onAllValid(status);\n });\n\n return true;\n}\n\n/**\n * Saves a field value from CSF in the CardInput state\n * Emits the onFieldValid event\n */\nfunction handleOnFieldValid(fieldObj: CardFieldValidData): boolean {\n // A card number field cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands && fieldObj.fieldType === ENCRYPTED_CARD_NUMBER) {\n return false;\n }\n\n const setValidFieldState = prevState => ({\n data: { ...prevState.data, [fieldObj.encryptedFieldName]: fieldObj.blob },\n valid: { ...prevState.valid, [fieldObj.encryptedFieldName]: fieldObj.valid },\n /**\n * For a field that has just received valid:true (field has just been completed & encrypted) - mark the error state for this field as false\n * For a field that has just received valid:false (field was encrypted, now is not)\n * - field is either in a state of being incomplete but without errors (digit deleted) - so mark the error state for this field as false\n * or has switched from valid/encrypted state to being in error (digit edited to one that puts the field in error) - so keep any error that\n * might just have been set\n */\n errors: { ...prevState.errors, [fieldObj.fieldType]: prevState.errors[fieldObj.fieldType] ?? null }\n });\n\n this.setState(setValidFieldState, () => {\n this.props.onChange(this.state, { event: 'handleOnFieldValid', fieldType: fieldObj.fieldType });\n\n // Propagate onFieldValid event\n this.props.onFieldValid(fieldObj);\n });\n\n return true;\n}\n\nfunction fieldIsInError(fieldType: string, policy: string, numCharsObj: object, errorsObj) {\n return (policy === OPTIONAL || policy === HIDDEN) && numCharsObj[fieldType] === 0 ? false : errorsObj[fieldType];\n}\n\n/**\n * Saves the card brand in state\n * Emits the onBrand event\n */\nfunction handleOnBrand(cardInfo: CardBrandData): void {\n this.setState(\n prevState => {\n /**\n * If we change brand to one where the cvc or date field(s) are not required & are empty - then these fields cannot be in error\n * (scenario: have validated empty form, then choose brand w. optional/hidden cvc or date)...\n * ...else propagate the existing error.\n */\n const cvcFieldInError = fieldIsInError(ENCRYPTED_SECURITY_CODE, cardInfo.cvcPolicy, this.numCharsInField, prevState.errors);\n\n const dateFieldInError =\n this.numDateFields === 1\n ? fieldIsInError(ENCRYPTED_EXPIRY_DATE, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n // For custom card comp\n const monthFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_MONTH, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n const yearFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_YEAR, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n // --\n /** end */\n\n return {\n brand: cardInfo.brand,\n cvcPolicy: cardInfo.cvcPolicy ?? CVC_POLICY_REQUIRED,\n showSocialSecurityNumber: cardInfo.showSocialSecurityNumber,\n errors: {\n ...prevState.errors,\n ...(existy(cvcFieldInError) && { [ENCRYPTED_SECURITY_CODE]: cvcFieldInError }),\n ...(existy(dateFieldInError) && { [ENCRYPTED_EXPIRY_DATE]: dateFieldInError }),\n ...(existy(monthFieldInError) && { [ENCRYPTED_EXPIRY_MONTH]: monthFieldInError }),\n ...(existy(yearFieldInError) && { [ENCRYPTED_EXPIRY_YEAR]: yearFieldInError })\n },\n expiryDatePolicy: cardInfo.expiryDatePolicy ?? DATE_POLICY_REQUIRED\n };\n },\n () => {\n this.props.onChange(this.state, { event: 'handleOnBrand' });\n\n // Enhance data object with the url for the brand image, first checking if the merchant has configured their own one for this brand\n const brandImageUrl = this.props.brandsConfiguration[cardInfo.brand]?.icon ?? getCardImageUrl(cardInfo.brand, this.props.resources);\n this.props.onBrand({ ...cardInfo, brandImageUrl });\n }\n );\n}\n\n/**\n * Handles validation errors\n */\nfunction handleOnError(cbObj: CardErrorData, hasUnsupportedCard: boolean = null): boolean {\n const errorCode = cbObj.error;\n\n this.setState(\n prevState => ({\n errors: { ...prevState.errors, [cbObj.fieldType]: errorCode || null },\n // If dealing with an unsupported card ensure these card number related fields are reset re. pasting a full, unsupported card straight in\n ...(hasUnsupportedCard && { data: { ...prevState.data, [ENCRYPTED_CARD_NUMBER]: undefined } }),\n ...(hasUnsupportedCard && { valid: { ...prevState.valid, [ENCRYPTED_CARD_NUMBER]: false } }),\n ...(hasUnsupportedCard && { isSfpValid: false })\n }),\n () => {\n this.props.onChange(this.state, { event: 'handleOnError', fieldType: cbObj.fieldType });\n }\n );\n\n return true;\n}\n\nfunction handleFocus(cbObj: CardFocusData): void {\n this.numCharsInField[cbObj.fieldType] = cbObj.numChars;\n\n this.props.onFocus(cbObj);\n}\n\nfunction handleOnTouchstartIOS(cbObj): void {\n // disableIOSArrowKeys is either null or a function (in which case we should call it)\n this.props.disableIOSArrowKeys?.(cbObj);\n}\n\n// Only called for holder name (from CSF>partials>processAutoComplete)\nfunction handleOnAutoComplete(cbObj: CardAutoCompleteData): void {\n this.setState({ autoCompleteName: cbObj.value }, () => {\n this.props.onChange(this.state, { event: 'handleOnAutoComplete', fieldType: cbObj.fieldType });\n this.setState({ autoCompleteName: null }); // Nullify ref after sending it (lets shopper edit holder name)\n });\n this.props.onAutoComplete(cbObj);\n}\n\nfunction handleKeyPressed(obj: SFKeyPressObj): void {\n if (obj.action === 'enterKeyPressed') {\n const kb = new KeyboardEvent('keypress', {\n bubbles: true,\n cancelable: true,\n key: 'Enter',\n code: 'Enter'\n });\n this.props.handleKeyPress?.(kb);\n }\n}\n\n/**\n * Handles cases where no secured fields are necessary (one click payments without CVC)\n * Automatically resolves with a valid state\n */\nfunction handleOnNoDataRequired(): void {\n this.setState({ status: 'ready' }, () => this.props.onChange({ isSfpValid: true }));\n}\n\nexport default {\n handleFocus,\n handleOnAllValid,\n handleOnAutoComplete,\n handleOnFieldValid,\n handleOnLoad,\n handleOnConfigSuccess,\n handleOnBrand,\n handleOnError,\n handleOnNoDataRequired,\n handleOnTouchstartIOS,\n handleKeyPressed\n};\n"],"names":["fieldIsInError","fieldType","policy","numCharsObj","errorsObj","OPTIONAL","HIDDEN","handlers","handleFocus","cbObj","this","numCharsInField","numChars","props","onFocus","handleOnAllValid","status","state","detectedUnsupportedBrands","setState","isSfpValid","allValid","onChange","event","onAllValid","handleOnAutoComplete","autoCompleteName","value","onAutoComplete","handleOnFieldValid","fieldObj","ENCRYPTED_CARD_NUMBER","prevState","data","encryptedFieldName","blob","valid","errors","onFieldValid","handleOnLoad","clearTimeout","csfLoadFailTimeout","onLoad","csfConfigFailTimeout","setTimeout","onError","AdyenCheckoutError","csfConfigFailTimeoutMS","handleOnConfigSuccess","onConfigSuccess","handleOnBrand","cardInfo","cvcFieldInError","ENCRYPTED_SECURITY_CODE","cvcPolicy","dateFieldInError","numDateFields","ENCRYPTED_EXPIRY_DATE","expiryDatePolicy","monthFieldInError","ENCRYPTED_EXPIRY_MONTH","yearFieldInError","ENCRYPTED_EXPIRY_YEAR","brand","CVC_POLICY_REQUIRED","showSocialSecurityNumber","existy","DATE_POLICY_REQUIRED","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","onBrand","handleOnError","hasUnsupportedCard","errorCode","error","undefined","handleOnNoDataRequired","handleOnTouchstartIOS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,IAGvD,KACIzD,KAAKG,MAAMS,SAASZ,KAAKO,MAAO,CAAEM,MAAO,kBAGzC,MAAM6C,EAAgB1D,KAAKG,MAAMwD,oBAAoBlB,EAASY,QAAQO,MAAQC,EAAgBpB,EAASY,MAAOrD,KAAKG,MAAM2D,WACzH9D,KAAKG,MAAM4D,QAAQ,IAAKtB,EAAUiB,mBAG9C,EAwEIM,cAnEJ,SAAuBjE,EAAsBkE,EAA8B,MACvE,MAAMC,EAAYnE,EAAMoE,MAexB,OAbAnE,KAAKS,SACDa,KACIK,OAAQ,IAAKL,EAAUK,OAAQ,CAAC5B,EAAMR,WAAY2E,GAAa,SAE3DD,GAAsB,CAAE1C,KAAM,IAAKD,EAAUC,KAAMF,CAACA,QAAwB+C,OAC5EH,GAAsB,CAAEvC,MAAO,IAAKJ,EAAUI,MAAOL,CAACA,IAAwB,OAC9E4C,GAAsB,CAAEvD,YAAY,KAE5C,KACIV,KAAKG,MAAMS,SAASZ,KAAKO,MAAO,CAAEM,MAAO,gBAAiBtB,UAAWQ,EAAMR,eAI5E,CACX,EAmDI8E,uBAbJ,WACIrE,KAAKS,SAAS,CAAEH,OAAQ,SAAW,IAAMN,KAAKG,MAAMS,SAAS,CAAEF,YAAY,IAC/E,EAYI4D,sBA5CJ,SAA+BvE,GAE3BC,KAAKG,MAAMoE,sBAAsBxE,EACrC,EA0CIyE,iBA/BJ,SAA0BC,GACtB,GAAmB,oBAAfA,EAAIC,OAA8B,CAClC,MAAMC,EAAK,IAAIC,cAAc,WAAY,CACrCC,SAAS,EACTC,YAAY,EACZC,IAAK,QACLC,KAAM,UAEVhF,KAAKG,MAAM8E,iBAAiBN,EAChC,CACJ"}
1
+ {"version":3,"file":"SecuredFieldsProviderHandlers.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.ts"],"sourcesContent":["import { getCardImageUrl } from '../utils';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE,\n OPTIONAL,\n HIDDEN,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../lib/constants';\nimport {\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyDownObj\n} from '../lib/types';\nimport { existy } from '../../../../utils/commonUtils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Emits the onLoad event\n * Here we can assume all securedFields iframes have fired their 'load' event\n */\nfunction handleOnLoad(cbObj: CardLoadData): void {\n // Clear 'loading' timeout\n clearTimeout(this.csfLoadFailTimeout);\n this.csfLoadFailTimeout = null;\n\n // Propagate onLoad event\n this.props.onLoad(cbObj);\n\n /**\n * Having seen that the securedFields iframes have loaded some kind of content (we don't know what, yet)\n * - setTimeout since we expect to get a successful configuration message \"within a reasonable time\"\n *\n * Now we catch clientKey & environment mismatch in core.ts - this timeout being called indicates that the securedFields have not all configured\n * - so we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n this.csfConfigFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfConfigFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured fields have failed to configure'));\n }\n }, this.csfConfigFailTimeoutMS);\n}\n\n/**\n * Emits the onConfigSuccess (ready) event\n * Here we can assume CSF is loaded, configured and ready to be used\n */\nfunction handleOnConfigSuccess(cbObj: CardConfigSuccessData): void {\n // Clear 'config' timeout\n clearTimeout(this.csfConfigFailTimeout);\n this.csfConfigFailTimeout = null;\n\n this.setState({ status: 'ready' }, () => {\n // Propagate onConfigSuccess event\n this.props.onConfigSuccess(cbObj);\n });\n}\n\n/**\n * Emits the onAllValid event\n */\nfunction handleOnAllValid(status: CardAllValidData): boolean {\n // Form cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands) {\n return false;\n }\n\n this.setState({ isSfpValid: status.allValid }, () => {\n // New - fixes maestro-with-error-on-optional-cvc-field bug\n this.props.onChange(this.state, { event: 'handleOnAllValid' });\n // Propagate onAllValid event\n this.props.onAllValid(status);\n });\n\n return true;\n}\n\n/**\n * Saves a field value from CSF in the CardInput state\n * Emits the onFieldValid event\n */\nfunction handleOnFieldValid(fieldObj: CardFieldValidData): boolean {\n // A card number field cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands && fieldObj.fieldType === ENCRYPTED_CARD_NUMBER) {\n return false;\n }\n\n const setValidFieldState = prevState => ({\n data: { ...prevState.data, [fieldObj.encryptedFieldName]: fieldObj.blob },\n valid: { ...prevState.valid, [fieldObj.encryptedFieldName]: fieldObj.valid },\n /**\n * For a field that has just received valid:true (field has just been completed & encrypted) - mark the error state for this field as false\n * For a field that has just received valid:false (field was encrypted, now is not)\n * - field is either in a state of being incomplete but without errors (digit deleted) - so mark the error state for this field as false\n * or has switched from valid/encrypted state to being in error (digit edited to one that puts the field in error) - so keep any error that\n * might just have been set\n */\n errors: { ...prevState.errors, [fieldObj.fieldType]: prevState.errors[fieldObj.fieldType] ?? null }\n });\n\n this.setState(setValidFieldState, () => {\n this.props.onChange(this.state, { event: 'handleOnFieldValid', fieldType: fieldObj.fieldType });\n\n // Propagate onFieldValid event\n this.props.onFieldValid(fieldObj);\n });\n\n return true;\n}\n\nfunction fieldIsInError(fieldType: string, policy: string, numCharsObj: object, errorsObj) {\n return (policy === OPTIONAL || policy === HIDDEN) && numCharsObj[fieldType] === 0 ? false : errorsObj[fieldType];\n}\n\n/**\n * Saves the card brand in state\n * Emits the onBrand event\n */\nfunction handleOnBrand(cardInfo: CardBrandData): void {\n this.setState(\n prevState => {\n /**\n * If we change brand to one where the cvc or date field(s) are not required & are empty - then these fields cannot be in error\n * (scenario: have validated empty form, then choose brand w. optional/hidden cvc or date)...\n * ...else propagate the existing error.\n */\n const cvcFieldInError = fieldIsInError(ENCRYPTED_SECURITY_CODE, cardInfo.cvcPolicy, this.numCharsInField, prevState.errors);\n\n const dateFieldInError =\n this.numDateFields === 1\n ? fieldIsInError(ENCRYPTED_EXPIRY_DATE, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n // For custom card comp\n const monthFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_MONTH, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n const yearFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_YEAR, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n // --\n /** end */\n\n return {\n brand: cardInfo.brand,\n cvcPolicy: cardInfo.cvcPolicy ?? CVC_POLICY_REQUIRED,\n showSocialSecurityNumber: cardInfo.showSocialSecurityNumber,\n errors: {\n ...prevState.errors,\n ...(existy(cvcFieldInError) && { [ENCRYPTED_SECURITY_CODE]: cvcFieldInError }),\n ...(existy(dateFieldInError) && { [ENCRYPTED_EXPIRY_DATE]: dateFieldInError }),\n ...(existy(monthFieldInError) && { [ENCRYPTED_EXPIRY_MONTH]: monthFieldInError }),\n ...(existy(yearFieldInError) && { [ENCRYPTED_EXPIRY_YEAR]: yearFieldInError })\n },\n expiryDatePolicy: cardInfo.expiryDatePolicy ?? DATE_POLICY_REQUIRED\n };\n },\n () => {\n this.props.onChange(this.state, { event: 'handleOnBrand' });\n\n // Enhance data object with the url for the brand image, first checking if the merchant has configured their own one for this brand\n const brandImageUrl = this.props.brandsConfiguration[cardInfo.brand]?.icon ?? getCardImageUrl(cardInfo.brand, this.props.resources);\n this.props.onBrand({ ...cardInfo, brandImageUrl });\n }\n );\n}\n\n/**\n * Handles validation errors\n */\nfunction handleOnError(cbObj: CardErrorData, hasUnsupportedCard: boolean = null): boolean {\n const errorCode = cbObj.error;\n\n this.setState(\n prevState => ({\n errors: { ...prevState.errors, [cbObj.fieldType]: errorCode || null },\n // If dealing with an unsupported card ensure these card number related fields are reset re. pasting a full, unsupported card straight in\n ...(hasUnsupportedCard && { data: { ...prevState.data, [ENCRYPTED_CARD_NUMBER]: undefined } }),\n ...(hasUnsupportedCard && { valid: { ...prevState.valid, [ENCRYPTED_CARD_NUMBER]: false } }),\n ...(hasUnsupportedCard && { isSfpValid: false })\n }),\n () => {\n this.props.onChange(this.state, { event: 'handleOnError', fieldType: cbObj.fieldType });\n }\n );\n\n return true;\n}\n\nfunction handleFocus(cbObj: CardFocusData): void {\n this.numCharsInField[cbObj.fieldType] = cbObj.numChars;\n\n this.props.onFocus(cbObj);\n}\n\nfunction handleOnTouchstartIOS(cbObj): void {\n // disableIOSArrowKeys is either null or a function (in which case we should call it)\n this.props.disableIOSArrowKeys?.(cbObj);\n}\n\n// Only called for holder name (from CSF>partials>processAutoComplete)\nfunction handleOnAutoComplete(cbObj: CardAutoCompleteData): void {\n this.setState({ autoCompleteName: cbObj.value }, () => {\n this.props.onChange(this.state, { event: 'handleOnAutoComplete', fieldType: cbObj.fieldType });\n this.setState({ autoCompleteName: null }); // Nullify ref after sending it (lets shopper edit holder name)\n });\n this.props.onAutoComplete(cbObj);\n}\n\nfunction handleKeyDown(obj: SFKeyDownObj): void {\n if (obj.action === 'enterKeyPressed') {\n const kb = new KeyboardEvent('keydown', {\n bubbles: true,\n cancelable: true,\n key: 'Enter',\n code: 'Enter'\n });\n this.props.handleKeyDown?.(kb);\n }\n}\n\n/**\n * Handles cases where no secured fields are necessary (one click payments without CVC)\n * Automatically resolves with a valid state\n */\nfunction handleOnNoDataRequired(): void {\n this.setState({ status: 'ready' }, () => this.props.onChange({ isSfpValid: true }));\n}\n\nexport default {\n handleFocus,\n handleOnAllValid,\n handleOnAutoComplete,\n handleOnFieldValid,\n handleOnLoad,\n handleOnConfigSuccess,\n handleOnBrand,\n handleOnError,\n handleOnNoDataRequired,\n handleOnTouchstartIOS,\n handleKeyDown\n};\n"],"names":["fieldIsInError","fieldType","policy","numCharsObj","errorsObj","OPTIONAL","HIDDEN","handlers","handleFocus","cbObj","this","numCharsInField","numChars","props","onFocus","handleOnAllValid","status","state","detectedUnsupportedBrands","setState","isSfpValid","allValid","onChange","event","onAllValid","handleOnAutoComplete","autoCompleteName","value","onAutoComplete","handleOnFieldValid","fieldObj","ENCRYPTED_CARD_NUMBER","prevState","data","encryptedFieldName","blob","valid","errors","onFieldValid","handleOnLoad","clearTimeout","csfLoadFailTimeout","onLoad","csfConfigFailTimeout","setTimeout","onError","AdyenCheckoutError","csfConfigFailTimeoutMS","handleOnConfigSuccess","onConfigSuccess","handleOnBrand","cardInfo","cvcFieldInError","ENCRYPTED_SECURITY_CODE","cvcPolicy","dateFieldInError","numDateFields","ENCRYPTED_EXPIRY_DATE","expiryDatePolicy","monthFieldInError","ENCRYPTED_EXPIRY_MONTH","yearFieldInError","ENCRYPTED_EXPIRY_YEAR","brand","CVC_POLICY_REQUIRED","showSocialSecurityNumber","existy","DATE_POLICY_REQUIRED","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","onBrand","handleOnError","hasUnsupportedCard","errorCode","error","undefined","handleOnNoDataRequired","handleOnTouchstartIOS","disableIOSArrowKeys","handleKeyDown","obj","action","kb","KeyboardEvent","bubbles","cancelable","key","code"],"mappings":"6ZA0HA,SAASA,EAAeC,EAAmBC,EAAgBC,EAAqBC,GAC5E,OAAQF,IAAWG,GAAYH,IAAWI,GAAsC,IAA3BH,EAAYF,KAA2BG,EAAUH,EAC1G,CAwHA,IAAAM,EAAe,CACXC,YAzCJ,SAAqBC,GACjBC,KAAKC,gBAAgBF,EAAMR,WAAaQ,EAAMG,SAE9CF,KAAKG,MAAMC,QAAQL,EACvB,EAsCIM,iBA7KJ,SAA0BC,GAEtB,OAAIN,KAAKO,MAAMC,4BAIfR,KAAKS,SAAS,CAAEC,WAAYJ,EAAOK,UAAY,KAE3CX,KAAKG,MAAMS,SAASZ,KAAKO,MAAO,CAAEM,MAAO,qBAEz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AAUI,MAAOL,CAACA,IAAwB,OAC9E4C,GAAsB,CAAEvD,YAAY,KAE5C,KACIV,KAAKG,MAAMS,SAASZ,KAAKO,MAAO,CAAEM,MAAO,gBAAiBtB,UAAWQ,EAAMR,eAI5E,CACX,EAmDI8E,uBAbJ,WACIrE,KAAKS,SAAS,CAAEH,OAAQ,SAAW,IAAMN,KAAKG,MAAMS,SAAS,CAAEF,YAAY,IAC/E,EAYI4D,sBA5CJ,SAA+BvE,GAE3BC,KAAKG,MAAMoE,sBAAsBxE,EACrC,EA0CIyE,cA/BJ,SAAuBC,GACnB,GAAmB,oBAAfA,EAAIC,OAA8B,CAClC,MAAMC,EAAK,IAAIC,cAAc,UAAW,CACpCC,SAAS,EACTC,YAAY,EACZC,IAAK,QACLC,KAAM,UAEVhF,KAAKG,MAAMqE,gBAAgBG,EAC/B,CACJ"}
@@ -1,2 +1,2 @@
1
- var o={type:"card",keypadFix:!0,rootNode:null,loadingContext:null,brands:[],showWarnings:!1,autoFocus:!0,trimTrailingSeparator:!0,onChange:()=>{},onLoad:()=>{},onConfigSuccess:()=>{},onAllValid:()=>{},onFieldValid:()=>{},onBrand:()=>{},onError:()=>{},onBinValue:()=>{},onFocus:()=>{},onAutoComplete:()=>{},handleKeyPress:()=>{},styles:{}};export{o as default};
1
+ var o={type:"card",keypadFix:!0,rootNode:null,loadingContext:null,brands:[],showWarnings:!1,autoFocus:!0,trimTrailingSeparator:!0,onChange:()=>{},onLoad:()=>{},onConfigSuccess:()=>{},onAllValid:()=>{},onFieldValid:()=>{},onBrand:()=>{},onError:()=>{},onBinValue:()=>{},onFocus:()=>{},onAutoComplete:()=>{},handleKeyDown:()=>{},styles:{}};export{o as default};
2
2
  //# sourceMappingURL=defaultProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultProps.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/defaultProps.ts"],"sourcesContent":["export default {\n type: 'card',\n\n // Settings\n keypadFix: true,\n rootNode: null,\n loadingContext: null,\n brands: [],\n showWarnings: false,\n autoFocus: true,\n trimTrailingSeparator: true,\n\n // Events\n onChange: () => {},\n onLoad: () => {},\n onConfigSuccess: () => {},\n onAllValid: () => {},\n onFieldValid: () => {},\n onBrand: () => {},\n onError: () => {},\n onBinValue: () => {},\n onFocus: () => {},\n onAutoComplete: () => {},\n handleKeyPress: () => {},\n\n // Customization\n styles: {}\n};\n"],"names":["defaultProps","type","keypadFix","rootNode","loadingContext","brands","showWarnings","autoFocus","trimTrailingSeparator","onChange","onLoad","onConfigSuccess","onAllValid","onFieldValid","onBrand","onError","onBinValue","onFocus","onAutoComplete","handleKeyPress","styles"],"mappings":"AAAA,IAAAA,EAAe,CACXC,KAAM,OAGNC,WAAW,EACXC,SAAU,KACVC,eAAgB,KAChBC,OAAQ,GACRC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAGvBC,SAAU,OACVC,OAAQ,OACRC,gBAAiB,OACjBC,WAAY,OACZC,aAAc,OACdC,QAAS,OACTC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,eAAgB,OAChBC,eAAgB,OAGhBC,OAAQ,CAAA"}
1
+ {"version":3,"file":"defaultProps.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/defaultProps.ts"],"sourcesContent":["export default {\n type: 'card',\n\n // Settings\n keypadFix: true,\n rootNode: null,\n loadingContext: null,\n brands: [],\n showWarnings: false,\n autoFocus: true,\n trimTrailingSeparator: true,\n\n // Events\n onChange: () => {},\n onLoad: () => {},\n onConfigSuccess: () => {},\n onAllValid: () => {},\n onFieldValid: () => {},\n onBrand: () => {},\n onError: () => {},\n onBinValue: () => {},\n onFocus: () => {},\n onAutoComplete: () => {},\n handleKeyDown: () => {},\n\n // Customization\n styles: {}\n};\n"],"names":["defaultProps","type","keypadFix","rootNode","loadingContext","brands","showWarnings","autoFocus","trimTrailingSeparator","onChange","onLoad","onConfigSuccess","onAllValid","onFieldValid","onBrand","onError","onBinValue","onFocus","onAutoComplete","handleKeyDown","styles"],"mappings":"AAAA,IAAAA,EAAe,CACXC,KAAM,OAGNC,WAAW,EACXC,SAAU,KACVC,eAAgB,KAChBC,OAAQ,GACRC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAGvBC,SAAU,OACVC,OAAQ,OACRC,gBAAiB,OACjBC,WAAY,OACZC,aAAc,OACdC,QAAS,OACTC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,eAAgB,OAChBC,cAAe,OAGfC,OAAQ,CAAA"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../../../../core/Services/http.js";import{DEFAULT_CARD_GROUP_TYPES as r}from"../lib/constants.js";import{SF_ErrorCodes as n}from"../../../../core/Errors/constants.js";var s=s=>{let o=null;return t=>{if(!1!==s.props.doBinLookup){if(t.encryptedBin&&s.props.clientKey)o=t.uuid,e({loadingContext:s.props.loadingContext,path:`v3/bin/binLookup?token=${s.props.clientKey}`},{type:s.props.brand,supportedBrands:s.props.brands||r,encryptedBin:t.encryptedBin,requestId:t.uuid}).then(e=>{if(e?.requestId===o)if(e.brands?.length){const o=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(o.supportedBrands.length)return s.processBinLookupResponse({issuingCountryCode:e.issuingCountryCode,supportedBrands:o.supportedBrands,...e.showSocialSecurityNumber?{showSocialSecurityNumber:e.showSocialSecurityNumber}:{}}),void s.onBinLookup({type:t.type,detectedBrands:o.detectedBrands,supportedBrands:o.supportedBrands.map(e=>e.brand),paymentMethodVariants:o.paymentMethodVariants,supportedBrandsRaw:o.supportedBrands,brands:s.props.brands||r,issuingCountryCode:e.issuingCountryCode});if(o.detectedBrands.length){const e={type:"card",fieldType:"encryptedCardNumber",error:n.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,detectedBrands:o.detectedBrands};return s.handleUnsupportedCard(e),void s.onBinLookup({type:t.type,detectedBrands:o.detectedBrands,supportedBrands:null,paymentMethodVariants:o.paymentMethodVariants,brands:s.props.brands||r})}}else s.onBinLookup({type:t.type,detectedBrands:null,supportedBrands:null,brands:s.props.brands||r}),s.processBinLookupResponse({},!0);else e?.requestId||s.props.onError(e||{errorType:"binLookup",message:"unknownError"})});else if(o){s.processBinLookupResponse(null,!0),o=null;const e={type:"card",fieldType:"encryptedCardNumber",error:""};s.handleUnsupportedCard(e),s.onBinLookup({isReset:!0})}s.props.onBinValue&&s.props.onBinValue(t)}else s.props.onBinValue&&s.props.onBinValue(t)}};export{s as default};
1
+ import{httpPost as e}from"../../../../core/Services/http.js";import{DEFAULT_CARD_GROUP_TYPES as r}from"../lib/constants.js";import{SF_ErrorCodes as n}from"../../../../core/Errors/constants.js";var t=t=>{let s=null;return o=>{if(!1!==t.props.doBinLookup){if(o.encryptedBin&&t.props.clientKey)s=o.uuid,e({loadingContext:t.props.loadingContext,path:`v3/bin/binLookup?token=${t.props.clientKey}`},{type:t.props.brand,supportedBrands:t.props.brands||r,encryptedBin:o.encryptedBin,requestId:o.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),void 0!==r.healthcare&&e.healthcare.push({[r.brand]:r.healthcare}),!0===r.supported?(e.supportedBrands.push(r),e):e),{supportedBrands:[],detectedBrands:[],paymentMethodVariants:[],healthcare:[]}),d=s.healthcare.length>0;if(s.supportedBrands.length)return t.processBinLookupResponse({issuingCountryCode:e.issuingCountryCode,supportedBrands:s.supportedBrands,...e.showSocialSecurityNumber?{showSocialSecurityNumber:e.showSocialSecurityNumber}:{}}),void t.onBinLookup({type:o.type,detectedBrands:s.detectedBrands,supportedBrands:s.supportedBrands.map(e=>e.brand),paymentMethodVariants:s.paymentMethodVariants,supportedBrandsRaw:s.supportedBrands,brands:t.props.brands||r,issuingCountryCode:e.issuingCountryCode,...d&&{healthcare:s.healthcare}});if(s.detectedBrands.length){const e={type:"card",fieldType:"encryptedCardNumber",error:n.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,detectedBrands:s.detectedBrands};return t.handleUnsupportedCard(e),void t.onBinLookup({type:o.type,detectedBrands:s.detectedBrands,supportedBrands:null,paymentMethodVariants:s.paymentMethodVariants,...d&&{healthcare:s.healthcare},brands:t.props.brands||r})}}else t.onBinLookup({type:o.type,detectedBrands:null,supportedBrands:null,brands:t.props.brands||r}),t.processBinLookupResponse({},!0);else e?.requestId||t.props.onError(e||{errorType:"binLookup",message:"unknownError"})});else if(s){t.processBinLookupResponse(null,!0),s=null;const e={type:"card",fieldType:"encryptedCardNumber",error:""};t.handleUnsupportedCard(e),t.onBinLookup({isReset:!0})}t.props.onBinValue&&t.props.onBinValue(o)}else t.props.onBinValue&&t.props.onBinValue(o)}};export{t 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 { CardBinValueData, CardErrorData } from '../lib/types';\nimport { DEFAULT_CARD_GROUP_TYPES } from '../lib/constants';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { BinLookupResponseRaw } from '../../../Card/types';\n\nif (process.env.NODE_ENV === 'development') {\n window.mockBinCount = 0; // Set to 0 to turn off mocking, 1 to turn it on\n}\n\nexport default parent => {\n let currentRequestId = null;\n\n return (callbackObj: CardBinValueData) => {\n // Allow way for merchant to disallow binLookup by specifically setting the prop to false\n if (parent.props.doBinLookup === false) {\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n return;\n }\n\n // Do binLookup when encryptedBin property is present (and only if the merchant is using a clientKey)\n if (callbackObj.encryptedBin && parent.props.clientKey) {\n // Store id of request we're about to make\n currentRequestId = callbackObj.uuid;\n\n void httpPost(\n {\n loadingContext: parent.props.loadingContext,\n path: `v3/bin/binLookup?token=${parent.props.clientKey}`\n },\n {\n type: parent.props.brand,\n supportedBrands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,\n encryptedBin: callbackObj.encryptedBin,\n requestId: callbackObj.uuid // Pass id of request\n }\n ).then((data: BinLookupResponseRaw) => {\n // If response is the one we were waiting for...\n if (data?.requestId === currentRequestId) {\n if (process.env.NODE_ENV === 'development') {\n // TODO mocking\n if (window.mockBinCount >= 1) {\n switch (window.mockBinCount) {\n case 1:\n console.log('\\n### triggerBinLookUp::mock first response:: ');\n data.brands = [\n {\n brand: 'mc',\n cvcPolicy: 'optional',\n enableLuhnCheck: true,\n // showExpiryDate: true, // deprecated in /binLookup v3\n expiryDatePolicy: 'optional',\n // panLength: 16,\n supported: true\n }\n ];\n // data.issuingCountryCode = 'KR'; // needed to mock korean_local_card\n // increment to alter second response\n window.mockBinCount++;\n\n break;\n case 2:\n console.log('\\n### triggerBinLookUp::mock second response:: ');\n // data.brands = null;\n data.brands = [\n {\n brand: 'maestro',\n cvcPolicy: 'required',\n enableLuhnCheck: true,\n showExpiryDate: true,\n supported: true,\n showSocialSecurityNumber: false\n // panLength: 16\n }\n ];\n break;\n default:\n }\n }\n // TODO end\n }\n\n if (data.brands?.length) {\n const mappedResponse = data.brands.reduce(\n (acc, item) => {\n // All brand strings end up in the detectedBrands array\n acc.detectedBrands.push(item.brand);\n // Also add the paymentMethodVariants (more granular description of the txvariant)\n acc.paymentMethodVariants.push(item.paymentMethodVariant);\n\n // Add supported brand objects to the supportedBrands array\n if (item.supported === true) {\n acc.supportedBrands.push(item);\n return acc;\n }\n\n return acc;\n },\n { supportedBrands: [], detectedBrands: [], paymentMethodVariants: [] }\n );\n\n /**\n * supportedBrands = merchant supports this brand(s); we have detected the card number to be of this brand(s); carry on!\n */\n if (mappedResponse.supportedBrands.length) {\n // ...call processBinLookupResponse with, a simplified, response object if it contains at least one supported brand\n parent.processBinLookupResponse({\n issuingCountryCode: data.issuingCountryCode,\n supportedBrands: mappedResponse.supportedBrands,\n ...(data.showSocialSecurityNumber ? { showSocialSecurityNumber: data.showSocialSecurityNumber } : {})\n });\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 });\n\n return;\n }\n\n /**\n * detectedBrands = no brands the merchant supports were found; what we did detect the shopper to be entering was this brand;\n * error!\n */\n if (mappedResponse.detectedBrands.length) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n detectedBrands: mappedResponse.detectedBrands\n };\n parent.handleUnsupportedCard(errObj);\n\n // Inform merchant of the result\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: mappedResponse.detectedBrands,\n supportedBrands: null,\n paymentMethodVariants: mappedResponse.paymentMethodVariants,\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n });\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 brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n });\n\n // Reset the UI and let the native, regex branding happen (for the generic card)\n // For a single-branded card we need to pass a boolean to prompt resetting the brand logo to the 'base' type\n parent.processBinLookupResponse({}, true);\n }\n } else {\n if (!data?.requestId) {\n // Some other kind of error on the backend\n parent.props.onError(data || { errorType: 'binLookup', message: 'unknownError' });\n }\n // Else - response with wrong requestId\n }\n });\n } else if (currentRequestId) {\n /**\n * If onBinValue callback is called AND we have been doing binLookup BUT passed object doesn't have an encryptedBin property\n * - then THE NUMBER OF DIGITS IN NUMBER FIELD HAS DROPPED BELOW THRESHOLD for BIN lookup - so reset the UI\n */\n parent.processBinLookupResponse(null, true);\n\n currentRequestId = null; // Ignore any pending responses\n\n // Reset any errors\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n parent.handleUnsupportedCard(errObj);\n\n // CustomCard needs this to reset the UI\n parent.onBinLookup({\n isReset: true\n });\n }\n\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n };\n};\n"],"names":["triggerBinLookUp","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":"iMAUA,IAAAA,EAAeC,IACX,IAAIC,EAAmB,KAEvB,OAAQC,IAEJ,IAAiC,IAA7BF,EAAOG,MAAMC,YAAjB,CAMA,GAAIF,EAAYG,cAAgBL,EAAOG,MAAMG,UAEzCL,EAAmBC,EAAYK,KAE1BC,EACD,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,KAAMC,IAEJ,GAAIA,GAAMF,YAAcf,EA4CpB,GAAIiB,EAAKJ,QAAQK,OAAQ,CACrB,MAAMC,EAAiBF,EAAKJ,OAAOO,OAC/B,CAACC,EAA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MAAM,GAEtC5B,EAAmB,KAGnB,MAAMkC,EAAwB,CAC1BxB,KAAM,OACNyB,UAAW,sBACXC,MAAO,IAEXrC,EAAOwC,sBAAsBL,GAG7BnC,EAAOgC,YAAY,CACfY,SAAS,GAEjB,CAEI5C,EAAOG,MAAM0C,YAAY7C,EAAOG,MAAM0C,WAAW3C,EAnLrD,MAFQF,EAAOG,MAAM0C,YAAY7C,EAAOG,MAAM0C,WAAW3C,GAuLjE"}
1
+ {"version":3,"file":"triggerBinLookUp.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/triggerBinLookUp.ts"],"sourcesContent":["import { httpPost } from '../../../../core/Services/http';\nimport { CardBinValueData, CardErrorData } from '../lib/types';\nimport { DEFAULT_CARD_GROUP_TYPES } from '../lib/constants';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { BinLookupResponseRaw, BrandObject } 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: string | null = null;\n\n return (callbackObj: CardBinValueData) => {\n // Allow way for merchant to disallow binLookup by specifically setting the prop to false\n if (parent.props.doBinLookup === false) {\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n return;\n }\n\n // Do binLookup when encryptedBin property is present (and only if the merchant is using a clientKey)\n if (callbackObj.encryptedBin && parent.props.clientKey) {\n // Store id of request we're about to make\n currentRequestId = callbackObj.uuid;\n\n void httpPost(\n {\n loadingContext: parent.props.loadingContext,\n path: `v3/bin/binLookup?token=${parent.props.clientKey}`\n },\n {\n type: parent.props.brand,\n supportedBrands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,\n encryptedBin: callbackObj.encryptedBin,\n requestId: callbackObj.uuid // Pass id of request\n }\n ).then((data: BinLookupResponseRaw) => {\n // If response is the one we were waiting for...\n if (data?.requestId === currentRequestId) {\n if (process.env.NODE_ENV === 'development') {\n // TODO mocking\n if (window.mockBinCount >= 1) {\n switch (window.mockBinCount) {\n case 1:\n console.log('\\n### triggerBinLookUp::mock first response:: ');\n data.brands = [\n {\n brand: 'mc',\n cvcPolicy: 'optional',\n enableLuhnCheck: true,\n // showExpiryDate: true, // deprecated in /binLookup v3\n expiryDatePolicy: 'optional',\n // panLength: 16,\n supported: true,\n healthcare: 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 healthcare: 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 // Add healthcare to the healthcare array, keyed by brand (only when the field is present)\n if (item.healthcare !== undefined) {\n acc.healthcare.push({ [item.brand]: item.healthcare });\n }\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 {\n supportedBrands: [] as BrandObject[],\n detectedBrands: [] as string[],\n paymentMethodVariants: [] as (string | undefined)[],\n healthcare: [] as Record<string, boolean>[]\n }\n );\n\n const hasHealthcareData = mappedResponse.healthcare.length > 0;\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 });\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 ...(hasHealthcareData && { healthcare: mappedResponse.healthcare })\n });\n\n return;\n }\n\n /**\n * detectedBrands = no brands the merchant supports were found; what we did detect the shopper to be entering was this brand;\n * error!\n */\n if (mappedResponse.detectedBrands.length) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n detectedBrands: mappedResponse.detectedBrands\n };\n parent.handleUnsupportedCard(errObj);\n\n // Inform merchant of the result\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: mappedResponse.detectedBrands,\n supportedBrands: null,\n paymentMethodVariants: mappedResponse.paymentMethodVariants,\n ...(hasHealthcareData && { healthcare: mappedResponse.healthcare }),\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n });\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 brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n });\n\n // Reset the UI and let the native, regex branding happen (for the generic card)\n // For a single-branded card we need to pass a boolean to prompt resetting the brand logo to the 'base' type\n parent.processBinLookupResponse({}, true);\n }\n } else {\n if (!data?.requestId) {\n // Some other kind of error on the backend\n parent.props.onError(data || { errorType: 'binLookup', message: 'unknownError' });\n }\n // Else - response with wrong requestId\n }\n });\n } else if (currentRequestId) {\n /**\n * If onBinValue callback is called AND we have been doing binLookup BUT passed object doesn't have an encryptedBin property\n * - then THE NUMBER OF DIGITS IN NUMBER FIELD HAS DROPPED BELOW THRESHOLD for BIN lookup - so reset the UI\n */\n parent.processBinLookupResponse(null, true);\n\n currentRequestId = null; // Ignore any pending responses\n\n // Reset any errors\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n parent.handleUnsupportedCard(errObj);\n\n // CustomCard needs this to reset the UI\n parent.onBinLookup({\n isReset: true\n });\n }\n\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n };\n};\n"],"names":["triggerBinLookUp","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","undefined","healthcare","supported","hasHealthcareData","processBinLookupResponse","issuingCountryCode","showSocialSecurityNumber","onBinLookup","map","supportedBrandsRaw","errObj","fieldType","error","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","handleUnsupportedCard","onError","errorType","message","isReset","onBinValue"],"mappings":"iMAUA,IAAAA,EAAeC,IACX,IAAIC,EAAkC,KAEtC,OAAQC,IAEJ,IAAiC,IAA7BF,EAAOG,MAAMC,YAAjB,CAMA,GAAIF,EAAYG,cAAgBL,EAAOG,MAAMG,UAEzCL,EAAmBC,EAAYK,KAE1BC,EACD,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,KAAMC,IAEJ,GAAIA,GAAMF,YAAcf,EA8CpB,GAAIiB,EAAKJ,QAAQK,OAAQ,CACrB,MAAMC,EA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,EAAYS,KAClBa,eAAgB,KAChBX,gBAAiB,KACjBC,OAAQd,EAAOG,MAAMW,QAAUC,IAKnCf,EAAOgC,yBAAyB,CAAA,GAAI,QAGnCd,GAAMF,WAEPhB,EAAOG,MAAMyC,QAAQ1B,GAAQ,CAAE2B,UAAW,YAAaC,QAAS,wBAKzE,GAAI7C,EAAkB,CAKzBD,EAAOgC,yBAAyB,MAAM,GAEtC/B,EAAmB,KAGnB,MAAMqC,EAAwB,CAC1B3B,KAAM,OACN4B,UAAW,sBACXC,MAAO,IAEXxC,EAAO2C,sBAAsBL,GAG7BtC,EAAOmC,YAAY,CACfY,SAAS,GAEjB,CAEI/C,EAAOG,MAAM6C,YAAYhD,EAAOG,MAAM6C,WAAW9C,EAlMrD,MAFQF,EAAOG,MAAM6C,YAAYhD,EAAOG,MAAM6C,WAAW9C,GAsMjE"}
@@ -1,2 +1,2 @@
1
- const o=()=>{};function n(n={}){this.callbacks.onLoad=n.onLoad?n.onLoad:o,this.callbacks.onConfigSuccess=n.onConfigSuccess?n.onConfigSuccess:o,this.callbacks.onFieldValid=n.onFieldValid?n.onFieldValid:o,this.callbacks.onAllValid=n.onAllValid?n.onAllValid:o,this.callbacks.onBrand=n.onBrand?n.onBrand:o,this.callbacks.onError=n.onError?n.onError:o,this.callbacks.onFocus=n.onFocus?n.onFocus:o,this.callbacks.onBinValue=n.onBinValue?n.onBinValue:o,this.callbacks.onAutoComplete=n.onAutoComplete?n.onAutoComplete:o,this.callbacks.onAdditionalSFConfig=n.onAdditionalSFConfig?n.onAdditionalSFConfig:o,this.callbacks.onAdditionalSFRemoved=n.onAdditionalSFRemoved?n.onAdditionalSFRemoved:o,this.callbacks.onTouchstartIOS=n.onTouchstartIOS?n.onTouchstartIOS:o,this.callbacks.onKeyPressed=n.onKeyPressed?n.onKeyPressed:o}export{n as configureCallbacks};
1
+ const o=()=>{};function n(n={}){this.callbacks.onLoad=n.onLoad?n.onLoad:o,this.callbacks.onConfigSuccess=n.onConfigSuccess?n.onConfigSuccess:o,this.callbacks.onFieldValid=n.onFieldValid?n.onFieldValid:o,this.callbacks.onAllValid=n.onAllValid?n.onAllValid:o,this.callbacks.onBrand=n.onBrand?n.onBrand:o,this.callbacks.onError=n.onError?n.onError:o,this.callbacks.onFocus=n.onFocus?n.onFocus:o,this.callbacks.onBinValue=n.onBinValue?n.onBinValue:o,this.callbacks.onAutoComplete=n.onAutoComplete?n.onAutoComplete:o,this.callbacks.onAdditionalSFConfig=n.onAdditionalSFConfig?n.onAdditionalSFConfig:o,this.callbacks.onAdditionalSFRemoved=n.onAdditionalSFRemoved?n.onAdditionalSFRemoved:o,this.callbacks.onTouchstartIOS=n.onTouchstartIOS?n.onTouchstartIOS:o,this.callbacks.onKeyDown=n.onKeyDown?n.onKeyDown:o}export{n as configureCallbacks};
2
2
  //# sourceMappingURL=configureCallbacks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configureCallbacks.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.ts"],"sourcesContent":["import { CSFCallbacksConfig } from '../types';\n\nconst noop = () => {};\n\nexport function configureCallbacks(callbacksObj: Partial<CSFCallbacksConfig> = {}): void {\n // --\n this.callbacks.onLoad = callbacksObj.onLoad ? callbacksObj.onLoad : noop;\n\n this.callbacks.onConfigSuccess = callbacksObj.onConfigSuccess ? callbacksObj.onConfigSuccess : noop;\n\n this.callbacks.onFieldValid = callbacksObj.onFieldValid ? callbacksObj.onFieldValid : noop;\n\n this.callbacks.onAllValid = callbacksObj.onAllValid ? callbacksObj.onAllValid : noop;\n\n this.callbacks.onBrand = callbacksObj.onBrand ? callbacksObj.onBrand : noop;\n\n this.callbacks.onError = callbacksObj.onError ? callbacksObj.onError : noop;\n\n this.callbacks.onFocus = callbacksObj.onFocus ? callbacksObj.onFocus : noop;\n\n this.callbacks.onBinValue = callbacksObj.onBinValue ? callbacksObj.onBinValue : noop;\n\n this.callbacks.onAutoComplete = callbacksObj.onAutoComplete ? callbacksObj.onAutoComplete : noop;\n\n this.callbacks.onAdditionalSFConfig = callbacksObj.onAdditionalSFConfig ? callbacksObj.onAdditionalSFConfig : noop;\n\n this.callbacks.onAdditionalSFRemoved = callbacksObj.onAdditionalSFRemoved ? callbacksObj.onAdditionalSFRemoved : noop;\n\n this.callbacks.onTouchstartIOS = callbacksObj.onTouchstartIOS ? callbacksObj.onTouchstartIOS : noop;\n\n this.callbacks.onKeyPressed = callbacksObj.onKeyPressed ? callbacksObj.onKeyPressed : noop;\n}\n"],"names":["noop","configureCallbacks","callbacksObj","this","callbacks","onLoad","onConfigSuccess","onFieldValid","onAllValid","onBrand","onError","onFocus","onBinValue","onAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","onKeyPressed"],"mappings":"AAEA,MAAMA,EAAO,OAEN,SAASC,EAAmBC,EAA4C,IAE3EC,KAAKC,UAAUC,OAASH,EAAaG,OAASH,EAAaG,OAASL,EAEpEG,KAAKC,UAAUE,gBAAkBJ,EAAaI,gBAAkBJ,EAAaI,gBAAkBN,EAE/FG,KAAKC,UAAUG,aAAeL,EAAaK,aAAeL,EAAaK,aAAeP,EAEtFG,KAAKC,UAAUI,WAAaN,EAAaM,WAAaN,EAAaM,WAAaR,EAEhFG,KAAKC,UAAUK,QAAUP,EAAaO,QAAUP,EAAaO,QAAUT,EAEvEG,KAAKC,UAAUM,QAAUR,EAAaQ,QAAUR,EAAaQ,QAAUV,EAEvEG,KAAKC,UAAUO,QAAUT,EAAaS,QAAUT,EAAaS,QAAUX,EAEvEG,KAAKC,UAAUQ,WAAaV,EAAaU,WAAaV,EAAaU,WAAaZ,EAEhFG,KAAKC,UAAUS,eAAiBX,EAAaW,eAAiBX,EAAaW,eAAiBb,EAE5FG,KAAKC,UAAUU,qBAAuBZ,EAAaY,qBAAuBZ,EAAaY,qBAAuBd,EAE9GG,KAAKC,UAAUW,sBAAwBb,EAAaa,sBAAwBb,EAAaa,sBAAwBf,EAEjHG,KAAKC,UAAUY,gBAAkBd,EAAac,gBAAkBd,EAAac,gBAAkBhB,EAE/FG,KAAKC,UAAUa,aAAef,EAAae,aAAef,EAAae,aAAejB,CAC1F"}
1
+ {"version":3,"file":"configureCallbacks.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.ts"],"sourcesContent":["import { CSFCallbacksConfig } from '../types';\n\nconst noop = () => {};\n\nexport function configureCallbacks(callbacksObj: Partial<CSFCallbacksConfig> = {}): void {\n // --\n this.callbacks.onLoad = callbacksObj.onLoad ? callbacksObj.onLoad : noop;\n\n this.callbacks.onConfigSuccess = callbacksObj.onConfigSuccess ? callbacksObj.onConfigSuccess : noop;\n\n this.callbacks.onFieldValid = callbacksObj.onFieldValid ? callbacksObj.onFieldValid : noop;\n\n this.callbacks.onAllValid = callbacksObj.onAllValid ? callbacksObj.onAllValid : noop;\n\n this.callbacks.onBrand = callbacksObj.onBrand ? callbacksObj.onBrand : noop;\n\n this.callbacks.onError = callbacksObj.onError ? callbacksObj.onError : noop;\n\n this.callbacks.onFocus = callbacksObj.onFocus ? callbacksObj.onFocus : noop;\n\n this.callbacks.onBinValue = callbacksObj.onBinValue ? callbacksObj.onBinValue : noop;\n\n this.callbacks.onAutoComplete = callbacksObj.onAutoComplete ? callbacksObj.onAutoComplete : noop;\n\n this.callbacks.onAdditionalSFConfig = callbacksObj.onAdditionalSFConfig ? callbacksObj.onAdditionalSFConfig : noop;\n\n this.callbacks.onAdditionalSFRemoved = callbacksObj.onAdditionalSFRemoved ? callbacksObj.onAdditionalSFRemoved : noop;\n\n this.callbacks.onTouchstartIOS = callbacksObj.onTouchstartIOS ? callbacksObj.onTouchstartIOS : noop;\n\n this.callbacks.onKeyDown = callbacksObj.onKeyDown ? callbacksObj.onKeyDown : noop;\n}\n"],"names":["noop","configureCallbacks","callbacksObj","this","callbacks","onLoad","onConfigSuccess","onFieldValid","onAllValid","onBrand","onError","onFocus","onBinValue","onAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","onKeyDown"],"mappings":"AAEA,MAAMA,EAAO,OAEN,SAASC,EAAmBC,EAA4C,IAE3EC,KAAKC,UAAUC,OAASH,EAAaG,OAASH,EAAaG,OAASL,EAEpEG,KAAKC,UAAUE,gBAAkBJ,EAAaI,gBAAkBJ,EAAaI,gBAAkBN,EAE/FG,KAAKC,UAAUG,aAAeL,EAAaK,aAAeL,EAAaK,aAAeP,EAEtFG,KAAKC,UAAUI,WAAaN,EAAaM,WAAaN,EAAaM,WAAaR,EAEhFG,KAAKC,UAAUK,QAAUP,EAAaO,QAAUP,EAAaO,QAAUT,EAEvEG,KAAKC,UAAUM,QAAUR,EAAaQ,QAAUR,EAAaQ,QAAUV,EAEvEG,KAAKC,UAAUO,QAAUT,EAAaS,QAAUT,EAAaS,QAAUX,EAEvEG,KAAKC,UAAUQ,WAAaV,EAAaU,WAAaV,EAAaU,WAAaZ,EAEhFG,KAAKC,UAAUS,eAAiBX,EAAaW,eAAiBX,EAAaW,eAAiBb,EAE5FG,KAAKC,UAAUU,qBAAuBZ,EAAaY,qBAAuBZ,EAAaY,qBAAuBd,EAE9GG,KAAKC,UAAUW,sBAAwBb,EAAaa,sBAAwBb,EAAaa,sBAAwBf,EAEjHG,KAAKC,UAAUY,gBAAkBd,EAAac,gBAAkBd,EAAac,gBAAkBhB,EAE/FG,KAAKC,UAAUa,UAAYf,EAAae,UAAYf,EAAae,UAAYjB,CACjF"}
@@ -1,2 +1,2 @@
1
- import{select as e,getAttribute as t}from"../../utilities/dom.js";import{DATA_ENCRYPTED_FIELD_ATTR as i,CVC_POLICY_REQUIRED as s,DATE_POLICY_REQUIRED as o,ENCRYPTED_EXPIRY_YEAR as n,SF_CONFIG_TIMEOUT as r,DATA_UID as a,DATA_INFO as d}from"../../constants.js";import{existy as l}from"../../../../../../utils/commonUtils.js";import c from"../utils/cardType.js";import h from"../../securedField/SecuredField.js";import p from"../../../../../../core/Errors/AdyenCheckoutError.js";import{isSecuredField as u}from"../../../utils.js";function f(){this.encryptedAttrName=i;const n=e(this.props.rootNode,`[${this.encryptedAttrName}]`).filter(e=>{const i=t(e,this.encryptedAttrName),s=u(i);return s||console.warn(`WARNING: '${i}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`),s}),r=s,a=o;return this.config.isCreditCardType?(this.isSingleBrandedCard=!1,this.securityCode="",this.createCardSecuredFields(n,r,a),n.length):(this.createNonCardSecuredFields(n),n.length)}async function m(e){for(let t=0;t<e.length;t++){const i=e[t];await this.setupSecuredField(i).catch(e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)})}}async function y(e,t,i){let n=this.state.type;if("card"===n&&1===this.config.cardGroupTypes.length&&(n=this.config.cardGroupTypes[0],this.state.type=n),this.isSingleBrandedCard="card"!==n,this.isSingleBrandedCard){const e=c.getCardByBrand(n);l(e)?(t=e.cvcPolicy||s,i=e.expiryDatePolicy||o,this.securityCode=e.securityCode):this.state.type="unrecognised-single-brand"}for(let s=0;s<e.length;s++){const o=e[s];window._b$dl&&console.log("\nAbout to set up securedField:",o),await this.setupSecuredField(o,t,i).catch(e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)}),window._b$dl&&console.log("Finished setting up securedField:",o)}if(window._b$dl&&console.log("Finished setting up all securedFields"),this.isSingleBrandedCard){const e={type:this.state.type,rootNode:this.props.rootNode,brand:n,cvcPolicy:t,expiryDatePolicy:i,cvcText:this.securityCode};setTimeout(()=>{this.callbacks.onBrand(e)},0)}}function g(e,i,s){return new Promise((o,l)=>{const c=t(e,this.encryptedAttrName);c===n&&(this.state.hasSeparateDateFields=!0);const u={fieldType:c,extraFieldData:t(e,d),uid:t(e,a),cvcPolicy:i,holderEl:e,expiryDatePolicy:s,txVariant:this.state.type,cardGroupTypes:this.config.cardGroupTypes,iframeUIConfig:this.config.iframeUIConfig,sfLogAtStart:this.config.sfLogAtStart,trimTrailingSeparator:this.config.trimTrailingSeparator,isCreditCardType:this.config.isCreditCardType,iframeSrc:this.config.iframeSrc,loadingContext:this.config.loadingContext,showWarnings:this.config.showWarnings,legacyInputMode:this.config.legacyInputMode,minimumExpiryDate:this.config.minimumExpiryDate,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,disableIOSArrowKeys:this.props.shouldDisableIOSArrowKeys,implementationType:this.props.implementationType,showContextualElement:this.props.showContextualElement,placeholders:this.props.placeholders,submitAnalytics:this.props.onSubmitAnalytics,componentType:this.props.componentType},f=new h(u,this.props.i18n).onIframeLoaded(()=>{if(this.state.iframeCount+=1,window._b$dl&&console.log("### createSecuredFields::onIframeLoaded:: this.state.iframeCount=",this.state.iframeCount),this.state.iframeCount>this.state.numIframes)throw this.destroySecuredFields(),new p("ERROR",`One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`);if(f.loadToConfigTimeout=setTimeout(()=>{l({type:u.fieldType,failReason:"sf took too long to config"})},r),this.state.iframeCount===this.state.originalNumIframes){const e={iframesLoaded:!0};this.callbacks.onLoad(e)}}).onConfig(e=>{this.handleIframeConfigFeedback(e),clearTimeout(f.loadToConfigTimeout),f.loadToConfigTimeout=null,o(e)}).onFocus(e=>{this.handleFocus(e)}).onBinValue(e=>{this.handleBinValue(e)}).onTouchstart(e=>{this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents||e.hasGenuineTouchEvents)&&this.callbacks.onTouchstartIOS({fieldType:e.fieldType}),(e.hasGenuineTouchEvents||this.hasGenuineTouchEvents)&&this.postMessageToAllIframes({fieldType:e.fieldType,fieldClick:!0})}).onShiftTab(e=>{this.handleSFShiftTab(e.fieldType)}).onEncryption(e=>{this.handleEncryption(e)}).onValidation(e=>{this.handleValidation(e)}).onAutoComplete(e=>{this.processAutoComplete(e)}).onKeyPressed(e=>{const{numKey:t,...i}=e;this.callbacks.onKeyPressed(i)});this.state.securedFields[c]=f})}export{y as createCardSecuredFields,m as createNonCardSecuredFields,f as createSecuredFields,g as setupSecuredField};
1
+ import{select as e,getAttribute as t}from"../../utilities/dom.js";import{DATA_ENCRYPTED_FIELD_ATTR as i,CVC_POLICY_REQUIRED as o,DATE_POLICY_REQUIRED as s,ENCRYPTED_EXPIRY_YEAR as n,SF_CONFIG_TIMEOUT as r,DATA_UID as a,DATA_INFO as d}from"../../constants.js";import{existy as l}from"../../../../../../utils/commonUtils.js";import c from"../utils/cardType.js";import h from"../../securedField/SecuredField.js";import p from"../../../../../../core/Errors/AdyenCheckoutError.js";import{isSecuredField as u}from"../../../utils.js";function f(){this.encryptedAttrName=i;const n=e(this.props.rootNode,`[${this.encryptedAttrName}]`).filter(e=>{const i=t(e,this.encryptedAttrName),o=u(i);return o||console.warn(`WARNING: '${i}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`),o}),r=o,a=s;return this.config.isCreditCardType?(this.isSingleBrandedCard=!1,this.securityCode="",this.createCardSecuredFields(n,r,a),n.length):(this.createNonCardSecuredFields(n),n.length)}async function m(e){for(let t=0;t<e.length;t++){const i=e[t];await this.setupSecuredField(i).catch(e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)})}}async function y(e,t,i){let n=this.state.type;if("card"===n&&1===this.config.cardGroupTypes.length&&(n=this.config.cardGroupTypes[0],this.state.type=n),this.isSingleBrandedCard="card"!==n,this.isSingleBrandedCard){const e=c.getCardByBrand(n);l(e)?(t=e.cvcPolicy||o,i=e.expiryDatePolicy||s,this.securityCode=e.securityCode):this.state.type="unrecognised-single-brand"}for(let o=0;o<e.length;o++){const s=e[o];window._b$dl&&console.log("\nAbout to set up securedField:",s),await this.setupSecuredField(s,t,i).catch(e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)}),window._b$dl&&console.log("Finished setting up securedField:",s)}if(window._b$dl&&console.log("Finished setting up all securedFields"),this.isSingleBrandedCard){const e={type:this.state.type,rootNode:this.props.rootNode,brand:n,cvcPolicy:t,expiryDatePolicy:i,cvcText:this.securityCode};setTimeout(()=>{this.callbacks.onBrand(e)},0)}}function g(e,i,o){return new Promise((s,l)=>{const c=t(e,this.encryptedAttrName);c===n&&(this.state.hasSeparateDateFields=!0);const u={fieldType:c,extraFieldData:t(e,d),uid:t(e,a),cvcPolicy:i,holderEl:e,expiryDatePolicy:o,txVariant:this.state.type,cardGroupTypes:this.config.cardGroupTypes,iframeUIConfig:this.config.iframeUIConfig,sfLogAtStart:this.config.sfLogAtStart,trimTrailingSeparator:this.config.trimTrailingSeparator,isCreditCardType:this.config.isCreditCardType,iframeSrc:this.config.iframeSrc,loadingContext:this.config.loadingContext,showWarnings:this.config.showWarnings,legacyInputMode:this.config.legacyInputMode,minimumExpiryDate:this.config.minimumExpiryDate,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,disableIOSArrowKeys:this.props.shouldDisableIOSArrowKeys,implementationType:this.props.implementationType,showContextualElement:this.props.showContextualElement,placeholders:this.props.placeholders,submitAnalytics:this.props.onSubmitAnalytics,componentType:this.props.componentType},f=new h(u,this.props.i18n).onIframeLoaded(()=>{if(this.state.iframeCount+=1,window._b$dl&&console.log("### createSecuredFields::onIframeLoaded:: this.state.iframeCount=",this.state.iframeCount),this.state.iframeCount>this.state.numIframes)throw this.destroySecuredFields(),new p("ERROR",`One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`);if(f.loadToConfigTimeout=setTimeout(()=>{l({type:u.fieldType,failReason:"sf took too long to config"})},r),this.state.iframeCount===this.state.originalNumIframes){const e={iframesLoaded:!0};this.callbacks.onLoad(e)}}).onConfig(e=>{this.handleIframeConfigFeedback(e),clearTimeout(f.loadToConfigTimeout),f.loadToConfigTimeout=null,s(e)}).onFocus(e=>{this.handleFocus(e)}).onBinValue(e=>{this.handleBinValue(e)}).onTouchstart(e=>{this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents||e.hasGenuineTouchEvents)&&this.callbacks.onTouchstartIOS({fieldType:e.fieldType}),(e.hasGenuineTouchEvents||this.hasGenuineTouchEvents)&&this.postMessageToAllIframes({fieldType:e.fieldType,fieldClick:!0})}).onShiftTab(e=>{this.handleSFShiftTab(e.fieldType)}).onEncryption(e=>{this.handleEncryption(e)}).onValidation(e=>{this.handleValidation(e)}).onAutoComplete(e=>{this.processAutoComplete(e)}).onKeyDown(e=>{const{numKey:t,...i}=e;this.callbacks.onKeyDown(i)});this.state.securedFields[c]=f})}export{y as createCardSecuredFields,m as createNonCardSecuredFields,f as createSecuredFields,g as setupSecuredField};
2
2
  //# sourceMappingURL=createSecuredFields.js.map