@adyen/adyen-web 6.35.0 → 6.37.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 (192) hide show
  1. package/dist/cjs/adyen.css +7 -7
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +2786 -2102
  6. package/dist/es/adyen.css +7 -7
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -1
  9. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  10. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  11. package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
  12. package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
  13. package/dist/es/components/Card/components/CardInput/components/CVCHint.js +1 -1
  14. package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  15. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
  17. package/dist/es/components/Donation/Donation.js +1 -1
  18. package/dist/es/components/Donation/Donation.js.map +1 -1
  19. package/dist/es/components/Donation/DonationCampaignService.js +2 -0
  20. package/dist/es/components/Donation/DonationCampaignService.js.map +1 -0
  21. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  22. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  23. package/dist/es/components/Donation/components/utils.js.map +1 -1
  24. package/dist/es/components/Iris/Iris.js +1 -1
  25. package/dist/es/components/Iris/Iris.js.map +1 -1
  26. package/dist/es/components/Iris/types.js.map +1 -1
  27. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  28. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  29. package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
  30. package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
  31. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  32. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  33. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  34. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  35. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  36. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  37. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  38. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  39. package/dist/es/components/ThreeDS2/components/utils.js +1 -1
  40. package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
  41. package/dist/es/components/UPI/UPI.js +1 -1
  42. package/dist/es/components/UPI/UPI.js.map +1 -1
  43. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  44. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  45. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  46. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  47. package/dist/es/components/UPI/constants.js +1 -1
  48. package/dist/es/components/UPI/constants.js.map +1 -1
  49. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  50. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  51. package/dist/es/components/internal/Address/Address.js +1 -1
  52. package/dist/es/components/internal/Address/Address.js.map +1 -1
  53. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  56. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  57. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  58. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  59. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  60. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  61. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  62. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  63. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  64. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  65. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  66. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  67. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  69. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  70. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  71. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js +1 -1
  72. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -1
  73. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  74. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  75. package/dist/es/components/internal/UIElement/utils.js +1 -1
  76. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  77. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  78. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  79. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  80. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  81. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  82. package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
  83. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  84. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  85. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  86. package/dist/es/core/Services/sessions/constants.js +1 -1
  87. package/dist/es/core/Services/sessions/constants.js.map +1 -1
  88. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  89. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  90. package/dist/es/core/Services/sessions/make-donation.js +2 -0
  91. package/dist/es/core/Services/sessions/make-donation.js.map +1 -0
  92. package/dist/es/core/config.js +1 -1
  93. package/dist/es/core/config.js.map +1 -1
  94. package/dist/es/core/core.registry.js +1 -1
  95. package/dist/es/core/core.registry.js.map +1 -1
  96. package/dist/es/core/utils.js +1 -1
  97. package/dist/es/core/utils.js.map +1 -1
  98. package/dist/es/index.d.ts +2786 -2102
  99. package/dist/es-legacy/adyen.css +7 -7
  100. package/dist/es-legacy/adyen.css.map +1 -1
  101. package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -1
  102. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  103. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  104. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
  105. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
  106. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js +1 -1
  107. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  108. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  109. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
  110. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  111. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  112. package/dist/es-legacy/components/Donation/DonationCampaignService.js +2 -0
  113. package/dist/es-legacy/components/Donation/DonationCampaignService.js.map +1 -0
  114. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  115. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  116. package/dist/es-legacy/components/Donation/components/utils.js.map +1 -1
  117. package/dist/es-legacy/components/Iris/Iris.js +1 -1
  118. package/dist/es-legacy/components/Iris/Iris.js.map +1 -1
  119. package/dist/es-legacy/components/Iris/types.js.map +1 -1
  120. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  121. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  122. package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
  123. package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
  124. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  125. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  126. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  127. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  128. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  129. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  130. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  131. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  132. package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
  133. package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
  134. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  135. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  136. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  137. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  138. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  139. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  140. package/dist/es-legacy/components/UPI/constants.js +1 -1
  141. package/dist/es-legacy/components/UPI/constants.js.map +1 -1
  142. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  143. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  144. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  145. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  146. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  147. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  148. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  149. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  150. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  151. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  152. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  153. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  154. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  155. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  156. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  157. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  158. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  159. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  160. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  161. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  162. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  163. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  164. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js +1 -1
  165. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -1
  166. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  167. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  168. package/dist/es-legacy/components/internal/UIElement/utils.js +1 -1
  169. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  170. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  171. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  172. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  173. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  174. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  175. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js +1 -1
  176. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  177. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  178. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  179. package/dist/es-legacy/core/Services/sessions/constants.js +1 -1
  180. package/dist/es-legacy/core/Services/sessions/constants.js.map +1 -1
  181. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  182. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  183. package/dist/es-legacy/core/Services/sessions/make-donation.js +2 -0
  184. package/dist/es-legacy/core/Services/sessions/make-donation.js.map +1 -0
  185. package/dist/es-legacy/core/config.js +1 -1
  186. package/dist/es-legacy/core/config.js.map +1 -1
  187. package/dist/es-legacy/core/core.registry.js +1 -1
  188. package/dist/es-legacy/core/core.registry.js.map +1 -1
  189. package/dist/es-legacy/core/utils.js +1 -1
  190. package/dist/es-legacy/core/utils.js.map +1 -1
  191. package/package.json +20 -20
  192. package/styles/adyen.css +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"PayToComponent.js","sources":["../../../../../src/components/PayTo/components/PayToComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { SegmentedControl } from '../../internal/SegmentedControl';\nimport { useMemo, useState } from 'preact/hooks';\nimport { SegmentedControlOptions } from '../../internal/SegmentedControl/SegmentedControl';\nimport PayIDInput from './PayIDInput';\nimport BSBInput from './BSBInput';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport { PayToData, PayToPlaceholdersType } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport classNames from 'classnames';\nimport { getUniqueId } from '../../../utils/idGenerator';\nimport './PayToComponent.scss';\n\nexport type PayToInputOption = 'payid-option' | 'bsb-option';\n\nexport type PayToComponentData = { selectedInput: PayToInputOption };\n\nexport interface PayToComponentProps {\n showPayButton: boolean;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n data: PayToData;\n placeholders: PayToPlaceholdersType;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n}\n\nexport default function PayToComponent(props: Readonly<PayToComponentProps>) {\n const { i18n } = useCoreContext();\n\n const [status, setStatus] = useState<UIElementStatus>('ready');\n\n // Generate unique IDs for the input sections\n const payidInputId = useMemo(() => getUniqueId('payid-input'), []);\n const bsbInputId = useMemo(() => getUniqueId('bsb-input'), []);\n\n const inputOptions: SegmentedControlOptions<PayToInputOption> = useMemo(\n () => [\n {\n value: 'payid-option',\n label: 'PayID',\n id: 'payid-option',\n controls: payidInputId\n },\n {\n value: 'bsb-option',\n label: i18n.get('payto.bsb.option.label'),\n id: 'bsb-option',\n controls: bsbInputId\n }\n ],\n [i18n, payidInputId, bsbInputId]\n );\n\n const defaultOption = inputOptions[0].value;\n const [selectedInput, setSelectedInput] = useState<PayToInputOption>(defaultOption);\n\n const onChange = ({ data, valid, errors, isValid }) => {\n // merge selected input to as data, this keep the input layers untouched\n props.onChange({ data: { selectedInput: selectedInput, ...data }, valid, errors, isValid });\n };\n\n return (\n <div\n className={classNames({\n 'adyen-checkout__payto-component': true,\n 'adyen-checkout__payto-component--loading': status === 'loading'\n })}\n >\n <SegmentedControl selectedValue={selectedInput} options={inputOptions} onChange={setSelectedInput} />\n {selectedInput === 'payid-option' && (\n <PayIDInput\n id={payidInputId}\n status={status}\n setStatus={setStatus}\n setComponentRef={props.setComponentRef}\n onChange={onChange}\n defaultData={props.data}\n placeholders={props.placeholders}\n />\n )}\n {selectedInput === 'bsb-option' && (\n <BSBInput\n id={bsbInputId}\n status={status}\n setStatus={setStatus}\n setComponentRef={props.setComponentRef}\n onChange={onChange}\n defaultData={props.data}\n placeholders={props.placeholders}\n />\n )}\n\n {props.showPayButton && props.payButton({ status, label: i18n.get('continue') })}\n </div>\n );\n}\n"],"names":["PayToComponent","props","i18n","useCoreContext","status","setStatus","useState","payidInputId","useMemo","getUniqueId","bsbInputId","inputOptions","value","label","id","controls","get","defaultOption","selectedInput","setSelectedInput","onChange","data","valid","errors","isValid","h","div","className","classNames","SegmentedControl","selectedValue","options","PayIDInput","setComponentRef","defaultData","placeholders","BSBInput","showPayButton","payButton"],"mappings":"6dA2Be,SAASA,EAAeC,GACnC,MAAMC,KAAEA,GAASC,KAEVC,EAAQC,GAAaC,EAA0B,SAGhDC,EAAeC,EAAQ,IAAMC,EAAY,eAAgB,IACzDC,EAAaF,EAAQ,IAAMC,EAAY,aAAc,IAErDE,EAA0DH,EAC5D,IAAM,CACF,CACII,MAAO,eACPC,MAAO,QACPC,GAAI,eACJC,SAAUR,GAEd,CACIK,MAAO,aACPC,MAAOX,EAAKc,IAAI,0BAChBF,GAAI,aACJC,SAAUL,IAGlB,CAACR,EAAMK,EAAcG,IAGnBO,EAAgBN,EAAa,GAAGC,OAC/BM,EAAeC,GAAoBb,EAA2BW,GAE/DG,EAAW,EAAGC,OAAMC,QAAOC,SAAQC,cAErCvB,EAAMmB,SAAS,CAAEC,KAAM,CAAEH,cAAeA,KAAkBG,GAAQC,QAAOC,SAAQC,aAGrF,OACIC,EAACC,MAAAA,CACGC,UAAWC,EAAW,CAClB,mCAAmC,EACnC,2CAAuD,YAAXxB,KAGhDqB,EAACI,EAAAA,CAAiBC,cAAeZ,EAAea,QAASpB,EAAcS,SAAUD,IAC9D,iBAAlBD,GACGO,EAACO,EAAAA,CACGlB,GAAIP,EACJH,OAAQA,EACRC,UAAWA,EACX4B,gBAAiBhC,EAAMgC,gBACvBb,SAAUA,EACVc,YAAajC,EAAMoB,KACnBc,aAAclC,EAAMkC,eAGT,eAAlBjB,GACGO,EAACW,EAAAA,CACGtB,GAAIJ,EACJN,OAAQA,EACRC,UAAWA,EACX4B,gBAAiBhC,EAAMgC,gBACvBb,SAAUA,EACVc,YAAajC,EAAMoB,KACnBc,aAAclC,EAAMkC,eAI3BlC,EAAMoC,eAAiBpC,EAAMqC,UAAU,CAAElC,SAAQS,MAAOX,EAAKc,IAAI,cAG9E"}
1
+ {"version":3,"file":"PayToComponent.js","sources":["../../../../../src/components/PayTo/components/PayToComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { SegmentedControl, SegmentedControlRegion } from '../../internal/SegmentedControl';\nimport { useMemo, useState } from 'preact/hooks';\nimport { SegmentedControlOptions } from '../../internal/SegmentedControl/SegmentedControl';\nimport PayIDInput from './PayIDInput';\nimport BSBInput from './BSBInput';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport { PayToData, PayToPlaceholdersType } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport classNames from 'classnames';\nimport { getUniqueId } from '../../../utils/idGenerator';\nimport './PayToComponent.scss';\n\nexport type PayToInputOption = 'payid-option' | 'bsb-option';\n\nexport type PayToComponentData = { selectedInput: PayToInputOption };\n\nexport interface PayToComponentProps {\n showPayButton: boolean;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n data: PayToData;\n placeholders: PayToPlaceholdersType;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n}\n\nexport default function PayToComponent(props: Readonly<PayToComponentProps>) {\n const { i18n } = useCoreContext();\n\n const [status, setStatus] = useState<UIElementStatus>('ready');\n\n // Generate unique IDs for the tab panels and input sections\n const payidPanelId = useMemo(() => getUniqueId('payid-panel'), []);\n const bsbPanelId = useMemo(() => getUniqueId('bsb-panel'), []);\n const payidInputId = useMemo(() => getUniqueId('payid-input'), []);\n const bsbInputId = useMemo(() => getUniqueId('bsb-input'), []);\n\n const inputOptions: SegmentedControlOptions<PayToInputOption> = useMemo(\n () => [\n {\n value: 'payid-option',\n label: 'PayID',\n id: 'payid-option',\n controls: payidPanelId\n },\n {\n value: 'bsb-option',\n label: i18n.get('payto.bsb.option.label'),\n id: 'bsb-option',\n controls: bsbPanelId\n }\n ],\n [i18n, payidPanelId, bsbPanelId]\n );\n\n const defaultOption = inputOptions[0].value;\n const [selectedInput, setSelectedInput] = useState<PayToInputOption>(defaultOption);\n\n const onChange = ({ data, valid, errors, isValid }) => {\n // merge selected input to as data, this keep the input layers untouched\n props.onChange({ data: { selectedInput: selectedInput, ...data }, valid, errors, isValid });\n };\n\n return (\n <div\n className={classNames({\n 'adyen-checkout__payto-component': true,\n 'adyen-checkout__payto-component--loading': status === 'loading'\n })}\n >\n <SegmentedControl selectedValue={selectedInput} options={inputOptions} onChange={setSelectedInput} />\n {selectedInput === 'payid-option' && (\n <SegmentedControlRegion id={payidPanelId} ariaLabelledBy=\"payid-option\">\n <PayIDInput\n id={payidInputId}\n status={status}\n setStatus={setStatus}\n setComponentRef={props.setComponentRef}\n onChange={onChange}\n defaultData={props.data}\n placeholders={props.placeholders}\n />\n </SegmentedControlRegion>\n )}\n {selectedInput === 'bsb-option' && (\n <SegmentedControlRegion id={bsbPanelId} ariaLabelledBy=\"bsb-option\">\n <BSBInput\n id={bsbInputId}\n status={status}\n setStatus={setStatus}\n setComponentRef={props.setComponentRef}\n onChange={onChange}\n defaultData={props.data}\n placeholders={props.placeholders}\n />\n </SegmentedControlRegion>\n )}\n\n {props.showPayButton && props.payButton({ status, label: i18n.get('continue') })}\n </div>\n );\n}\n"],"names":["PayToComponent","props","i18n","useCoreContext","status","setStatus","useState","payidPanelId","useMemo","getUniqueId","bsbPanelId","payidInputId","bsbInputId","inputOptions","value","label","id","controls","get","defaultOption","selectedInput","setSelectedInput","onChange","data","valid","errors","isValid","h","div","className","classNames","SegmentedControl","selectedValue","options","SegmentedControlRegion","ariaLabelledBy","PayIDInput","setComponentRef","defaultData","placeholders","BSBInput","showPayButton","payButton"],"mappings":"gkBA2Be,SAASA,EAAeC,GACnC,MAAMC,KAAEA,GAASC,KAEVC,EAAQC,GAAaC,EAA0B,SAGhDC,EAAeC,EAAQ,IAAMC,EAAY,eAAgB,IACzDC,EAAaF,EAAQ,IAAMC,EAAY,aAAc,IACrDE,EAAeH,EAAQ,IAAMC,EAAY,eAAgB,IACzDG,EAAaJ,EAAQ,IAAMC,EAAY,aAAc,IAErDI,EAA0DL,EAC5D,IAAM,CACF,CACIM,MAAO,eACPC,MAAO,QACPC,GAAI,eACJC,SAAUV,GAEd,CACIO,MAAO,aACPC,MAAOb,EAAKgB,IAAI,0BAChBF,GAAI,aACJC,SAAUP,IAGlB,CAACR,EAAMK,EAAcG,IAGnBS,EAAgBN,EAAa,GAAGC,OAC/BM,EAAeC,GAAoBf,EAA2Ba,GAE/DG,EAAW,EAAGC,OAAMC,QAAOC,SAAQC,cAErCzB,EAAMqB,SAAS,CAAEC,KAAM,CAAEH,cAAeA,KAAkBG,GAAQC,QAAOC,SAAQC,aAGrF,OACIC,EAACC,MAAAA,CACGC,UAAWC,EAAW,CAClB,mCAAmC,EACnC,2CAAuD,YAAX1B,KAGhDuB,EAACI,EAAAA,CAAiBC,cAAeZ,EAAea,QAASpB,EAAcS,SAAUD,IAC9D,iBAAlBD,GACGO,EAACO,EAAAA,CAAuBlB,GAAIT,EAAc4B,eAAe,gBACrDR,EAACS,EAAAA,CACGpB,GAAIL,EACJP,OAAQA,EACRC,UAAWA,EACXgC,gBAAiBpC,EAAMoC,gBACvBf,SAAUA,EACVgB,YAAarC,EAAMsB,KACnBgB,aAActC,EAAMsC,gBAIb,eAAlBnB,GACGO,EAACO,EAAAA,CAAuBlB,GAAIN,EAAYyB,eAAe,cACnDR,EAACa,EAAAA,CACGxB,GAAIJ,EACJR,OAAQA,EACRC,UAAWA,EACXgC,gBAAiBpC,EAAMoC,gBACvBf,SAAUA,EACVgB,YAAarC,EAAMsB,KACnBgB,aAActC,EAAMsC,gBAK/BtC,EAAMwC,eAAiBxC,EAAMyC,UAAU,CAAEtC,SAAQW,MAAOb,EAAKgB,IAAI,cAG9E"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./components/Challenge/PrepareChallenge3DS2.js";import{THREEDS2_CHALLENGE_ERROR as n,THREEDS2_CHALLENGE as r,DEFAULT_CHALLENGE_WINDOW_SIZE as s}from"./constants.js";import{existy as i}from"../../utils/commonUtils.js";import{hasOwnProperty as a}from"../../utils/hasOwnProperty.js";import{TxVariants as p}from"../tx-variants.js";import l,{API_ERROR as m}from"../../core/Errors/AdyenCheckoutError.js";import{AnalyticsLogEvent as c,LogEventSubtype as h,LogEventType as u}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as y,ErrorEventType as d,ErrorEventCode as f}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function A(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class D extends t{beforeRender(){}onComplete(e){this.props.onComplete?this.props.onComplete(e,this.elementRef):super.onComplete(e),this.unmount()}componentToRender(){if(!i(this.props.paymentData)){const e=a(this.props,"isMDFlow")?"paymentData":"authorisationToken";this.props.onError(new l(m,`No ${e} received. 3DS2 Challenge cannot proceed`));const t=new y({component:this.type,code:f.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:d.threeDS2,message:`${n}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(t),null}return e(o,{...this.props,onComplete:this.onComplete,onSubmitAnalytics:this.submitAnalytics,isMDFlow:this.props.paymentData.length<15,onActionHandled:this.onActionHandled})}constructor(...e){super(...e),A(this,"onActionHandled",e=>{const t=new c({component:this.type,type:u.threeDS2,subType:h.challengeIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}A(D,"type",p.threeDS2Challenge),A(D,"defaultProps",{dataKey:"threeDSResult",size:s,type:r});export{D as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./components/Challenge/PrepareChallenge3DS2.js";import{THREEDS2_CHALLENGE_ERROR as n,THREEDS2_CHALLENGE as r,DEFAULT_CHALLENGE_WINDOW_SIZE as s}from"./constants.js";import{existy as i}from"../../utils/commonUtils.js";import{hasOwnProperty as a}from"../../utils/hasOwnProperty.js";import{TxVariants as p}from"../tx-variants.js";import l,{API_ERROR as m}from"../../core/Errors/AdyenCheckoutError.js";import{AnalyticsLogEvent as c,LogEventSubtype as h,LogEventType as u}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as d,ErrorEventType as y,ErrorEventCode as f}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function A(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class D extends t{beforeRender(){}onComplete(e){this.props.isMDFlow?this.props.on3DS2RedirectFlowComplete?.(e,this.elementRef):super.onComplete(e),this.unmount()}componentToRender(){if(!i(this.props.paymentData)){const e=a(this.props,"isMDFlow")?"paymentData":"authorisationToken";this.props.onError(new l(m,`No ${e} received. 3DS2 Challenge cannot proceed`));const t=new d({component:this.type,code:f.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:y.threeDS2,message:`${n}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(t),null}return e(o,{...this.props,onComplete:this.onComplete,onSubmitAnalytics:this.submitAnalytics,onActionHandled:this.onActionHandled})}constructor(...e){super(...e),A(this,"onActionHandled",e=>{const t=new c({component:this.type,type:u.threeDS2,subType:h.challengeIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}A(D,"type",p.threeDS2Challenge),A(D,"defaultProps",{dataKey:"threeDSResult",size:s,type:r});export{D as default};
2
2
  //# sourceMappingURL=ThreeDS2Challenge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDS2Challenge.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2Challenge.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareChallenge from './components/Challenge';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE, THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR } from './constants';\nimport { existy } from '../../utils/commonUtils';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport { TxVariants } from '../tx-variants';\nimport { ChallengeResolveData, LegacyChallengeResolveData, ThreeDS2ChallengeConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass ThreeDS2Challenge extends UIElement<ThreeDS2ChallengeConfiguration> {\n public static readonly type = TxVariants.threeDS2Challenge;\n\n public static readonly defaultProps = {\n dataKey: 'threeDSResult',\n size: DEFAULT_CHALLENGE_WINDOW_SIZE,\n type: THREEDS2_CHALLENGE\n };\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2Challenge - it will have the same timestamp as the \"creq sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n onComplete(state: LegacyChallengeResolveData | ChallengeResolveData) {\n /**\n * Equals a call to onAdditionalDetails (as set in actionTypes.ts) for the regular, \"native\" flow.\n * However, if the action to create this component came from the 3DS2InMDFlow process it will instead equal a call to the onComplete callback\n * (as defined in the 3DS2InMDFlow and passed in as a config prop).\n */\n if (this.props.onComplete) {\n this.props.onComplete(state, this.elementRef);\n } else {\n super.onComplete(state);\n }\n\n this.unmount(); // re. fixing issue around back to back challenge calls\n }\n\n protected override componentToRender(): h.JSX.Element {\n // existy used because threeds2InMDFlow will send empty string for paymentData and we should be allowed to proceed with this\n if (!existy(this.props.paymentData)) {\n /**\n * The presence of props.isMDFlow indicates the action to create this component came from the threeds2InMDFlow process which passes (an empty) paymentsData.\n * The regular, \"native\" flow uses the authorisationToken from the 3DS2 action, which actionTypes.ts assigns to a property called paymentData\n */\n const dataTypeForError = hasOwnProperty(this.props, 'isMDFlow') ? 'paymentData' : 'authorisationToken';\n\n this.props.onError(new AdyenCheckoutError(API_ERROR, `No ${dataTypeForError} received. 3DS2 Challenge cannot proceed`));\n\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n return (\n <PrepareChallenge\n {...this.props}\n onComplete={this.onComplete}\n onSubmitAnalytics={this.submitAnalytics}\n isMDFlow={this.props.paymentData.length < 15}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2Challenge;\n"],"names":["ThreeDS2Challenge","UIElement","beforeRender","onComplete","state","this","props","elementRef","super","unmount","componentToRender","existy","paymentData","dataTypeForError","hasOwnProperty","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","submitAnalytics","h","PrepareChallenge","onSubmitAnalytics","isMDFlow","length","onActionHandled","args","_define_property","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeIframeLoaded","actionDescription","TxVariants","threeDS2Challenge","defaultProps","dataKey","size","DEFAULT_CHALLENGE_WINDOW_SIZE","THREEDS2_CHALLENGE"],"mappings":"q5BAaA,MAAMA,UAA0BC,EASTC,YAAAA,GAEnB,CAeAC,UAAAA,CAAWC,GAMHC,KAAKC,MAAMH,WACXE,KAAKC,MAAMH,WAAWC,EAAOC,KAAKE,YAElCC,MAAML,WAAWC,GAGrBC,KAAKI,SACT,CAEmBC,iBAAAA,GAEf,IAAKC,EAAON,KAAKC,MAAMM,aAAc,CAKjC,MAAMC,EAAmBC,EAAeT,KAAKC,MAAO,YAAc,cAAgB,qBAElFD,KAAKC,MAAMS,QAAQ,IAAIC,EAAmBC,EAAW,MAAMJ,8CAE3D,MAAMK,EAAQ,IAAIC,EAAoB,CAClCC,UAAWf,KAAKgB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFAxB,KAAKyB,gBAAgBZ,GAEd,IACX,CAEA,OACIa,EAACC,EAAAA,IACO3B,KAAKC,MACTH,WAAYE,KAAKF,WACjB8B,kBAAmB5B,KAAKyB,gBACxBI,SAAU7B,KAAKC,MAAMM,YAAYuB,OAAS,GAC1CC,gBAAiB/B,KAAK+B,iBAGlC,mBAzEJ5B,SAAA6B,GAaIC,EAAAjC,KAAU+B,kBAAmBG,IACzB,MAAMrB,EAAQ,IAAIsB,EAAkB,CAChCpB,UAAWf,KAAKgB,KAChBA,KAAMoB,EAAad,SACnBe,QAASC,EAAgBC,sBACzBhB,QAASW,EAAOM,oBAGpBxC,KAAKyB,gBAAgBZ,GAErBV,MAAM4B,gBAAgBG,MAtB1BD,EADEtC,EACqBqB,OAAOyB,EAAWC,mBAEzCT,EAHEtC,EAGqBgD,eAAe,CAClCC,QAAS,gBACTC,KAAMC,EACN9B,KAAM+B"}
1
+ {"version":3,"file":"ThreeDS2Challenge.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2Challenge.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareChallenge from './components/Challenge';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE, THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR } from './constants';\nimport { existy } from '../../utils/commonUtils';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport { TxVariants } from '../tx-variants';\nimport { ChallengeResolveData, LegacyChallengeResolveData, ThreeDS2ChallengeConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass ThreeDS2Challenge extends UIElement<ThreeDS2ChallengeConfiguration> {\n public static readonly type = TxVariants.threeDS2Challenge;\n\n public static readonly defaultProps = {\n dataKey: 'threeDSResult',\n size: DEFAULT_CHALLENGE_WINDOW_SIZE,\n type: THREEDS2_CHALLENGE\n };\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2Challenge - it will have the same timestamp as the \"creq sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n /**\n * Will make a call to onAdditionalDetails (as set in actionTypes.ts) for the regular, \"native\" flow.\n * However, if the action to create this component came from the 3DS2InMDFlow process it will instead equal a call to the onComplete callback\n * (as defined in the 3DS2InMDFlow and passed in as a config prop).\n */\n onComplete(state: LegacyChallengeResolveData | ChallengeResolveData) {\n if (this.props.isMDFlow) {\n this.props.on3DS2RedirectFlowComplete?.(state, this.elementRef);\n } else {\n super.onComplete(state);\n }\n\n this.unmount(); // re. fixing issue around back to back challenge calls\n }\n\n protected override componentToRender(): h.JSX.Element {\n // existy used because threeds2InMDFlow might send an empty string for paymentData and we should be allowed to proceed with this\n if (!existy(this.props.paymentData)) {\n /**\n * The presence of props.isMDFlow indicates the action to create this component came from the threeds2InMDFlow process which passes (an empty) paymentsData.\n * The regular, \"native\" flow uses the authorisationToken from the 3DS2 action, which actionTypes.ts assigns to a property called paymentData\n */\n const dataTypeForError = hasOwnProperty(this.props, 'isMDFlow') ? 'paymentData' : 'authorisationToken';\n\n this.props.onError(new AdyenCheckoutError(API_ERROR, `No ${dataTypeForError} received. 3DS2 Challenge cannot proceed`));\n\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n return (\n <PrepareChallenge\n {...this.props}\n onComplete={this.onComplete}\n onSubmitAnalytics={this.submitAnalytics}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2Challenge;\n"],"names":["ThreeDS2Challenge","UIElement","beforeRender","onComplete","state","this","props","isMDFlow","on3DS2RedirectFlowComplete","elementRef","super","unmount","componentToRender","existy","paymentData","dataTypeForError","hasOwnProperty","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","submitAnalytics","h","PrepareChallenge","onSubmitAnalytics","onActionHandled","args","_define_property","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeIframeLoaded","actionDescription","TxVariants","threeDS2Challenge","defaultProps","dataKey","size","DEFAULT_CHALLENGE_WINDOW_SIZE","THREEDS2_CHALLENGE"],"mappings":"q5BAaA,MAAMA,UAA0BC,EASTC,YAAAA,GAEnB,CAoBAC,UAAAA,CAAWC,GACHC,KAAKC,MAAMC,SACXF,KAAKC,MAAME,6BAA6BJ,EAAOC,KAAKI,YAEpDC,MAAMP,WAAWC,GAGrBC,KAAKM,SACT,CAEmBC,iBAAAA,GAEf,IAAKC,EAAOR,KAAKC,MAAMQ,aAAc,CAKjC,MAAMC,EAAmBC,EAAeX,KAAKC,MAAO,YAAc,cAAgB,qBAElFD,KAAKC,MAAMW,QAAQ,IAAIC,EAAmBC,EAAW,MAAMJ,8CAE3D,MAAMK,EAAQ,IAAIC,EAAoB,CAClCC,UAAWjB,KAAKkB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFA1B,KAAK2B,gBAAgBZ,GAEd,IACX,CAEA,OACIa,EAACC,EAAAA,IACO7B,KAAKC,MACTH,WAAYE,KAAKF,WACjBgC,kBAAmB9B,KAAK2B,gBACxBI,gBAAiB/B,KAAK+B,iBAGlC,mBAxEJ1B,SAAA2B,GAaIC,EAAAjC,KAAU+B,kBAAmBG,IACzB,MAAMnB,EAAQ,IAAIoB,EAAkB,CAChClB,UAAWjB,KAAKkB,KAChBA,KAAMkB,EAAaZ,SACnBa,QAASC,EAAgBC,sBACzBd,QAASS,EAAOM,oBAGpBxC,KAAK2B,gBAAgBZ,GAErBV,MAAM0B,gBAAgBG,MAtB1BD,EADEtC,EACqBuB,OAAOuB,EAAWC,mBAEzCT,EAHEtC,EAGqBgD,eAAe,CAClCC,QAAS,gBACTC,KAAMC,EACN5B,KAAM6B"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./components/DeviceFingerprint/PrepareFingerprint3DS2.js";import r from"./callSubmit3DS2Fingerprint.js";import{existy as o}from"../../utils/commonUtils.js";import{TxVariants as i}from"../tx-variants.js";import s,{API_ERROR as p}from"../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_FINGERPRINT_ERROR as a,THREEDS2_FINGERPRINT as m}from"./constants.js";import{AnalyticsLogEvent as l,LogEventSubtype as c,LogEventType as u}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as h,ErrorEventType as d,ErrorEventCode as y}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function f(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}class D extends e{beforeRender(){}onComplete(t){this.props.onComplete?this.props.onComplete(t,this.elementRef):super.onComplete(t),this.unmount()}componentToRender(){if(!o(this.props.paymentData)){this.props.onError(new s(p,"No paymentData received. 3DS2 Fingerprint cannot proceed"));const t=new h({component:this.type,code:y.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:d.threeDS2,message:`${a}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(t),null}return t(n,{...this.props,onComplete:this.props.isMDFlow?this.onComplete:this.callSubmit3DS2Fingerprint,onSubmitAnalytics:this.submitAnalytics,isMDFlow:this.props.paymentData.length<15,onActionHandled:this.onActionHandled})}constructor(...t){super(...t),f(this,"callSubmit3DS2Fingerprint",r.bind(this)),f(this,"onActionHandled",t=>{const e=new l({component:this.type,type:u.threeDS2,subType:c.fingerprintIframeLoaded,message:t.actionDescription});this.submitAnalytics(e),super.onActionHandled(t)})}}f(D,"type",i.threeDS2Fingerprint),f(D,"defaultProps",{dataKey:"fingerprintResult",type:m});export{D as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/DeviceFingerprint/PrepareFingerprint3DS2.js";import n from"./callSubmit3DS2Fingerprint.js";import{existy as o}from"../../utils/commonUtils.js";import{TxVariants as i}from"../tx-variants.js";import s,{API_ERROR as p}from"../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_FINGERPRINT_ERROR as a,THREEDS2_FINGERPRINT as m}from"./constants.js";import{AnalyticsLogEvent as c,LogEventSubtype as l,LogEventType as u}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as d,ErrorEventType as h,ErrorEventCode as f}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class D extends t{beforeRender(){}onComplete(e){this.props.isMDFlow?this.props.on3DS2RedirectFlowComplete?.(e,this.elementRef):super.onComplete(e),this.unmount()}componentToRender(){if(!o(this.props.paymentData)){this.props.onError(new s(p,"No paymentData received. 3DS2 Fingerprint cannot proceed"));const e=new d({component:this.type,code:f.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:h.threeDS2,message:`${a}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(e),null}return e(r,{...this.props,onComplete:this.props.isMDFlow?this.onComplete:this.callSubmit3DS2Fingerprint,onSubmitAnalytics:this.submitAnalytics,onActionHandled:this.onActionHandled})}constructor(...e){super(...e),y(this,"callSubmit3DS2Fingerprint",n.bind(this)),y(this,"onActionHandled",e=>{const t=new c({component:this.type,type:u.threeDS2,subType:l.fingerprintIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}y(D,"type",i.threeDS2Fingerprint),y(D,"defaultProps",{dataKey:"fingerprintResult",type:m});export{D as default};
2
2
  //# sourceMappingURL=ThreeDS2DeviceFingerprint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDS2DeviceFingerprint.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2DeviceFingerprint.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareFingerprint from './components/DeviceFingerprint';\nimport callSubmit3DS2Fingerprint from './callSubmit3DS2Fingerprint';\nimport { existy } from '../../utils/commonUtils';\nimport { TxVariants } from '../tx-variants';\nimport { FingerprintResolveData, LegacyFingerprintResolveData, ThreeDS2DeviceFingerprintConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR } from './constants';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass ThreeDS2DeviceFingerprint extends UIElement<ThreeDS2DeviceFingerprintConfiguration> {\n public static readonly type = TxVariants.threeDS2Fingerprint;\n\n public static readonly defaultProps = {\n dataKey: 'fingerprintResult',\n type: THREEDS2_FINGERPRINT\n };\n\n private callSubmit3DS2Fingerprint = callSubmit3DS2Fingerprint.bind(this); // New 3DS2 flow\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2DeviceFingerprint - it will have the same timestamp as the \"threeDSMethodData sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n onComplete(state: LegacyFingerprintResolveData | FingerprintResolveData) {\n if (this.props.onComplete) {\n this.props.onComplete(state, this.elementRef);\n } else {\n super.onComplete(state);\n }\n\n this.unmount(); // re. fixing issue around back to back fingerprinting calls\n }\n\n protected override componentToRender(): h.JSX.Element {\n /**\n * In the regular components (aka \"native\") flow we can't proceed because something has gone wrong with the payment if paymentData is missing from the threeDS2 action.\n * In the MDFlow the paymentData is always present (albeit an empty string, which is why we use 'existy' since we should be allowed to proceed with this)\n */\n if (!existy(this.props.paymentData)) {\n this.props.onError(new AdyenCheckoutError(API_ERROR, `No paymentData received. 3DS2 Fingerprint cannot proceed`));\n\n // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n /**\n * this.props.isMDFlow indicates the action to create this component came from the 3DS2InMDFlow process and upon completion should call the\n * passed onComplete callback (as defined in the 3DS2InMDFlow) instead of the /submitThreeDS2Fingerprint endpoint for the regular, \"native\" flow\n */\n return (\n <PrepareFingerprint\n {...this.props}\n onComplete={this.props.isMDFlow ? this.onComplete : this.callSubmit3DS2Fingerprint}\n onSubmitAnalytics={this.submitAnalytics}\n isMDFlow={this.props.paymentData.length < 15}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2DeviceFingerprint;\n"],"names":["ThreeDS2DeviceFingerprint","UIElement","beforeRender","onComplete","state","this","props","elementRef","super","unmount","componentToRender","existy","paymentData","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_FINGERPRINT_ERROR","submitAnalytics","h","PrepareFingerprint","isMDFlow","callSubmit3DS2Fingerprint","onSubmitAnalytics","length","onActionHandled","args","_define_property","bind","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintIframeLoaded","actionDescription","TxVariants","threeDS2Fingerprint","defaultProps","dataKey","THREEDS2_FINGERPRINT"],"mappings":"+2BAaA,MAAMA,UAAkCC,EAUjBC,YAAAA,GAEnB,CAeAC,UAAAA,CAAWC,GACHC,KAAKC,MAAMH,WACXE,KAAKC,MAAMH,WAAWC,EAAOC,KAAKE,YAElCC,MAAML,WAAWC,GAGrBC,KAAKI,SACT,CAEmBC,iBAAAA,GAKf,IAAKC,EAAON,KAAKC,MAAMM,aAAc,CACjCP,KAAKC,MAAMO,QAAQ,IAAIC,EAAmBC,EAAW,6DAGrD,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWb,KAAKc,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFAtB,KAAKuB,gBAAgBZ,GAEd,IACX,CAMA,OACIa,EAACC,EAAAA,IACOzB,KAAKC,MACTH,WAAYE,KAAKC,MAAMyB,SAAW1B,KAAKF,WAAaE,KAAK2B,0BACzDC,kBAAmB5B,KAAKuB,gBACxBG,SAAU1B,KAAKC,MAAMM,YAAYsB,OAAS,GAC1CC,gBAAiB9B,KAAK8B,iBAGlC,mBAvEJ3B,SAAA4B,GAQIC,OAAQL,4BAA4BA,EAA0BM,KAAKjC,OAMnEgC,EAAAhC,KAAU8B,kBAAmBI,IACzB,MAAMvB,EAAQ,IAAIwB,EAAkB,CAChCtB,UAAWb,KAAKc,KAChBA,KAAMsB,EAAahB,SACnBiB,QAASC,EAAgBC,wBACzBlB,QAASa,EAAOM,oBAGpBxC,KAAKuB,gBAAgBZ,GAErBR,MAAM2B,gBAAgBI,MAvB1BF,EADErC,EACqBmB,OAAO2B,EAAWC,qBAEzCV,EAHErC,EAGqBgD,eAAe,CAClCC,QAAS,oBACT9B,KAAM+B"}
1
+ {"version":3,"file":"ThreeDS2DeviceFingerprint.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2DeviceFingerprint.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareFingerprint from './components/DeviceFingerprint';\nimport callSubmit3DS2Fingerprint from './callSubmit3DS2Fingerprint';\nimport { existy } from '../../utils/commonUtils';\nimport { TxVariants } from '../tx-variants';\nimport { FingerprintResolveData, LegacyFingerprintResolveData, ThreeDS2DeviceFingerprintConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR } from './constants';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass ThreeDS2DeviceFingerprint extends UIElement<ThreeDS2DeviceFingerprintConfiguration> {\n public static readonly type = TxVariants.threeDS2Fingerprint;\n\n public static readonly defaultProps = {\n dataKey: 'fingerprintResult',\n type: THREEDS2_FINGERPRINT\n };\n\n private callSubmit3DS2Fingerprint = callSubmit3DS2Fingerprint.bind(this); // New 3DS2 flow\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2DeviceFingerprint - it will have the same timestamp as the \"threeDSMethodData sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n /**\n * Can be called directly from PrepareFingerprint (MDFlow) or after the call to /submitThreeDS2Fingerprint endpoint (native flow)\n */\n onComplete(state: LegacyFingerprintResolveData | FingerprintResolveData) {\n if (this.props.isMDFlow) {\n this.props.on3DS2RedirectFlowComplete?.(state, this.elementRef);\n } else {\n super.onComplete(state);\n }\n\n this.unmount(); // re. fixing issue around back to back fingerprinting calls\n }\n\n protected override componentToRender(): h.JSX.Element {\n /**\n * In the regular components (aka \"native\") flow we can't proceed because something has gone wrong with the payment if paymentData is missing from the threeDS2 action.\n * In the MDFlow the paymentData is always present (albeit an empty string, which is why we use 'existy' since we should be allowed to proceed with this)\n */\n if (!existy(this.props.paymentData)) {\n this.props.onError(new AdyenCheckoutError(API_ERROR, `No paymentData received. 3DS2 Fingerprint cannot proceed`));\n\n // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n /**\n * this.props.isMDFlow indicates the action to create this component came from the 3DS2InMDFlow process and upon completion should call the\n * passed onComplete callback (as defined in the 3DS2InMDFlow) instead of the /submitThreeDS2Fingerprint endpoint for the regular, \"native\" flow\n */\n return (\n <PrepareFingerprint\n {...this.props}\n // For MDFlow will bypass the /submitThreeDS2Fingerprint endpoint\n onComplete={this.props.isMDFlow ? this.onComplete : this.callSubmit3DS2Fingerprint}\n onSubmitAnalytics={this.submitAnalytics}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2DeviceFingerprint;\n"],"names":["ThreeDS2DeviceFingerprint","UIElement","beforeRender","onComplete","state","this","props","isMDFlow","on3DS2RedirectFlowComplete","elementRef","super","unmount","componentToRender","existy","paymentData","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_FINGERPRINT_ERROR","submitAnalytics","h","PrepareFingerprint","callSubmit3DS2Fingerprint","onSubmitAnalytics","onActionHandled","args","_define_property","bind","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintIframeLoaded","actionDescription","TxVariants","threeDS2Fingerprint","defaultProps","dataKey","THREEDS2_FINGERPRINT"],"mappings":"+2BAaA,MAAMA,UAAkCC,EAUjBC,YAAAA,GAEnB,CAkBAC,UAAAA,CAAWC,GACHC,KAAKC,MAAMC,SACXF,KAAKC,MAAME,6BAA6BJ,EAAOC,KAAKI,YAEpDC,MAAMP,WAAWC,GAGrBC,KAAKM,SACT,CAEmBC,iBAAAA,GAKf,IAAKC,EAAOR,KAAKC,MAAMQ,aAAc,CACjCT,KAAKC,MAAMS,QAAQ,IAAIC,EAAmBC,EAAW,6DAGrD,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWf,KAAKgB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFAxB,KAAKyB,gBAAgBZ,GAEd,IACX,CAMA,OACIa,EAACC,EAAAA,IACO3B,KAAKC,MAETH,WAAYE,KAAKC,MAAMC,SAAWF,KAAKF,WAAaE,KAAK4B,0BACzDC,kBAAmB7B,KAAKyB,gBACxBK,gBAAiB9B,KAAK8B,iBAGlC,mBA1EJzB,SAAA0B,GAQIC,OAAQJ,4BAA4BA,EAA0BK,KAAKjC,OAMnEgC,EAAAhC,KAAU8B,kBAAmBI,IACzB,MAAMrB,EAAQ,IAAIsB,EAAkB,CAChCpB,UAAWf,KAAKgB,KAChBA,KAAMoB,EAAad,SACnBe,QAASC,EAAgBC,wBACzBhB,QAASW,EAAOM,oBAGpBxC,KAAKyB,gBAAgBZ,GAErBR,MAAMyB,gBAAgBI,MAvB1BF,EADErC,EACqBqB,OAAOyB,EAAWC,qBAEzCV,EAHErC,EAGqBgD,eAAe,CAClCC,QAAS,oBACT5B,KAAM6B"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as s,createOldChallengeResolveData as o,createChallengeResolveData as n,prepareChallengeData as i}from"../utils.js";import a from"../../../internal/Img/Img.js";import{hasOwnProperty as l}from"../../../../utils/hasOwnProperty.js";import p from"../../../../core/Context/useImage.js";import c,{ERROR as h}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE_ERROR as u,MISSING_TOKEN_IN_ACTION_MSG as m,THREEDS2_NUM as S,THREEDS2_CHALLENGE as d}from"../../constants.js";import{isValidHttpUrl as g}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as D,LogEventSubtype as E,LogEventType as _}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as T,AnalyticsErrorEvent as f,ErrorEventType as C}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function I(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}class y extends e{componentDidMount(){if(!s(this.state.challengeData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{acsURL:r}=this.state.challengeData;if(!g(r,e)){this.setError({errorInfo:`${T.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new f({component:this.props.type,code:T.THREEDS2_TOKEN_IS_MISSING_ACSURL,errorType:C.threeDS2,message:`${u}: Decoded token is missing a valid acsURL property`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: no valid acsURL")}const{acsTransID:t,messageVersion:s,threeDSServerTransID:o}=this.state.challengeData.cReqData;if(!t||!s||!o){this.setError({errorInfo:`${T.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new f({component:this.props.type,code:T.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:C.threeDS2,message:`${u}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const e=this.state.challengeData.error,r=e.includes(m)?T.THREEDS2_ACTION_IS_MISSING_TOKEN:T.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new f({component:this.props.type,code:r,errorType:C.threeDS2,message:`${u}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=(this.props.isMDFlow?o:n)(this.props.dataKey,e.transStatus,this.props.paymentData);let s;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const i=r||e;if(i.errorCode){const e={code:"timeout"===i.errorCode?T.THREEDS2_TIMEOUT:T.THREEDS2_NO_TRANSSTATUS,errorType:C.threeDS2};s=new f({component:this.props.type,message:i.message,...e}),this.props.onSubmitAnalytics(s)}let a;switch(e?.transStatus){case"Y":a="success";break;case"N":a="failed";break;case"U":a=r?"timeout":"cancelled"}e?.errorCode&&(a="noTransStatus"),s=new D({component:this.props.type,type:_.threeDS2,subType:E.challengeCompleted,message:`${S} challenge has completed`,result:a}),this.props.onSubmitAnalytics(s),this.props.onComplete(t)})}setError(e,r){this.setState({status:"error",errorInfo:e.errorInfo}),r&&this.props.onError(new c(h,e.errorInfo,{cause:e.errorObj}))}render(e,{challengeData:s}){const o=p();return"performingChallenge"===this.state.status?r(t,{onCompleteChallenge:e=>{let r=null;if(l(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new c(h,`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${u}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new f({component:this.props.type,code:T.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:C.threeDS2,message:`${u}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(l(e,"errorCode")){const r={errorCode:e.errorCode,message:`${d}: ${e.errorCode}`};return this.props.isMDFlow&&this.props.onError(new c(h,`${u}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}},...s,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit}):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(a,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:o({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),I(this,"onFormSubmit",e=>{const r=new D({component:this.props.type,type:_.threeDS2,subType:E.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=i({token:this.props.token,size:this.props.challengeWindowSize||this.props.size});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:m}},console.debug(`${u}: ${m}`)}}I(y,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{y as default};
1
+ import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as s,createChallengeResolveData as o,prepareChallengeData as n}from"../utils.js";import a from"../../../internal/Img/Img.js";import{hasOwnProperty as i}from"../../../../utils/hasOwnProperty.js";import l from"../../../../core/Context/useImage.js";import p,{ERROR as c}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE_ERROR as h,MISSING_TOKEN_IN_ACTION_MSG as u,THREEDS2_NUM as m,THREEDS2_CHALLENGE as S}from"../../constants.js";import{isValidHttpUrl as d}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as g,LogEventSubtype as D,LogEventType as E}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as _,AnalyticsErrorEvent as T,ErrorEventType as f}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function C(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}class I extends e{componentDidMount(){if(!s(this.state.challengeData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{acsURL:r}=this.state.challengeData;if(!d(r,e)){this.setError({errorInfo:`${_.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new T({component:this.props.type,code:_.THREEDS2_TOKEN_IS_MISSING_ACSURL,errorType:f.threeDS2,message:`${h}: Decoded token is missing a valid acsURL property`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: no valid acsURL")}const{acsTransID:t,messageVersion:s,threeDSServerTransID:o}=this.state.challengeData.cReqData;if(!t||!s||!o){this.setError({errorInfo:`${_.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new T({component:this.props.type,code:_.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:f.threeDS2,message:`${h}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const e=this.state.challengeData.error,r=e.includes(u)?_.THREEDS2_ACTION_IS_MISSING_TOKEN:_.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new T({component:this.props.type,code:r,errorType:f.threeDS2,message:`${h}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=o(this.props.dataKey,e.transStatus,this.props.paymentData);let s;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const n=r||e;if(n.errorCode){const e={code:"timeout"===n.errorCode?_.THREEDS2_TIMEOUT:_.THREEDS2_NO_TRANSSTATUS,errorType:f.threeDS2};s=new T({component:this.props.type,message:n.message,...e}),this.props.onSubmitAnalytics(s)}let a;switch(e?.transStatus){case"Y":a="success";break;case"N":a="failed";break;case"U":a=r?"timeout":"cancelled"}e?.errorCode&&(a="noTransStatus"),s=new g({component:this.props.type,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:a}),this.props.onSubmitAnalytics(s),this.props.onComplete(t)})}setError(e,r){this.setState({status:"error",errorInfo:e.errorInfo}),r&&this.props.onError(new p(c,e.errorInfo,{cause:e.errorObj}))}render(e,{challengeData:s}){const o=l();return"performingChallenge"===this.state.status?r(t,{onCompleteChallenge:e=>{let r=null;if(i(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new p(c,`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${h}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new T({component:this.props.type,code:_.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:f.threeDS2,message:`${h}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(i(e,"errorCode")){const r={errorCode:e.errorCode,message:`${S}: ${e.errorCode}`};return this.props.isMDFlow&&this.props.onError(new p(c,`${h}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}},...s,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit}):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(a,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:o({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),C(this,"onFormSubmit",e=>{const r=new g({component:this.props.type,type:E.threeDS2,subType:D.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=n({token:this.props.token,size:this.props.challengeWindowSize||this.props.size});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:u}},console.debug(`${h}: ${u}`)}}C(I,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{I as default};
2
2
  //# sourceMappingURL=PrepareChallenge3DS2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, LegacyChallengeResolveData, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData: challengeData as ChallengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data: LegacyChallengeResolveData | ChallengeResolveData = resolveDataFunction(\n this.props.dataKey,\n resultObj.transStatus,\n this.props.paymentData\n );\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"gkCAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,OAAEA,GAAWT,KAAKC,MAAMC,cAI9B,IAHuBQ,EAAeD,EAAQN,GAGzB,CAEjBH,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAeC,qCAAqCd,KAAKI,MAAMW,KAAKC,IAAI,oBAE1F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWnB,KAAKI,MAAMgB,KACtBC,KAAMR,EAAeC,iCACrBQ,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,wDAKhB,OAHA1B,KAAKI,MAAMuB,kBAAkBV,QAE7BW,QAAQC,MAAM,sDAElB,CAEA,MAA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,KAAOyF,eAAgBU,IACnB,MAAMlF,EAAQ,IAAIyC,EAAkB,CAChCvC,UAAWnB,KAAKI,MAAMgB,KACtBA,KAAMuC,EAAanC,SACnBoC,QAASC,EAAgBuC,qBACzB3E,QAAS0E,IAGbnG,KAAKI,MAAMuB,kBAAkBV,KA1BzBjB,KAAKI,MAAMiG,MAAO,CAClB,MAAMnG,EAA6CoG,EAAqB,CACpED,MAAOrG,KAAKI,MAAMiG,MAClBE,KAAMvG,KAAKI,MAAMoG,qBAAuBxG,KAAKI,MAAMmG,OAGvDvG,KAAKC,MAAQ,CACTmC,OAAQ,OACRlC,cAAeA,EAEvB,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAEuG,SAAS,EAAOnE,MAAOE,IAEvDZ,QAAQC,MAAM,GAAGH,MAA6Bc,IAEtD,EAzBA0D,EADEtG,EACqB8G,eAAe,CAClC1C,WAAY,OACZG,QAAS,OACTpB,UAAU"}
1
+ {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData: challengeData as ChallengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","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ACXjF,KAAKI,MAAM6D,QACP,IAAIC,EAAmBC,EAAO,GAAGzC,gCAAwD,CACrF0C,MAAOS,EAAUtC,kBAK7BvC,KAAK2C,kBAAkBkC,EAAUtB,OAAQ8B,EAE7C,MAEAnF,EACJqF,gBAAiBvF,KAAKI,MAAMmF,gBAC5BC,aAAcxF,KAAKwF,eAKL,UAAtBxF,KAAKC,MAAMmC,OAEPsC,EAACe,MAAAA,CAAIC,UAAU,4CACXhB,EAACiB,EAAAA,CACGD,UAAU,mEACVE,IAAKpB,EAAS,CACVqB,YAAa,eADZrB,CAEF,SACHsB,IAAK,KAETpB,EAACe,MAAAA,CAAIC,UAAU,gCACV1F,KAAKC,MAAMW,UAAYZ,KAAKC,MAAMW,UAAYZ,KAAKI,MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAnVA,WAAA+E,CAAY3F,GAGR,GAFA4F,MAAM5F,GAoBV6F,EAAAjG,KAAOwF,eAAgBU,IACnB,MAAMjF,EAAQ,IAAIuC,EAAkB,CAChCrC,UAAWnB,KAAKI,MAAMgB,KACtBA,KAAMqC,EAAajC,SACnBkC,QAASC,EAAgBwC,qBACzB1E,QAASyE,IAGblG,KAAKI,MAAMuB,kBAAkBV,KA1BzBjB,KAAKI,MAAMgG,MAAO,CAClB,MAAMlG,EAA6CmG,EAAqB,CACpED,MAAOpG,KAAKI,MAAMgG,MAClBE,KAAMtG,KAAKI,MAAMmG,qBAAuBvG,KAAKI,MAAMkG,OAGvDtG,KAAKC,MAAQ,CACTmC,OAAQ,OACRlC,cAAeA,EAEvB,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAEsG,SAAS,EAAOlE,MAAOE,IAEvDZ,QAAQC,MAAM,GAAGH,MAA6Bc,IAEtD,EAzBAyD,EADErG,EACqB6G,eAAe,CAClC3C,WAAY,OACZG,QAAS,OACTgB,UAAU"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as n,prepareFingerPrintData as i}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as m,TIMEOUT as l,THREEDS2_NUM as c,THREEDS2_FINGERPRINT as h}from"../../constants.js";import{AnalyticsLogEvent as d,LogEventSubtype as S,LogEventType as D}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as u,ErrorEventType as g,AnalyticsErrorEvent as f}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class C extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{threeDSMethodURL:t,threeDSMethodNotificationURL:r,postMessageDomain:o,threeDSServerTransID:s}=this.state.fingerPrintData;if(!a(t,e))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:u.THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${p}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const n=a(r,e),i=a(o,e),m=s?.length;if(!n||!i||!m)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:u.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,message:`${p}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.includes(m)?u.THREEDS2_ACTION_IS_MISSING_TOKEN:u.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${p}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},()=>{const r=(this.props.isMDFlow?s:n)(this.props.dataKey,e,this.props.paymentData);let o;const i=t||e;if(i.errorCode){const e={code:i.errorCode===l?u.THREEDS2_TIMEOUT:i.errorCode,errorType:g.threeDS2};o=new f({component:this.props.type,message:i.message,...e}),this.props.onSubmitAnalytics(o)}let a;switch(e?.threeDSCompInd){case"Y":a="success";break;case"N":a=t?t.errorCode===l?l:"failedInternal":"failed";break;case"U":a="noThreeDSMethodURL"}o=new d({component:this.props.type,type:D.threeDS2,subType:S.fingerprintCompleted,message:`${c} fingerprinting has completed`,result:a}),this.props.onSubmitAnalytics(o),this.props.onComplete(r)})}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,{onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${h}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e,...s,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit}):null}constructor(e){super(e),E(this,"onFormSubmit",e=>{const t=new d({component:this.props.type,type:D.threeDS2,subType:S.fingerprintDataSentWeb,message:e});this.props.onSubmitAnalytics(t)});const{token:t,notificationURL:r}=this.props;if(t){const e=i({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:m}},console.debug(`${p}: ${m}`)}}E(C,"type","scheme"),E(C,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{C as default};
1
+ import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createFingerprintResolveData as s,prepareFingerPrintData as n}from"../utils.js";import{isValidHttpUrl as i}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as a,MISSING_TOKEN_IN_ACTION_MSG as p,TIMEOUT as m,THREEDS2_NUM as l,THREEDS2_FINGERPRINT as c}from"../../constants.js";import{AnalyticsLogEvent as h,LogEventSubtype as d,LogEventType as S}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as D,ErrorEventType as u,AnalyticsErrorEvent as g}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class E extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{threeDSMethodURL:t,threeDSMethodNotificationURL:r,postMessageDomain:o,threeDSServerTransID:s}=this.state.fingerPrintData;if(!i(t,e))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:D.THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${a}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const n=i(r,e),p=i(o,e),m=s?.length;if(!n||!p||!m)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:D.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,message:`${a}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.includes(p)?D.THREEDS2_ACTION_IS_MISSING_TOKEN:D.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${a}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},()=>{const r=s(this.props.dataKey,e,this.props.paymentData);let o;const n=t||e;if(n.errorCode){const e={code:n.errorCode===m?D.THREEDS2_TIMEOUT:n.errorCode,errorType:u.threeDS2};o=new g({component:this.props.type,message:n.message,...e}),this.props.onSubmitAnalytics(o)}let i;switch(e?.threeDSCompInd){case"Y":i="success";break;case"N":i=t?t.errorCode===m?m:"failedInternal":"failed";break;case"U":i="noThreeDSMethodURL"}o=new h({component:this.props.type,type:S.threeDS2,subType:d.fingerprintCompleted,message:`${l} fingerprinting has completed`,result:i}),this.props.onSubmitAnalytics(o),this.props.onComplete(r)})}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,{onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${c}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e,...s,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit}):null}constructor(e){super(e),f(this,"onFormSubmit",e=>{const t=new h({component:this.props.type,type:S.threeDS2,subType:d.fingerprintDataSentWeb,message:e});this.props.onSubmitAnalytics(t)});const{token:t,notificationURL:r}=this.props;if(t){const e=n({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:p}},console.debug(`${a}: ${p}`)}}f(E,"type","scheme"),f(E,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{E as default};
2
2
  //# sourceMappingURL=PrepareFingerprint3DS2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject, LegacyFingerprintResolveData, FingerprintResolveData } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static readonly type = 'scheme';\n\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data: LegacyFingerprintResolveData | FingerprintResolveData = resolveDataFunction(\n this.props.dataKey,\n resultObj,\n this.props.paymentData\n );\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? ErrorEventCode.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: ErrorEventType.threeDS2\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintCompleted,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ErrorEventType","threeDS2","AnalyticsErrorEvent","component","type","onSubmitAnalytics","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintCompleted","THREEDS2_NUM","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","fingerprintDataSentWeb","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"22BAYA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAeC,2CAC1BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,GAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZAzB,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAeU,sCAC1BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAORtB,KAAK4B,SAAS,CAAEC,OAAQ,yBAE5B,KAAO,CAGH,MAAMC,EAAmB9B,KAAMC,MAAMC,gBAAgC6B,MAE/Df,EAAYc,EAAStB,SAASwB,GAC9Bf,EAAegB,iCACfhB,EAAeiB,wCAErBlC,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,YACAG,QAAS,GAAGC,MAA+BU,MAInDT,QAAQC,MAAM,oGAClB,CACJ,CAEAR,iBAAAA,CAAkBqB,EAAyBC,EAAmC,MAC1EpC,KAAK4B,SAAS,CAAEC,OAAQ,YAAc,KAKlC,MACMQ,GADsBrC,KAAKI,MAAMkC,SAAWC,EAAkCC,GAEhFxC,KAAKI,MAAMq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EAAQ,IAAIc,EAAkB,CAChCJ,UAAWrD,KAAKI,MAAMkD,KACtBA,KAAMI,EAAaP,SACnBQ,QAASC,EAAgBmB,uBACzB5D,QAAS2D,IAGb9E,KAAKI,MAAMmD,kBAAkBZ,KAzB7B,MAAMqC,MAAEA,EAAKC,gBAAEA,GAAoBjF,KAAKI,MAExC,GAAI4E,EAAO,CACP,MAAM9E,EAAiDgF,EAAuB,CAAEF,QAAOC,oBAEvFjF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,EAEzB,MAEIF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEiF,SAAS,EAAOpD,MAAOC,IAEzDX,QAAQC,MAAM,GAAGF,MAA+BY,IAExD,EA3BA6C,EADEjF,EACqB0D,OAAO,UAE9BuB,EAHEjF,EAGqBwF,eAAe,CAClCrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
1
+ {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject, FingerprintResolveData } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static readonly type = 'scheme';\n\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: FingerprintResolveData = createFingerprintResolveData(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? ErrorEventCode.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: ErrorEventType.threeDS2\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintCompleted,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ErrorEventType","threeDS2","AnalyticsErrorEvent","component","type","onSubmitAnalytics","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintCompleted","THREEDS2_NUM","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","fingerprintDataSentWeb","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError","isMDFlow"],"mappings":"s0BAYA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAeC,2CAC1BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9D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SIZE as t}from"../constants.js";import{getOrigin as r}from"../../../utils/getOrigin.js";import s from"../../../utils/base64.js";const n=e=>"success"in e&&!e.success,a=e=>{const t=s.decode(e);if(t.success)try{return JSON.parse(t.data)}catch(e){return{success:!1,error:"Could not JSON parse token"}}return t},o=e=>{if(!e||!Object.keys(e).length)throw new Error("No (populated) data object to encode");return s.encode(JSON.stringify(e))},i=r=>{const s=1===r.length?`0${r}`:r;return Object.prototype.hasOwnProperty.call(e,s)?s:t},c=t=>e[i(t)],p=({token:e,size:t})=>{const s=a(e);if(n(s))return s;const{acsTransID:o,acsURL:p,messageVersion:l,threeDSNotificationURL:d,threeDSServerTransID:h}=s,u=r(d);return{acsURL:p,cReqData:{acsTransID:o,messageVersion:l,threeDSServerTransID:h,messageType:"CReq",challengeWindowSize:i(t)},iframeSizeArr:c(t),postMessageDomain:u}},l=({token:e,notificationURL:t})=>{const s=a(e);if(n(s))return s;const{threeDSMethodNotificationURL:o,threeDSMethodUrl:i,threeDSServerTransID:c}=s,p=t||o;return{threeDSServerTransID:c,threeDSMethodURL:i,threeDSMethodNotificationURL:p,postMessageDomain:r(p)}},d=(e,t,r)=>({data:{[e]:o({threeDSCompInd:t.threeDSCompInd}),paymentData:r}}),h=(e,t,r)=>({data:{details:{"threeds2.fingerprint":o(t)},paymentData:r}}),u=(e,t,r)=>({data:{details:{[e]:o({transStatus:t,authorisationToken:r})}}}),D=(e,t,r)=>({data:{details:{"threeds2.challengeResult":o({transStatus:t})},paymentData:r}}),m=e=>{let t=window.btoa(e).split("=")[0];return t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t},S=(e,t)=>"fingerprint"===e?{showSpinner:!t.isDropin,statusType:"loading",...t.elementRef&&{elementRef:t.elementRef}}:{statusType:"custom",i18n:t.i18n,elementRef:t.elementRef};export{u as createChallengeResolveData,d as createFingerprintResolveData,D as createOldChallengeResolveData,h as createOldFingerprintResolveData,a as decodeAndParseToken,m as encodeBase64URL,o as encodeObject,S as get3DS2FlowProps,c as getChallengeWindowSize,n as isErrorObject,p as prepareChallengeData,l as prepareFingerPrintData,i as validateChallengeWindowSize};
1
+ import{CHALLENGE_WINDOW_SIZES as e,DEFAULT_CHALLENGE_WINDOW_SIZE as t}from"../constants.js";import{getOrigin as r}from"../../../utils/getOrigin.js";import n from"../../../utils/base64.js";const s=e=>"success"in e&&!e.success,o=e=>{const t=n.decode(e);if(t.success)try{return JSON.parse(t.data)}catch(e){return{success:!1,error:"Could not JSON parse token"}}return t},a=e=>{if(!e||!Object.keys(e).length)throw new Error("No (populated) data object to encode");return n.encode(JSON.stringify(e))},i=r=>{const n=1===r.length?`0${r}`:r;return Object.prototype.hasOwnProperty.call(e,n)?n:t},c=t=>e[i(t)],p=({token:e,size:t})=>{const n=o(e);if(s(n))return n;const{acsTransID:a,acsURL:p,messageVersion:h,threeDSNotificationURL:u,threeDSServerTransID:l}=n,D=r(u);return{acsURL:p,cReqData:{acsTransID:a,messageVersion:h,threeDSServerTransID:l,messageType:"CReq",challengeWindowSize:i(t)},iframeSizeArr:c(t),postMessageDomain:D}},h=({token:e,notificationURL:t})=>{const n=o(e);if(s(n))return n;const{threeDSMethodNotificationURL:a,threeDSMethodUrl:i,threeDSServerTransID:c}=n,p=t||a;return{threeDSServerTransID:c,threeDSMethodURL:i,threeDSMethodNotificationURL:p,postMessageDomain:r(p)}},u=(e,t,r)=>({data:{[e]:a({threeDSCompInd:t.threeDSCompInd}),paymentData:r}}),l=(e,t,r)=>({data:{details:{[e]:a({transStatus:t,authorisationToken:r})}}}),D=e=>{let t=window.btoa(e).split("=")[0];return t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t},S=(e,t)=>"fingerprint"===e?{showSpinner:!t.isDropin,statusType:"loading",...t.elementRef&&{elementRef:t.elementRef}}:{statusType:"custom",i18n:t.i18n,elementRef:t.elementRef};export{l as createChallengeResolveData,u as createFingerprintResolveData,o as decodeAndParseToken,D as encodeBase64URL,a as encodeObject,S as get3DS2FlowProps,c as getChallengeWindowSize,s as isErrorObject,p as prepareChallengeData,h as prepareFingerPrintData,i as validateChallengeWindowSize};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/ThreeDS2/components/utils.ts"],"sourcesContent":["import { CHALLENGE_WINDOW_SIZES, DEFAULT_CHALLENGE_WINDOW_SIZE } from '../constants';\nimport { getOrigin } from '../../../utils/getOrigin';\nimport base64 from '../../../utils/base64';\nimport type {\n ChallengeData,\n ThreeDS2Token,\n FingerPrintData,\n ResultObject,\n FingerprintResolveData,\n ChallengeResolveData,\n ThreeDS2FlowProps,\n ThreeDS2ActionProps\n} from '../types';\nimport type { DecodeObject } from '../../../types/global-types';\nimport type { ErrorObject } from '../../../core/Errors/types';\n\n/**\n * Check if we have been passed an ErrorObject because either base64 decoding or JSON.parse failed\n * @param obj -\n */\nexport const isErrorObject = (obj: ErrorObject | ThreeDS2Token): boolean => {\n return 'success' in obj && !obj.success;\n};\n\nexport const decodeAndParseToken = (token: string): ThreeDS2Token | ErrorObject => {\n const decodedToken: DecodeObject = base64.decode(token);\n if (decodedToken.success) {\n try {\n return JSON.parse(decodedToken.data) as ThreeDS2Token;\n } catch (e) {\n return {\n success: false,\n error: 'Could not JSON parse token'\n };\n }\n }\n\n // base64.decode failed - object will contain error msg: 'not base64' or 'malformed URI sequence'\n return decodedToken as ErrorObject;\n};\n\n/**\n * Performs JSON.stringify on passed object & and base64 encodes result\n * @param obj -\n * @returns encoded result\n */\nexport const encodeObject = obj => {\n if (!obj || !Object.keys(obj).length) {\n throw new Error('No (populated) data object to encode');\n }\n return base64.encode(JSON.stringify(obj));\n};\n\n/**\n * Accepts a size string for the challenge window & returns it if it is valid else returns a default value\n * @param sizeStr - the size string to check the validity of\n * @returns a valid size string\n */\nexport const validateChallengeWindowSize = (sizeStr: string): string => {\n const sizeString = sizeStr.length === 1 ? `0${sizeStr}` : sizeStr;\n const hasSize = Object.prototype.hasOwnProperty.call(CHALLENGE_WINDOW_SIZES, sizeString);\n return hasSize ? sizeString : DEFAULT_CHALLENGE_WINDOW_SIZE;\n};\n\n/**\n * Accepts a size string for the challenge window & returns the corresponding array of w/h values\n * @param sizeStr -\n */\nexport const getChallengeWindowSize = (sizeStr: string): string[] => CHALLENGE_WINDOW_SIZES[validateChallengeWindowSize(sizeStr)];\n\n/**\n * prepareChallengeData\n *\n * Requires an object containing the challenge parameters:\n * @param token - challengeToken string received from /submitThreeDS2Fingerprint, /details or /payments call: contains acsTransID, acsURL, messageVersion,\n * threeDSNotificationURL and threeDSServerTransID\n * @param size - one of five possible challenge window sizes\n */\nexport const prepareChallengeData = ({ token, size }): ChallengeData | ErrorObject => {\n const decodedChallengeToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedChallengeToken)) {\n return decodedChallengeToken as ErrorObject;\n }\n\n const { acsTransID, acsURL, messageVersion, threeDSNotificationURL, threeDSServerTransID } = decodedChallengeToken as ThreeDS2Token;\n const notificationURLOrigin = getOrigin(threeDSNotificationURL);\n\n return {\n acsURL,\n cReqData: {\n acsTransID,\n messageVersion,\n threeDSServerTransID,\n messageType: 'CReq',\n challengeWindowSize: validateChallengeWindowSize(size)\n },\n iframeSizeArr: getChallengeWindowSize(size),\n postMessageDomain: notificationURLOrigin\n } as ChallengeData;\n};\n\n/**\n * prepareFingerPrintData\n *\n * Requires an object containing the fingerprint parameters:\n * @param token - fingerprintToken string received from /payments call: contains threeDSMethodNotificationURL, threeDSMethodUrl and\n * threeDSServerTransID\n * @param notificationURL - the URL that the final notification is expected to be postMessaged from.\n *\n * NOTE: we don't expect merchants to alter the default by passing in a notificationURL of their own via props;\n * and if 3DS2 is being done via createFromAction or handleAction we won't accept it.\n * But if the merchant is using checkout.create('threeDS2DeviceFingerprint') we still support the fact that they might want to set their own\n * notificationURL (aka threeDSMethodNotificationURL)\n */\nexport const prepareFingerPrintData = ({ token, notificationURL }): FingerPrintData | ErrorObject => {\n const decodedFingerPrintToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedFingerPrintToken)) {\n return decodedFingerPrintToken as ErrorObject;\n }\n\n const { threeDSMethodNotificationURL, threeDSMethodUrl: threeDSMethodURL, threeDSServerTransID } = decodedFingerPrintToken as ThreeDS2Token;\n const receivedNotificationURL = notificationURL || threeDSMethodNotificationURL;\n const notificationURLOrigin = getOrigin(receivedNotificationURL);\n\n return {\n threeDSServerTransID,\n threeDSMethodURL,\n threeDSMethodNotificationURL: receivedNotificationURL,\n postMessageDomain: notificationURLOrigin\n } as FingerPrintData;\n};\n\nexport const createFingerprintResolveData = (dataKey: string, resultObj: ResultObject, paymentData: string): FingerprintResolveData => ({\n data: {\n [dataKey]: encodeObject({ threeDSCompInd: resultObj.threeDSCompInd }),\n paymentData\n }\n});\n\n// Old 3DS2 flow\nexport const createOldFingerprintResolveData = (dataKey: string, resultObj: ResultObject, paymentData: string): any => ({\n data: {\n details: { 'threeds2.fingerprint': encodeObject(resultObj) },\n paymentData\n }\n});\n\nexport const createChallengeResolveData = (dataKey: string, transStatus: string, authorisationToken: string): ChallengeResolveData => ({\n data: {\n details: { [dataKey]: encodeObject({ transStatus, authorisationToken }) }\n }\n});\n\n// Needed for old 3DS2 flow & threeds2InMDFlow\nexport const createOldChallengeResolveData = (dataKey: string, transStatus: string, authorisationToken: string): any => ({\n data: {\n details: { 'threeds2.challengeResult': encodeObject({ transStatus }) },\n paymentData: authorisationToken\n }\n});\n\n/**\n *\n * Takes a string and encodes it as a base64url string\n * (https://en.wikipedia.org/wiki/Base64#URL_applications)\n * (See also https://tools.ietf.org/html/rfc7515)\n *\n * @example\n * ```\n * const jsonStr = JSON.stringify( {name:'john', surname:'smith'} );\n * const base64url = encodeBase64URL(jsonStr);\n * ```\n *\n * @param dataStr - data, as a string, to be encoded\n *\n * @returns base64URL - a base64url encoded string\n */\nexport const encodeBase64URL = (dataStr: string): string => {\n const base64Data = window.btoa(dataStr);\n let base64url = base64Data.split('=')[0]; // Remove any trailing '='s\n\n base64url = base64url.replace(/\\+/g, '-'); // 62nd char of encoding\n base64url = base64url.replace(/\\//g, '_'); // 63rd char of encoding\n\n return base64url;\n};\n\n/**\n * Add props specifically needed for the type of 3DS2 flow: fingerprint or challenge\n *\n * @param actionSubtype - 3DS2 flow type: fingerprint or challenge\n * @param props - object from which to extract particular properties\n */\nexport const get3DS2FlowProps = (actionSubtype: string, props: ThreeDS2ActionProps): ThreeDS2FlowProps => {\n if (actionSubtype === 'fingerprint') {\n return {\n showSpinner: !props.isDropin,\n statusType: 'loading',\n // elementRef exists when the fingerprint component is created from the Dropin\n ...(props.elementRef && { elementRef: props.elementRef })\n };\n }\n\n // Challenge\n return {\n statusType: 'custom',\n i18n: props.i18n,\n elementRef: props.elementRef\n };\n};\n"],"names":["isErrorObject","obj","success","decodeAndParseToken","token","decodedToken","base64","decode","JSON","parse","data","e","error","encodeObject","Object","keys","length","Error","encode","stringify","validateChallengeWindowSize","sizeStr","sizeString","prototype","hasOwnProperty","call","CHALLENGE_WINDOW_SIZES","DEFAULT_CHALLENGE_WINDOW_SIZE","getChallengeWindowSize","prepareChallengeData","size","decodedChallengeToken","acsTransID","acsURL","messageVersion","threeDSNotificationURL","threeDSServerTransID","notificationURLOrigin","getOrigin","cReqData","messageType","challengeWindowSize","iframeSizeArr","postMessageDomain","prepareFingerPrintData","notificationURL","decodedFingerPrintToken","threeDSMethodNotificationURL","threeDSMethodUrl","threeDSMethodURL","receivedNotificationURL","createFingerprintResolveData","dataKey","resultObj","paymentData","threeDSCompInd","createOldFingerprintResolveData","details","createChallengeResolveData","transStatus","authorisationToken","createOldChallengeResolveData","encodeBase64URL","dataStr","base64url","window","btoa","split","replace","get3DS2FlowProps","actionSubtype","props","showSpinner","isDropin","statusType","elementRef","i18n"],"mappings":"4LAoBO,MAAMA,EAAiBC,GACnB,YAAaA,IAAQA,EAAIC,QAGvBC,EAAuBC,IAChC,MAAMC,EAA6BC,EAAOC,OAAOH,GACjD,GAAIC,EAAaH,QACb,IACI,OAAOM,KAAKC,MAAM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,CAACN,EAAiBO,EAAqBC,MAC7ElD,KAAM,CACF+C,QAAS,CAAEL,CAACA,GAAUvC,EAAa,CAAE8C,cAAaC,2BAK7CC,EAAgC,CAACT,EAAiBO,EAAqBC,MAChFlD,KAAM,CACF+C,QAAS,CAAE,2BAA4B5C,EAAa,CAAE8C,iBACtDL,YAAaM,KAoBRE,EAAmBC,IAE5B,IAAIC,EADeC,OAAOC,KAAKH,GACJI,MAAM,KAAK,GAKtC,OAHAH,EAAYA,EAAUI,QAAQ,MAAO,KACrCJ,EAAYA,EAAUI,QAAQ,MAAO,KAE9BJ,GASEK,EAAmB,CAACC,EAAuBC,IAC9B,gBAAlBD,EACO,CACHE,aAAcD,EAAME,SACpBC,WAAY,aAERH,EAAMI,YAAc,CAAEA,WAAYJ,EAAMI,aAK7C,CACHD,WAAY,SACZE,KAAML,EAAMK,KACZD,WAAYJ,EAAMI"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/ThreeDS2/components/utils.ts"],"sourcesContent":["import { CHALLENGE_WINDOW_SIZES, DEFAULT_CHALLENGE_WINDOW_SIZE } from '../constants';\nimport { getOrigin } from '../../../utils/getOrigin';\nimport base64 from '../../../utils/base64';\nimport type {\n ChallengeData,\n ThreeDS2Token,\n FingerPrintData,\n ResultObject,\n FingerprintResolveData,\n ChallengeResolveData,\n ThreeDS2FlowProps,\n ThreeDS2ActionProps\n} from '../types';\nimport type { DecodeObject } from '../../../types/global-types';\nimport type { ErrorObject } from '../../../core/Errors/types';\n\n/**\n * Check if we have been passed an ErrorObject because either base64 decoding or JSON.parse failed\n * @param obj -\n */\nexport const isErrorObject = (obj: ErrorObject | ThreeDS2Token): boolean => {\n return 'success' in obj && !obj.success;\n};\n\nexport const decodeAndParseToken = (token: string): ThreeDS2Token | ErrorObject => {\n const decodedToken: DecodeObject = base64.decode(token);\n if (decodedToken.success) {\n try {\n return JSON.parse(decodedToken.data) as ThreeDS2Token;\n } catch (e) {\n return {\n success: false,\n error: 'Could not JSON parse token'\n };\n }\n }\n\n // base64.decode failed - object will contain error msg: 'not base64' or 'malformed URI sequence'\n return decodedToken as ErrorObject;\n};\n\n/**\n * Performs JSON.stringify on passed object & and base64 encodes result\n * @param obj -\n * @returns encoded result\n */\nexport const encodeObject = obj => {\n if (!obj || !Object.keys(obj).length) {\n throw new Error('No (populated) data object to encode');\n }\n return base64.encode(JSON.stringify(obj));\n};\n\n/**\n * Accepts a size string for the challenge window & returns it if it is valid else returns a default value\n * @param sizeStr - the size string to check the validity of\n * @returns a valid size string\n */\nexport const validateChallengeWindowSize = (sizeStr: string): string => {\n const sizeString = sizeStr.length === 1 ? `0${sizeStr}` : sizeStr;\n const hasSize = Object.prototype.hasOwnProperty.call(CHALLENGE_WINDOW_SIZES, sizeString);\n return hasSize ? sizeString : DEFAULT_CHALLENGE_WINDOW_SIZE;\n};\n\n/**\n * Accepts a size string for the challenge window & returns the corresponding array of w/h values\n * @param sizeStr -\n */\nexport const getChallengeWindowSize = (sizeStr: string): string[] => CHALLENGE_WINDOW_SIZES[validateChallengeWindowSize(sizeStr)];\n\n/**\n * prepareChallengeData\n *\n * Requires an object containing the challenge parameters:\n * @param token - challengeToken string received from /submitThreeDS2Fingerprint, /details or /payments call: contains acsTransID, acsURL, messageVersion,\n * threeDSNotificationURL and threeDSServerTransID\n * @param size - one of five possible challenge window sizes\n */\nexport const prepareChallengeData = ({ token, size }): ChallengeData | ErrorObject => {\n const decodedChallengeToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedChallengeToken)) {\n return decodedChallengeToken as ErrorObject;\n }\n\n const { acsTransID, acsURL, messageVersion, threeDSNotificationURL, threeDSServerTransID } = decodedChallengeToken as ThreeDS2Token;\n const notificationURLOrigin = getOrigin(threeDSNotificationURL);\n\n return {\n acsURL,\n cReqData: {\n acsTransID,\n messageVersion,\n threeDSServerTransID,\n messageType: 'CReq',\n challengeWindowSize: validateChallengeWindowSize(size)\n },\n iframeSizeArr: getChallengeWindowSize(size),\n postMessageDomain: notificationURLOrigin\n } as ChallengeData;\n};\n\n/**\n * prepareFingerPrintData\n *\n * Requires an object containing the fingerprint parameters:\n * @param token - fingerprintToken string received from /payments call: contains threeDSMethodNotificationURL, threeDSMethodUrl and\n * threeDSServerTransID\n * @param notificationURL - the URL that the final notification is expected to be postMessaged from.\n *\n * NOTE: we don't expect merchants to alter the default by passing in a notificationURL of their own via props;\n * and if 3DS2 is being done via createFromAction or handleAction we won't accept it.\n * But if the merchant is using checkout.create('threeDS2DeviceFingerprint') we still support the fact that they might want to set their own\n * notificationURL (aka threeDSMethodNotificationURL)\n */\nexport const prepareFingerPrintData = ({ token, notificationURL }): FingerPrintData | ErrorObject => {\n const decodedFingerPrintToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedFingerPrintToken)) {\n return decodedFingerPrintToken as ErrorObject;\n }\n\n const { threeDSMethodNotificationURL, threeDSMethodUrl: threeDSMethodURL, threeDSServerTransID } = decodedFingerPrintToken as ThreeDS2Token;\n const receivedNotificationURL = notificationURL || threeDSMethodNotificationURL;\n const notificationURLOrigin = getOrigin(receivedNotificationURL);\n\n return {\n threeDSServerTransID,\n threeDSMethodURL,\n threeDSMethodNotificationURL: receivedNotificationURL,\n postMessageDomain: notificationURLOrigin\n } as FingerPrintData;\n};\n\nexport const createFingerprintResolveData = (dataKey: string, resultObj: ResultObject, paymentData: string): FingerprintResolveData => ({\n data: {\n [dataKey]: encodeObject({ threeDSCompInd: resultObj.threeDSCompInd }),\n paymentData\n }\n});\n\nexport const createChallengeResolveData = (dataKey: string, transStatus: string, authorisationToken: string): ChallengeResolveData => ({\n data: {\n details: { [dataKey]: encodeObject({ transStatus, authorisationToken }) }\n }\n});\n\n/**\n *\n * Takes a string and encodes it as a base64url string\n * (https://en.wikipedia.org/wiki/Base64#URL_applications)\n * (See also https://tools.ietf.org/html/rfc7515)\n *\n * @example\n * ```\n * const jsonStr = JSON.stringify( {name:'john', surname:'smith'} );\n * const base64url = encodeBase64URL(jsonStr);\n * ```\n *\n * @param dataStr - data, as a string, to be encoded\n *\n * @returns base64URL - a base64url encoded string\n */\nexport const encodeBase64URL = (dataStr: string): string => {\n const base64Data = window.btoa(dataStr);\n let base64url = base64Data.split('=')[0]; // Remove any trailing '='s\n\n base64url = base64url.replace(/\\+/g, '-'); // 62nd char of encoding\n base64url = base64url.replace(/\\//g, '_'); // 63rd char of encoding\n\n return base64url;\n};\n\n/**\n * Add props specifically needed for the type of 3DS2 flow: fingerprint or challenge\n *\n * @param actionSubtype - 3DS2 flow type: fingerprint or challenge\n * @param props - object from which to extract particular properties\n */\nexport const get3DS2FlowProps = (actionSubtype: string, props: ThreeDS2ActionProps): ThreeDS2FlowProps => {\n if (actionSubtype === 'fingerprint') {\n return {\n showSpinner: !props.isDropin,\n statusType: 'loading',\n // elementRef exists when the fingerprint component is created from the Dropin\n ...(props.elementRef && { elementRef: props.elementRef })\n };\n }\n\n // Challenge\n return {\n statusType: 'custom',\n i18n: props.i18n,\n elementRef: props.elementRef\n };\n};\n"],"names":["isErrorObject","obj","success","decodeAndParseToken","token","decodedToken","base64","decode","JSON","parse","data","e","error","encodeObject","Object","keys","length","Error","encode","stringify","validateChallengeWindowSize","sizeStr","sizeString","prototype","hasOwnProperty","call","CHALLENGE_WINDOW_SIZES","DEFAULT_CHALLENGE_WINDOW_SIZE","getChallengeWindowSize","prepareChallengeData","size","decodedChallengeToken","acsTransID","acsURL","messageVersion","threeDSNotificationURL","threeDSServerTransID","notificationURLOrigin","getOrigin","cReqData","messageType","challengeWindowSize","iframeSizeArr","postMessageDomain","prepareFingerPrintData","notificationURL","decodedFingerPrintToken","threeDSMethodNotificationURL","threeDSMethodUrl","threeDSMethodURL","receivedNotificationURL","createFingerprintResolveData","dataKey","resultObj","paymentData","threeDSCompInd","createChallengeResolveData","transStatus","authorisationToken","details","encodeBase64URL","dataStr","base64url","window","btoa","split","replace","get3DS2FlowProps","actionSubtype","props","showSpinner","isDropin","statusType","elementRef","i18n"],"mappings":"4LAoBO,MAAMA,EAAiBC,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,EAAUE,iBACpDD,iBAIKE,EAA6B,CAACJ,EAAiBK,EAAqBC,MAC7EhD,KAAM,CACFiD,QAAS,CAAEP,CAACA,GAAUvC,EAAa,CAAE4C,cAAaC,2BAoB7CE,EAAmBC,IAE5B,IAAIC,EADeC,OAAOC,KAAKH,GACJI,MAAM,KAAK,GAKtC,OAHAH,EAAYA,EAAUI,QAAQ,MAAO,KACrCJ,EAAYA,EAAUI,QAAQ,MAAO,KAE9BJ,GASEK,EAAmB,CAACC,EAAuBC,IAC9B,gBAAlBD,EACO,CACHE,aAAcD,EAAME,SACpBC,WAAY,aAERH,EAAMI,YAAc,CAAEA,WAAYJ,EAAMI,aAK7C,CACHD,WAAY,SACZE,KAAML,EAAMK,KACZD,WAAYJ,EAAMI"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{Await as n}from"../internal/Await/Await.js";import{QRLoader as s}from"../internal/QRLoader/QRLoader.js";import"../../core/Context/CoreProvider.js";import"../../external/preact/hooks/dist/hooks.js";import"../../core/Errors/SRPanelContext.js";import"../internal/Button/Button.js";import"../internal/QRLoader/QRLoaderDetailsProvider.js";import{TxVariants as i}from"../tx-variants.js";import r from"../../utils/isMobile.js";import{UPI_MODE as a,UPI_COUNTDOWN_TIME as p}from"./constants.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d extends e{formatProps(t){return{showOtherInsteadOfNumber:!r(),...t}}get isValid(){return this.state.isValid}formatData(){const{app:t}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===i.upi_intent&&t?.id&&{appId:t.id}}}}get brands(){const{showPaymentMethodItemImages:t}=this.props;return t?this.appsList.map(t=>({icon:t.icon,name:t.name})):[]}get paymentType(){return this.mode===a.QR_CODE?i.upi_qr:i.upi_intent}componentToRender(){const{type:e,url:r,paymentMethodType:a}=this.props,p=!!this.props.mandate;switch(e){case"qrCode":return t(s,{...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:i.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:this.props.countdownTime,onActionHandled:this.onActionHandled,showAmount:!p});case"await":return t(n,{url:r,type:a,showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!p,countdownTime:this.props.countdownTime,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n.get("upi.vpaWaitingMessage"),awaitText:this.props.i18n.get("await.waitForConfirmation"),onComplete:this.onComplete,brandLogo:this.icon});default:return t(o,{setComponentRef:this.setComponentRef,payButton:this.payButton,onChange:this.setState,appsList:this.appsList,mode:this.mode,showPayButton:this.props.showPayButton,mandate:this.props.mandate})}}constructor(t,e){super(t,e),m(this,"mode",void 0),m(this,"appsList",void 0);const{apps:o=[]}=this.props,n=o.length>0;this.mode=r()&&n?a.INTENT:a.QR_CODE,this.appsList=o.map(t=>{const e=`upi/${t.id.toLowerCase()}`,o=this.core.modules.resources?.getImage()(e);return{id:t.id,name:t.name,icon:o}})}}m(d,"type",i.upi),m(d,"txVariants",[i.upi,i.upi_qr,i.upi_intent]),m(d,"defaultProps",{showPaymentMethodItemImages:!0,countdownTime:p});export{d as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{Await as n}from"../internal/Await/Await.js";import{QRLoader as i}from"../internal/QRLoader/QRLoader.js";import"../../core/Context/CoreProvider.js";import"../../external/preact/hooks/dist/hooks.js";import"../../core/Errors/SRPanelContext.js";import"../internal/Button/Button.js";import"../internal/QRLoader/QRLoaderDetailsProvider.js";import{TxVariants as s}from"../tx-variants.js";import r from"../../utils/isMobile.js";import{UPI_MODE as a,UPI_COUNTDOWN_TIME as p}from"./constants.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d extends e{formatProps(t){return{showOtherInsteadOfNumber:!r(),...t}}get isValid(){return this.state.isValid}formatData(){const{app:t}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===s.upi_intent&&t?.id&&{appId:t.id}}}}get brands(){const{showPaymentMethodItemImages:t}=this.props;return t?this.appsList.map(t=>({icon:t.icon,name:t.name})):[]}get paymentType(){return this.mode===a.QR_CODE?s.upi_qr:s.upi_intent}componentToRender(){const{type:e,url:r,paymentMethodType:a}=this.props,p=!!this.props.mandate;switch(e){case"qrCode":return t(i,{...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):void 0,type:s.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n?.get("upi.qrCodeWaitingMessage")??"",countdownTime:this.props.countdownTime,onActionHandled:this.onActionHandled,showAmount:!p});case"await":return t(n,{url:r,type:a??"",showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!p,countdownTime:this.props.countdownTime,clientKey:this.props.clientKey??"",paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n?.get("upi.vpaWaitingMessage")??"",awaitText:this.props.i18n?.get("await.waitForConfirmation")??"",onComplete:this.onComplete,brandLogo:this.icon});default:return t(o,{setComponentRef:this.setComponentRef,payButton:this.payButton,onChange:this.setState,appsList:this.appsList,mode:this.mode,showPayButton:this.props.showPayButton??!0,mandate:this.props.mandate,onSubmitAnalytics:this.submitAnalytics})}}constructor(t,e){super(t,e),m(this,"mode",void 0),m(this,"appsList",void 0);const{apps:o=[]}=this.props,n=o.length>0;this.mode=r()&&n?a.INTENT:a.QR_CODE,this.appsList=o.map(t=>{const e=`upi/${t.id.toLowerCase()}`,o=this.core.modules.resources?.getImage()(e)??"";return{id:t.id,name:t.name,icon:o}})}}m(d,"type",s.upi),m(d,"txVariants",[s.upi,s.upi_qr,s.upi_intent]),m(d,"defaultProps",{showPaymentMethodItemImages:!0,countdownTime:p});export{d as default};
2
2
  //# sourceMappingURL=UPI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { Await } from '../internal/Await';\nimport { QRLoader } from '../internal/QRLoader';\nimport { UPIAppList, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport { UPI_COUNTDOWN_TIME, UPI_MODE } from './constants';\nimport { PaymentMethodBrand } from '../../types/global-types';\nimport { ICore } from '../../types';\n\n/**\n * For mobile:\n * We should show upi_intent depending on if `apps` are returned in /paymentMethods response.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * Show upi_qr as default\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static readonly type = TxVariants.upi;\n public static readonly txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_intent];\n private readonly mode: UpiMode;\n private readonly appsList: UPIAppList;\n\n protected static readonly defaultProps = {\n showPaymentMethodItemImages: true,\n countdownTime: UPI_COUNTDOWN_TIME\n };\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n const { apps = [] } = this.props;\n const hasIntentApps = apps.length > 0;\n\n this.mode = isMobile() && hasIntentApps ? UPI_MODE.INTENT : UPI_MODE.QR_CODE;\n\n this.appsList = apps.map(app => {\n const imageName = `upi/${app.id.toLowerCase()}`;\n const brandIcon = this.core.modules.resources?.getImage()(imageName);\n return { id: app.id, name: app.name, icon: brandIcon };\n });\n }\n\n protected formatProps(props: UPIConfiguration): UPIConfiguration {\n return {\n showOtherInsteadOfNumber: !isMobile(),\n ...props\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get brands(): PaymentMethodBrand[] {\n const { showPaymentMethodItemImages } = this.props;\n\n if (!showPaymentMethodItemImages) {\n return [];\n }\n\n return this.appsList.map(app => ({ icon: app.icon, name: app.name }));\n }\n\n get paymentType(): UpiType {\n if (this.mode === UPI_MODE.QR_CODE) {\n return TxVariants.upi_qr;\n }\n return TxVariants.upi_intent;\n }\n\n protected override componentToRender(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={this.props.countdownTime}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n setComponentRef={this.setComponentRef}\n payButton={this.payButton}\n onChange={this.setState}\n appsList={this.appsList}\n mode={this.mode}\n showPayButton={this.props.showPayButton}\n mandate={this.props.mandate}\n />\n );\n }\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","showOtherInsteadOfNumber","isMobile","isValid","this","state","formatData","app","data","paymentMethod","type","paymentType","TxVariants","upi_intent","id","appId","brands","showPaymentMethodItemImages","appsList","map","icon","name","mode","UPI_MODE","QR_CODE","upi_qr","componentToRender","url","paymentMethodType","isAutoPay","mandate","h","QRLoader","qrCodeData","encodeURIComponent","brandLogo","onComplete","introduction","i18n","get","countdownTime","onActionHandled","showAmount","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","setComponentRef","payButton","onChange","setState","showPayButton","constructor","checkout","super","_define_property","apps","hasIntentApps","length","INTENT","imageName","toLowerCase","brandIcon","core","modules","resources","getImage","upi","txVariants","defaultProps","UPI_COUNTDOWN_TIME"],"mappings":"kyBAqBA,MAAMA,UAAYC,EAyBJC,WAAAA,CAAYC,GAClB,MAAO,CACHC,0BAA2BC,OACxBF,EAEX,CAEA,WAAWG,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,IAAEA,GAAQH,KAAKC,MAAMG,MAAQ,CAAA,EAEnC,MAAO,CACHC,cAAe,CACXC,KAAMN,KAAKO,eACPP,KAAKO,cAAgBC,EAAWC,YAAcN,GAAKO,IAAM,CAAEC,MAAOR,EAAIO,KAGtF,CAEA,UAAIE,GACA,MAAMC,4BAAEA,GAAgCb,KAAKJ,MAE7C,OAAKiB,EAIEb,KAAKc,SAASC,IAAIZ,KAAUa,KAAMb,EAAIa,KAAMC,KAAMd,EAAIc,QAHlD,EAIf,CAEA,eAAIV,GACA,OAAIP,KAAKkB,OAASC,EAASC,QAChBZ,EAAWa,OAEfb,EAAWC,UACtB,CAEmBa,iBAAAA,GACf,MAAMhB,KAAEA,EAAIiB,IAAEA,EAAGC,kBAAEA,GAAsBxB,KAAKJ,MAExC6B,IAAczB,KAAKJ,MAAM8B,QAE/B,OAAQpB,GACJ,IAAK,SACD,OACIqB,EAACC,EAAAA,IACO5B,KAAKJ,MACTiC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D,EAAY,OAAO1D,EAAIO,GAAGoD,gBAC1BC,EAAY/D,KAAKgE,KAAKC,QAAQC,WAAWC,UAA7BnE,CAAwC6D,GAC1D,MAAO,CAAEnD,GAAIP,EAAIO,GAAIO,KAAMd,EAAIc,KAAMD,KAAM+C,IAEnD,EAtBAP,EADE/D,EACqBa,OAAOE,EAAW4D,KACzCZ,EAFE/D,EAEqB4E,aAAa,CAAC7D,EAAW4D,IAAK5D,EAAWa,OAAQb,EAAWC,aAInF+C,EANE/D,EAMwB6E,eAAe,CACrCzD,6BAA6B,EAC7BuB,cAAemC"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { Await } from '../internal/Await';\nimport { QRLoader } from '../internal/QRLoader';\nimport { UPIAppList, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport { UPI_COUNTDOWN_TIME, UPI_MODE } from './constants';\nimport { PaymentMethodBrand } from '../../types/global-types';\nimport { ICore } from '../../types';\n\n/**\n * For mobile:\n * We should show upi_intent depending on if `apps` are returned in /paymentMethods response.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * Show upi_qr as default\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static readonly type = TxVariants.upi;\n public static readonly txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_intent];\n private readonly mode: UpiMode;\n private readonly appsList: UPIAppList;\n\n protected static readonly defaultProps = {\n showPaymentMethodItemImages: true,\n countdownTime: UPI_COUNTDOWN_TIME\n };\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n const { apps = [] } = this.props;\n const hasIntentApps = apps.length > 0;\n\n this.mode = isMobile() && hasIntentApps ? UPI_MODE.INTENT : UPI_MODE.QR_CODE;\n\n this.appsList = apps.map(app => {\n const imageName = `upi/${app.id.toLowerCase()}`;\n const brandIcon = this.core.modules.resources?.getImage()(imageName) ?? '';\n return { id: app.id, name: app.name, icon: brandIcon };\n });\n }\n\n protected formatProps(props: UPIConfiguration): UPIConfiguration {\n return {\n showOtherInsteadOfNumber: !isMobile(),\n ...props\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get brands(): PaymentMethodBrand[] {\n const { showPaymentMethodItemImages } = this.props;\n\n if (!showPaymentMethodItemImages) {\n return [];\n }\n\n return this.appsList.map(app => ({ icon: app.icon, name: app.name }));\n }\n\n get paymentType(): UpiType {\n if (this.mode === UPI_MODE.QR_CODE) {\n return TxVariants.upi_qr;\n }\n return TxVariants.upi_intent;\n }\n\n protected override componentToRender(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : undefined}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n?.get('upi.qrCodeWaitingMessage') ?? ''}\n countdownTime={this.props.countdownTime}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType ?? ''}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime}\n clientKey={this.props.clientKey ?? ''}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n?.get('upi.vpaWaitingMessage') ?? ''}\n awaitText={this.props.i18n?.get('await.waitForConfirmation') ?? ''}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n setComponentRef={this.setComponentRef}\n payButton={this.payButton}\n onChange={this.setState}\n appsList={this.appsList}\n mode={this.mode}\n showPayButton={this.props.showPayButton ?? true}\n mandate={this.props.mandate}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","showOtherInsteadOfNumber","isMobile","isValid","this","state","formatData","app","data","paymentMethod","type","paymentType","TxVariants","upi_intent","id","appId","brands","showPaymentMethodItemImages","appsList","map","icon","name","mode","UPI_MODE","QR_CODE","upi_qr","componentToRender","url","paymentMethodType","isAutoPay","mandate","h","QRLoader","qrCodeData","encodeURIComponent","undefined","brandLogo","onComplete","introduction","i18n","get","countdownTime","onActionHandled","showAmount","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","setComponentRef","payButton","onChange","setState","showPayButton","onSubmitAnalytics","submitAnalytics","constructor","checkout","super","_define_property","apps","hasIntentApps","length","INTENT","imageName","toLowerCase","brandIcon","core","modules","resources","getImage","upi","txVariants","defaultProps","UPI_COUNTDOWN_TIME"],"mappings":"kyBAqBA,MAAMA,UAAYC,EAyBJC,WAAAA,CAAYC,GAClB,MAAO,CACHC,0BAA2BC,OACxBF,EAEX,CAEA,WAAWG,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,IAAEA,GAAQH,KAAKC,MAAMG,MAAQ,CAAA,EAEnC,MAAO,CACHC,cAAe,CACXC,KAAMN,KAAKO,eACPP,KAAKO,cAAgBC,EAAWC,YAAcN,GAAKO,IAAM,CAAEC,MAAOR,EAAIO,KAGtF,CAEA,UAAIE,GACA,MAAMC,4BAAEA,GAAgCb,KAAKJ,MAE7C,OAAKiB,EAIEb,KAAKc,SAASC,IAAIZ,KAAUa,KAAMb,EAAIa,KAAMC,KAAMd,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