@coras-io/embed 0.5.1 → 0.6.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 (373) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +15 -2
  3. package/dist/components/accordion/accordion-item/accordion-item.component.js +9 -3
  4. package/dist/components/accordion/accordion-item/accordion-item.styles.js +4 -0
  5. package/dist/components/accordion/accordion.component.js +8 -0
  6. package/dist/components/alert/alert.component.d.ts +1 -1
  7. package/dist/components/alert/alert.component.js +4 -3
  8. package/dist/components/attraction-card/base/attraction-card.mixin.d.ts +0 -2
  9. package/dist/components/attraction-card/base/attraction-card.mixin.js +0 -6
  10. package/dist/components/attraction-card/base/attraction-card.types.d.ts +0 -1
  11. package/dist/components/basket-mobile/basket-mobile.component.d.ts +14 -3
  12. package/dist/components/basket-mobile/basket-mobile.component.js +71 -15
  13. package/dist/components/better-carousel/better-carousel.component.d.ts +3 -5
  14. package/dist/components/better-carousel/better-carousel.component.js +13 -34
  15. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +5 -12
  16. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +13 -5
  17. package/dist/components/breadcrumbs/breadcrumbs.component.d.ts +0 -1
  18. package/dist/components/breadcrumbs/breadcrumbs.component.js +5 -8
  19. package/dist/components/breadcrumbs/breadcrumbs.styles.js +8 -2
  20. package/dist/components/button/button.constants.d.ts +1 -2
  21. package/dist/components/button/button.constants.js +0 -1
  22. package/dist/components/calendar/base/calendar.mixin.js +5 -1
  23. package/dist/components/calendar/multi/multi.component.d.ts +2 -2
  24. package/dist/components/calendar/multi/multi.component.js +12 -19
  25. package/dist/components/carousel/carousel.component.js +9 -2
  26. package/dist/components/categories-tree/categories-tree.component.d.ts +5 -3
  27. package/dist/components/categories-tree/categories-tree.component.js +22 -21
  28. package/dist/components/checkbox/checkbox.component.js +5 -1
  29. package/dist/components/checkbox-group/checkbox-group.component.js +1 -1
  30. package/dist/components/checkbox-group/checkbox-group.styles.js +1 -1
  31. package/dist/components/chip/chip.component.js +8 -3
  32. package/dist/components/crypto-auth-modal/crypto-auth-modal.component.d.ts +6 -0
  33. package/dist/components/crypto-auth-modal/crypto-auth-modal.component.js +15 -1
  34. package/dist/components/currencies-list/currencies-list.component.js +0 -1
  35. package/dist/components/dialog/dialog.component.js +52 -21
  36. package/dist/components/drawer/drawer.component.d.ts +3 -2
  37. package/dist/components/drawer/drawer.component.js +13 -18
  38. package/dist/components/drawer/drawer.styles.js +5 -2
  39. package/dist/components/dropdown/dropdown.component.js +6 -9
  40. package/dist/components/expiration-timer/expiration-timer.component.d.ts +2 -3
  41. package/dist/components/expiration-timer/expiration-timer.component.js +10 -8
  42. package/dist/components/explore-card/explore-card.component.js +3 -1
  43. package/dist/components/explore-card/explore-card.styles.js +31 -0
  44. package/dist/components/filters-drawer/filters-drawer.component.js +1 -1
  45. package/dist/components/flag-icon/flag-icon.component.d.ts +4 -2
  46. package/dist/components/flag-icon/flag-icon.component.js +16 -4
  47. package/dist/components/icon/icon.component.js +15 -2
  48. package/dist/components/image/image.component.js +4 -3
  49. package/dist/components/image-viewer/image-viewer.component.js +6 -4
  50. package/dist/components/input-field/input-field.component.js +10 -6
  51. package/dist/components/layout/layout.styles.js +1 -1
  52. package/dist/components/locales-list/locales-list.component.js +0 -1
  53. package/dist/components/location-image/location-image.component.js +0 -1
  54. package/dist/components/locations-results/locations-results.component.d.ts +10 -0
  55. package/dist/components/locations-results/locations-results.component.js +22 -15
  56. package/dist/components/locations-results/locations-results.styles.js +4 -1
  57. package/dist/components/message-card/message-card.component.d.ts +1 -1
  58. package/dist/components/message-card/message-card.component.js +4 -3
  59. package/dist/components/mobile-menu-item/mobile-menu-item.component.d.ts +0 -1
  60. package/dist/components/mobile-menu-item/mobile-menu-item.component.js +14 -16
  61. package/dist/components/mobile-menu-item/mobile-menu-item.styles.js +9 -5
  62. package/dist/components/option-group/option-chip/option-chip.component.d.ts +4 -1
  63. package/dist/components/option-group/option-chip/option-chip.component.js +23 -10
  64. package/dist/components/option-group/option-group.component.d.ts +3 -1
  65. package/dist/components/option-group/option-group.component.js +10 -3
  66. package/dist/components/overlay/overlay.component.d.ts +0 -5
  67. package/dist/components/overlay/overlay.component.js +3 -15
  68. package/dist/components/phone-country-code/phone-country-code.component.d.ts +4 -0
  69. package/dist/components/phone-country-code/phone-country-code.component.js +37 -0
  70. package/dist/components/phone-country-codes/phone-country-codes.component.js +1 -1
  71. package/dist/components/phone-field/phone-field.component.js +2 -2
  72. package/dist/components/search-button/search-button.component.d.ts +1 -1
  73. package/dist/components/search-button/search-button.component.js +13 -7
  74. package/dist/components/seated-selector/seated-selector.component.js +3 -3
  75. package/dist/components/seats-io/seats-io.component.d.ts +3 -2
  76. package/dist/components/seats-io/seats-io.component.js +31 -13
  77. package/dist/components/seats-io/seats-io.constants.d.ts +0 -2
  78. package/dist/components/seats-io/seats-io.constants.js +0 -3
  79. package/dist/components/seats-io/seats-io.transform.d.ts +1 -6
  80. package/dist/components/seats-io/seats-io.transform.js +1 -20
  81. package/dist/components/select-list/select-list.component.js +7 -2
  82. package/dist/components/select-list/select-option/select-option.component.d.ts +3 -1
  83. package/dist/components/select-list/select-option/select-option.component.js +10 -3
  84. package/dist/components/tabs/tabs.component.d.ts +2 -0
  85. package/dist/components/tabs/tabs.component.js +59 -5
  86. package/dist/components/time-tag/time-tag.component.js +1 -1
  87. package/dist/containers/basket/basket.component.d.ts +1 -1
  88. package/dist/containers/basket/basket.component.js +21 -20
  89. package/dist/containers/navbar/navbar.component.d.ts +12 -8
  90. package/dist/containers/navbar/navbar.component.js +108 -62
  91. package/dist/containers/navbar/navbar.styles.js +23 -5
  92. package/dist/containers/navbar/navbar.utils.js +4 -4
  93. package/dist/contexts/basket/basket.provider.d.ts +3 -4
  94. package/dist/contexts/basket/basket.provider.js +46 -61
  95. package/dist/contexts/basket/basket.types.d.ts +0 -2
  96. package/dist/controllers/time-expiration.d.ts +15 -2
  97. package/dist/controllers/time-expiration.js +47 -17
  98. package/dist/core/api/client.d.ts +9 -0
  99. package/dist/core/api/client.js +26 -0
  100. package/dist/core/api/middlewares/booking-session/booking-session.constants.d.ts +0 -2
  101. package/dist/core/api/middlewares/booking-session/booking-session.constants.js +0 -2
  102. package/dist/core/api/middlewares/booking-session/booking-session.js +3 -12
  103. package/dist/core/api/middlewares/booking-session/booking-session.utils.d.ts +0 -1
  104. package/dist/core/api/middlewares/booking-session/booking-session.utils.js +6 -28
  105. package/dist/core/api/middlewares/error-handler/error-handler.js +5 -1
  106. package/dist/core/api/middlewares/retry/retry.constants.d.ts +3 -0
  107. package/dist/core/api/middlewares/retry/retry.constants.js +7 -0
  108. package/dist/core/api/middlewares/retry/retry.d.ts +2 -0
  109. package/dist/core/api/middlewares/retry/retry.js +48 -0
  110. package/dist/core/api/queries.d.ts +13 -38
  111. package/dist/core/api/queries.js +16 -99
  112. package/dist/core/events.d.ts +2 -4
  113. package/dist/core/i18n/date.d.ts +14 -5
  114. package/dist/core/i18n/date.js +47 -20
  115. package/dist/core/i18n/localization.js +10 -3
  116. package/dist/core/images/helpers.js +6 -5
  117. package/dist/core/logger.d.ts +17 -0
  118. package/dist/core/logger.js +13 -0
  119. package/dist/core/types/api-schema.d.ts +7872 -0
  120. package/dist/core/types/seats-config.d.ts +5 -4
  121. package/dist/core/types/seats-config.js +10 -3
  122. package/dist/core/utils/crypto-address.d.ts +12 -0
  123. package/dist/core/utils/crypto-address.js +17 -0
  124. package/dist/core/utils/datetime.d.ts +13 -11
  125. package/dist/core/utils/datetime.js +41 -51
  126. package/dist/core/utils/loyalty.d.ts +8 -0
  127. package/dist/core/utils/loyalty.js +10 -0
  128. package/dist/core/utils/redaction.d.ts +9 -0
  129. package/dist/core/utils/redaction.js +58 -0
  130. package/dist/core/utils/time.js +2 -3
  131. package/dist/helpers/helpers.d.ts +6 -0
  132. package/dist/helpers/helpers.js +33 -16
  133. package/dist/locales/ar-SA.d.ts +38 -21
  134. package/dist/locales/ar-SA.js +38 -21
  135. package/dist/locales/da-DK.d.ts +38 -21
  136. package/dist/locales/da-DK.js +38 -21
  137. package/dist/locales/de-DE.d.ts +38 -21
  138. package/dist/locales/de-DE.js +38 -21
  139. package/dist/locales/en-IE.d.ts +38 -21
  140. package/dist/locales/en-IE.js +38 -21
  141. package/dist/locales/en-US.d.ts +38 -21
  142. package/dist/locales/en-US.js +38 -21
  143. package/dist/locales/es-ES.d.ts +38 -21
  144. package/dist/locales/es-ES.js +38 -21
  145. package/dist/locales/fr-FR.d.ts +38 -21
  146. package/dist/locales/fr-FR.js +38 -21
  147. package/dist/locales/fr-MA.d.ts +38 -21
  148. package/dist/locales/fr-MA.js +38 -21
  149. package/dist/locales/is-IS.d.ts +38 -21
  150. package/dist/locales/is-IS.js +38 -21
  151. package/dist/locales/it-IT.d.ts +38 -21
  152. package/dist/locales/it-IT.js +38 -21
  153. package/dist/locales/ms-MY.d.ts +38 -21
  154. package/dist/locales/ms-MY.js +38 -21
  155. package/dist/locales/nb-NO.d.ts +38 -21
  156. package/dist/locales/nb-NO.js +38 -21
  157. package/dist/locales/pl-PL.d.ts +38 -21
  158. package/dist/locales/pl-PL.js +38 -21
  159. package/dist/locales/pt-PT.d.ts +38 -21
  160. package/dist/locales/pt-PT.js +38 -21
  161. package/dist/locales/sv-SE.d.ts +38 -21
  162. package/dist/locales/sv-SE.js +38 -21
  163. package/dist/locales/th-TH.d.ts +38 -21
  164. package/dist/locales/th-TH.js +38 -21
  165. package/dist/locales/tr-TR.d.ts +38 -21
  166. package/dist/locales/tr-TR.js +38 -21
  167. package/dist/locales/zh-CN.d.ts +38 -21
  168. package/dist/locales/zh-CN.js +38 -21
  169. package/dist/locales/zh-HK.d.ts +38 -21
  170. package/dist/locales/zh-HK.js +38 -21
  171. package/dist/mixins/base.mixin.d.ts +3 -1
  172. package/dist/mixins/base.mixin.js +10 -7
  173. package/dist/mixins/coinbase.mixin.d.ts +13 -17
  174. package/dist/mixins/coinbase.mixin.js +251 -288
  175. package/dist/mixins/error-modal.mixin.js +8 -4
  176. package/dist/mixins/location-search/location-search.d.ts +13 -1
  177. package/dist/mixins/location-search/location-search.js +35 -27
  178. package/dist/mixins/overlay/overlay-mixin.js +39 -3
  179. package/dist/mixins/overlay/types.d.ts +1 -0
  180. package/dist/mixins/search-mixin/search-mixin.js +8 -5
  181. package/dist/sdk/diagnostics.js +2 -0
  182. package/dist/sdk/mount.d.ts +10 -0
  183. package/dist/sdk/mount.js +20 -1
  184. package/dist/sdk/page-registry.js +5 -0
  185. package/dist/sdk/params.d.ts +53 -0
  186. package/dist/sdk/params.js +180 -0
  187. package/dist/sdk/redaction.d.ts +1 -4
  188. package/dist/sdk/redaction.js +2 -41
  189. package/dist/sdk/types.d.ts +21 -7
  190. package/dist/sdk/url.d.ts +1 -1
  191. package/dist/sdk/url.js +12 -5
  192. package/dist/sdk/validation.d.ts +1 -26
  193. package/dist/sdk/validation.js +8 -145
  194. package/dist/styles/tokens.d.ts +1 -1
  195. package/dist/styles/tokens.generated.d.ts +1 -1
  196. package/dist/styles/tokens.generated.js +1 -1
  197. package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +30 -0
  198. package/dist/views/chrome-only-page/chrome-only-page.component.js +24 -0
  199. package/dist/views/chrome-only-page/chrome-only-page.d.ts +8 -0
  200. package/dist/views/chrome-only-page/chrome-only-page.js +6 -0
  201. package/dist/views/chrome-only-page/chrome-only-page.styles.js +13 -0
  202. package/dist/views/details-page/details-page.component.d.ts +11 -4
  203. package/dist/views/details-page/details-page.component.js +263 -237
  204. package/dist/views/details-page/details-page.utilts.d.ts +63 -3
  205. package/dist/views/details-page/details-page.utilts.js +53 -5
  206. package/dist/views/details-page/partials/location-categories/location-categories.component.d.ts +29 -0
  207. package/dist/views/details-page/partials/location-categories/location-categories.component.js +149 -0
  208. package/dist/views/details-page/partials/location-categories/location-categories.d.ts +8 -0
  209. package/dist/views/details-page/partials/location-categories/location-categories.js +6 -0
  210. package/dist/views/details-page/partials/location-categories/location-categories.styles.js +35 -0
  211. package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +26 -0
  212. package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +158 -0
  213. package/dist/views/details-page/partials/location-highlights/location-highlights.d.ts +8 -0
  214. package/dist/views/details-page/partials/location-highlights/location-highlights.js +6 -0
  215. package/dist/views/details-page/partials/location-highlights/location-highlights.styles.js +42 -0
  216. package/dist/views/details-page/partials/tour-description/tour-description.component.js +1 -4
  217. package/dist/views/help-page/help-page.component.d.ts +2 -0
  218. package/dist/views/help-page/help-page.component.js +37 -18
  219. package/dist/views/help-page/help-page.utils.js +6 -5
  220. package/dist/views/landing-page/landing-page.component.d.ts +5 -8
  221. package/dist/views/landing-page/landing-page.component.js +82 -97
  222. package/dist/views/payment-page/controllers/crypto-auth.controller.d.ts +10 -4
  223. package/dist/views/payment-page/controllers/crypto-auth.controller.js +53 -31
  224. package/dist/views/payment-page/controllers/crypto-transfer.controller.d.ts +9 -5
  225. package/dist/views/payment-page/controllers/crypto-transfer.controller.js +26 -39
  226. package/dist/views/payment-page/controllers/payment-flow.controller.d.ts +6 -1
  227. package/dist/views/payment-page/controllers/payment-flow.controller.js +1 -0
  228. package/dist/views/payment-page/controllers/stripe-payment.controller.d.ts +20 -2
  229. package/dist/views/payment-page/controllers/stripe-payment.controller.js +42 -19
  230. package/dist/views/payment-page/partials/activity-details/activity-details.component.d.ts +2 -0
  231. package/dist/views/payment-page/partials/activity-details/activity-details.component.js +6 -3
  232. package/dist/views/payment-page/partials/billing-address/billing-address.component.d.ts +2 -0
  233. package/dist/views/payment-page/partials/billing-address/billing-address.component.js +5 -1
  234. package/dist/views/payment-page/partials/confirmation/confirmation.component.js +2 -3
  235. package/dist/views/payment-page/partials/country-field/country-field.component.js +1 -1
  236. package/dist/views/payment-page/partials/payment-type-selector/payment-type-selector.component.js +3 -3
  237. package/dist/views/payment-page/partials/stripe/stripe.component.d.ts +2 -0
  238. package/dist/views/payment-page/partials/stripe/stripe.component.js +36 -7
  239. package/dist/views/payment-page/partials/stripe/stripe.utils.js +0 -3
  240. package/dist/views/payment-page/payment-page.component.d.ts +39 -6
  241. package/dist/views/payment-page/payment-page.component.js +302 -178
  242. package/dist/views/payment-page/payment-page.constants.d.ts +1 -27
  243. package/dist/views/payment-page/payment-page.constants.js +3 -30
  244. package/dist/views/payment-page/payment-page.types.d.ts +1 -19
  245. package/dist/views/payment-page/payment-page.utils.d.ts +22 -13
  246. package/dist/views/payment-page/payment-page.utils.js +57 -75
  247. package/dist/views/payment-page/services/payment-api.service.d.ts +16 -34
  248. package/dist/views/payment-page/services/payment-api.service.js +19 -27
  249. package/dist/views/search-page/search-page.component.d.ts +2 -0
  250. package/dist/views/search-page/search-page.component.js +39 -20
  251. package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +1 -0
  252. package/dist/views/suggestion-widget/suggestion-widget.component.js +6 -5
  253. package/package.json +24 -20
  254. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.component.d.ts +0 -10
  255. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.component.js +0 -43
  256. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.d.ts +0 -8
  257. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.js +0 -6
  258. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.styles.js +0 -23
  259. package/dist/components/attraction-discovery/attraction-discovery.component.d.ts +0 -10
  260. package/dist/components/attraction-discovery/attraction-discovery.component.js +0 -52
  261. package/dist/components/attraction-discovery/attraction-discovery.constants.d.ts +0 -4
  262. package/dist/components/attraction-discovery/attraction-discovery.constants.js +0 -5
  263. package/dist/components/attraction-discovery/attraction-discovery.d.ts +0 -8
  264. package/dist/components/attraction-discovery/attraction-discovery.js +0 -6
  265. package/dist/components/attraction-discovery/attraction-discovery.styles.js +0 -193
  266. package/dist/components/basket-rewards/basket-rewards.component.d.ts +0 -10
  267. package/dist/components/basket-rewards/basket-rewards.component.js +0 -52
  268. package/dist/components/basket-rewards/basket-rewards.d.ts +0 -8
  269. package/dist/components/basket-rewards/basket-rewards.js +0 -6
  270. package/dist/components/basket-rewards/basket-rewards.styles.js +0 -18
  271. package/dist/components/filter-chip/filter-chip.component.d.ts +0 -12
  272. package/dist/components/filter-chip/filter-chip.component.js +0 -68
  273. package/dist/components/filter-chip/filter-chip.constants.d.ts +0 -2
  274. package/dist/components/filter-chip/filter-chip.constants.js +0 -2
  275. package/dist/components/filter-chip/filter-chip.d.ts +0 -8
  276. package/dist/components/filter-chip/filter-chip.js +0 -6
  277. package/dist/components/filter-chip/filter-chip.styles.d.ts +0 -2
  278. package/dist/components/filter-chip/filter-chip.styles.js +0 -162
  279. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.component.d.ts +0 -10
  280. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.component.js +0 -43
  281. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.d.ts +0 -8
  282. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.js +0 -6
  283. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.styles.d.ts +0 -2
  284. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.styles.js +0 -28
  285. package/dist/components/image-carousel/image-carousel.component.d.ts +0 -8
  286. package/dist/components/image-carousel/image-carousel.component.js +0 -36
  287. package/dist/components/image-carousel/image-carousel.d.ts +0 -8
  288. package/dist/components/image-carousel/image-carousel.js +0 -6
  289. package/dist/components/image-carousel/image-carousel.styles.d.ts +0 -2
  290. package/dist/components/image-carousel/image-carousel.styles.js +0 -72
  291. package/dist/components/itinerary/itinerary-item/itinerary-item.component.d.ts +0 -9
  292. package/dist/components/itinerary/itinerary-item/itinerary-item.component.js +0 -45
  293. package/dist/components/itinerary/itinerary-item/itinerary-item.d.ts +0 -8
  294. package/dist/components/itinerary/itinerary-item/itinerary-item.js +0 -6
  295. package/dist/components/itinerary/itinerary-item/itinerary-item.styles.d.ts +0 -2
  296. package/dist/components/itinerary/itinerary-item/itinerary-item.styles.js +0 -70
  297. package/dist/components/itinerary/itinerary.component.d.ts +0 -7
  298. package/dist/components/itinerary/itinerary.component.js +0 -23
  299. package/dist/components/itinerary/itinerary.d.ts +0 -8
  300. package/dist/components/itinerary/itinerary.js +0 -6
  301. package/dist/components/itinerary/itinerary.styles.d.ts +0 -2
  302. package/dist/components/itinerary/itinerary.styles.js +0 -15
  303. package/dist/components/marketing-tag/marketing-tag.component.d.ts +0 -5
  304. package/dist/components/marketing-tag/marketing-tag.component.js +0 -8
  305. package/dist/components/marketing-tag/marketing-tag.d.ts +0 -8
  306. package/dist/components/marketing-tag/marketing-tag.js +0 -6
  307. package/dist/components/marketing-tag/marketing-tag.styles.d.ts +0 -2
  308. package/dist/components/marketing-tag/marketing-tag.styles.js +0 -36
  309. package/dist/components/price/price.component.d.ts +0 -12
  310. package/dist/components/price/price.component.js +0 -38
  311. package/dist/components/price/price.d.ts +0 -8
  312. package/dist/components/price/price.js +0 -6
  313. package/dist/components/reviews/review/review.component.d.ts +0 -9
  314. package/dist/components/reviews/review/review.component.js +0 -41
  315. package/dist/components/reviews/review/review.d.ts +0 -8
  316. package/dist/components/reviews/review/review.js +0 -6
  317. package/dist/components/reviews/review/review.styles.d.ts +0 -2
  318. package/dist/components/reviews/review/review.styles.js +0 -45
  319. package/dist/components/reviews/reviews.component.d.ts +0 -9
  320. package/dist/components/reviews/reviews.component.js +0 -56
  321. package/dist/components/reviews/reviews.d.ts +0 -8
  322. package/dist/components/reviews/reviews.js +0 -6
  323. package/dist/components/reviews/reviews.styles.d.ts +0 -2
  324. package/dist/components/reviews/reviews.styles.js +0 -73
  325. package/dist/components/selected-tickets-preview/selected-tickets-preview.component.d.ts +0 -10
  326. package/dist/components/selected-tickets-preview/selected-tickets-preview.component.js +0 -51
  327. package/dist/components/selected-tickets-preview/selected-tickets-preview.d.ts +0 -8
  328. package/dist/components/selected-tickets-preview/selected-tickets-preview.js +0 -6
  329. package/dist/components/selected-tickets-preview/selected-tickets-preview.styles.d.ts +0 -2
  330. package/dist/components/selected-tickets-preview/selected-tickets-preview.styles.js +0 -89
  331. package/dist/components/tag/tag.component.d.ts +0 -8
  332. package/dist/components/tag/tag.component.js +0 -33
  333. package/dist/components/tag/tag.constants.d.ts +0 -1
  334. package/dist/components/tag/tag.constants.js +0 -1
  335. package/dist/components/tag/tag.d.ts +0 -8
  336. package/dist/components/tag/tag.js +0 -6
  337. package/dist/components/tag/tag.styles.d.ts +0 -2
  338. package/dist/components/tag/tag.styles.js +0 -56
  339. package/dist/components/tooltip/tooltip.component.d.ts +0 -19
  340. package/dist/components/tooltip/tooltip.component.js +0 -124
  341. package/dist/components/tooltip/tooltip.d.ts +0 -8
  342. package/dist/components/tooltip/tooltip.js +0 -6
  343. package/dist/components/tooltip/tooltip.styles.d.ts +0 -2
  344. package/dist/components/tooltip/tooltip.styles.js +0 -79
  345. package/dist/core/signals.d.ts +0 -2
  346. package/dist/core/signals.js +0 -3
  347. package/dist/core/storybook/argTypes.d.ts +0 -1
  348. package/dist/core/storybook/argTypes.js +0 -46
  349. package/dist/core/storybook/cssprops.d.ts +0 -30
  350. package/dist/core/storybook/cssprops.js +0 -46
  351. package/dist/core/storybook/demo.d.ts +0 -4
  352. package/dist/core/storybook/demo.js +0 -17
  353. package/dist/core/types/api-errors.d.ts +0 -8
  354. package/dist/core/types/api-errors.js +0 -1
  355. package/dist/styles/contrast-fixtures.d.ts +0 -5
  356. package/dist/styles/contrast-fixtures.js +0 -131
  357. package/dist/views/payment-page/domain/payment-mappers.d.ts +0 -7
  358. package/dist/views/payment-page/domain/payment-mappers.js +0 -7
  359. package/dist/views/payment-page/domain/payment-validators.d.ts +0 -6
  360. package/dist/views/payment-page/domain/payment-validators.js +0 -6
  361. package/dist/views/payment-page/domain/recovery-payload.d.ts +0 -8
  362. package/dist/views/payment-page/domain/recovery-payload.js +0 -7
  363. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.component.d.ts +0 -22
  364. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.component.js +0 -65
  365. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.d.ts +0 -8
  366. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.js +0 -6
  367. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.styles.d.ts +0 -2
  368. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.styles.js +0 -12
  369. package/dist/views/payment-page/payment-page.validation-schema.d.ts +0 -28
  370. package/dist/views/payment-page/payment-page.validation-schema.js +0 -42
  371. /package/dist/{components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.styles.d.ts → views/chrome-only-page/chrome-only-page.styles.d.ts} +0 -0
  372. /package/dist/{components/attraction-discovery/attraction-discovery.styles.d.ts → views/details-page/partials/location-categories/location-categories.styles.d.ts} +0 -0
  373. /package/dist/{components/basket-rewards/basket-rewards.styles.d.ts → views/details-page/partials/location-highlights/location-highlights.styles.d.ts} +0 -0
@@ -8,9 +8,10 @@ import { state } from "lit/decorators.js";
8
8
  // Only the lightweight, synchronously-needed helpers are imported statically
9
9
  // (via `viem/utils`, which pulls no client/transport/RPC code). The heavy
10
10
  // public-client machinery and the chain configs (`./coinbase-chains.js`) are
11
- // dynamically imported inside `initCoinbase`/`transferTokens`, so a payment page
12
- // that never enters the crypto flow does not eagerly bundle them.
13
- import { formatUnits, isAddress } from "viem/utils";
11
+ // dynamically imported inside `initCoinbase`, so a payment page that never
12
+ // enters the crypto flow does not eagerly bundle them.
13
+ import { encodeFunctionData, formatUnits, isAddress, parseUnits, } from "viem/utils";
14
+ import { assertNonZeroAddress } from "../core/utils/crypto-address.js";
14
15
  /**
15
16
  * ERC-20 ABI for balance and transfer operations
16
17
  */
@@ -32,15 +33,7 @@ const ERC20_ABI = [
32
33
  ],
33
34
  outputs: [{ name: "", type: "bool" }],
34
35
  },
35
- {
36
- name: "decimals",
37
- type: "function",
38
- stateMutability: "view",
39
- inputs: [],
40
- outputs: [{ name: "", type: "uint8" }],
41
- },
42
36
  ];
43
- export { assertNonZeroAddress as _assertNonZeroAddress, ZERO_ADDRESS as _ZERO_ADDRESS, };
44
37
  /**
45
38
  * Email validation regex (RFC 5322 simplified).
46
39
  * Max 254 chars enforced separately per RFC 5321.
@@ -61,31 +54,37 @@ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12
61
54
  */
62
55
  const TOKEN_DECIMALS = 18;
63
56
  /**
64
- * Maximum transfer amount (safety bound).
57
+ * Maximum transfer amount in whole tokens (safety bound).
65
58
  */
66
59
  const MAX_TRANSFER_AMOUNT = 1_000_000;
60
+ const MAX_TRANSFER_AMOUNT_WEI = parseUnits(String(MAX_TRANSFER_AMOUNT), TOKEN_DECIMALS);
67
61
  /**
68
- * Zero address constant - transfers to this address permanently burn tokens.
69
- */
70
- const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
71
- /**
72
- * Validates that an address is both a valid Ethereum address and not the zero address.
73
- * Zero address is technically valid by format but represents a burn address
74
- * that would cause irreversible loss of funds.
75
- *
76
- * @throws Error if address is invalid or zero
62
+ * Maps a sendUserOperation rejection to a code. The SDK's MfaError carries
63
+ * a `code` and names itself; anything else is opaque and reported as unknown.
77
64
  */
78
- function assertNonZeroAddress(address, label) {
79
- if (!isAddress(address) || address.toLowerCase() === ZERO_ADDRESS) {
80
- throw new Error(`${label} is invalid or zero-address`);
65
+ function transferErrorCode(error) {
66
+ if (error instanceof Error && error.name === "MfaError") {
67
+ const { code } = error;
68
+ return code === "CANCELLED" || code === "SUPERSEDED"
69
+ ? "cancelled"
70
+ : "mfa_failed";
81
71
  }
72
+ return "unknown";
73
+ }
74
+ /** Resolves after `ms`, or immediately once `signal` aborts. */
75
+ function sleep(ms, signal) {
76
+ return new Promise((resolve) => {
77
+ const onAbort = () => {
78
+ clearTimeout(timer);
79
+ resolve();
80
+ };
81
+ const timer = setTimeout(() => {
82
+ signal.removeEventListener("abort", onAbort);
83
+ resolve();
84
+ }, ms);
85
+ signal.addEventListener("abort", onAbort, { once: true });
86
+ });
82
87
  }
83
- /**
84
- * localStorage key for persisting the Coinbase login email.
85
- * The CDP SDK does not return the email on session restore,
86
- * so we persist it at login time to autofill the billing email.
87
- */
88
- const COINBASE_EMAIL_KEY = "coras-coinbase-email";
89
88
  export const CoinbaseMixin = (Base) => {
90
89
  class CoinbaseMixinClass extends Base {
91
90
  constructor() {
@@ -103,6 +102,14 @@ export const CoinbaseMixin = (Base) => {
103
102
  this.mfaVerificationError = "";
104
103
  this._mfaListenerUnsubscribe = null;
105
104
  this._mfaInProgress = false;
105
+ /**
106
+ * Incremented per transferTokens attempt. A superseded attempt (CDP
107
+ * rejects it once a newer one starts) must not touch state that now
108
+ * belongs to the newer attempt.
109
+ */
110
+ this._transferSequence = 0;
111
+ /** Aborts the in-flight transfer's receipt polling on disconnect or cleanup. */
112
+ this._transferAbort = null;
106
113
  this.cdpProjectId = "";
107
114
  this.cryptoNetwork = "base";
108
115
  this.tokenContractAddress = "0x0000000000000000000000000000000000000000";
@@ -138,36 +145,35 @@ export const CoinbaseMixin = (Base) => {
138
145
  return phone.replace(/[\s\-()]/g, "");
139
146
  }
140
147
  /**
141
- * Extracts the first EVM account address from a CDP user object.
142
- * Handles both string and object formats consistently.
148
+ * Extracts the first EVM (EOA) account address from a CDP user object.
143
149
  */
144
150
  extractAccountAddress(user) {
145
- if (user.evmAccounts && user.evmAccounts.length > 0) {
146
- const firstAccount = user.evmAccounts[0];
147
- return (typeof firstAccount === "string"
148
- ? firstAccount
149
- : firstAccount.address);
150
- }
151
- if (user.evmAccountObjects && user.evmAccountObjects.length > 0) {
152
- return user.evmAccountObjects[0].address;
153
- }
154
- return undefined;
151
+ const address = user.evmAccountObjects?.[0]?.address;
152
+ return address && isAddress(address) ? address : undefined;
155
153
  }
156
154
  /**
157
- * Extracts the smart account address from a CDP user object.
158
- * Checks evmSmartAccountObjects first (newer API), then evmSmartAccounts.
155
+ * Extracts the first smart account address from a CDP user object.
159
156
  */
160
157
  extractSmartAccountAddress(user) {
161
- if (user.evmSmartAccountObjects &&
162
- user.evmSmartAccountObjects.length > 0) {
163
- const smartAccount = user.evmSmartAccountObjects[0];
164
- return (typeof smartAccount === "string" ? smartAccount : smartAccount.address);
165
- }
166
- if (user.evmSmartAccounts && user.evmSmartAccounts.length > 0) {
167
- const smartAccount = user.evmSmartAccounts[0];
168
- return (typeof smartAccount === "string" ? smartAccount : smartAccount.address);
158
+ const address = user.evmSmartAccountObjects?.[0]?.address;
159
+ return address && isAddress(address) ? address : undefined;
160
+ }
161
+ /**
162
+ * Builds a session from a CDP user, or undefined when the user has no
163
+ * EVM account yet.
164
+ */
165
+ sessionFromUser(user) {
166
+ const address = this.extractAccountAddress(user);
167
+ if (!address) {
168
+ return undefined;
169
169
  }
170
- return undefined;
170
+ return {
171
+ address,
172
+ smartAccountAddress: this.extractSmartAccountAddress(user),
173
+ email: user.authenticationMethods?.email?.email,
174
+ userId: user.userId,
175
+ isConnected: true,
176
+ };
171
177
  }
172
178
  /**
173
179
  * Initializes Coinbase CDP SDK for embedded wallets.
@@ -186,11 +192,11 @@ export const CoinbaseMixin = (Base) => {
186
192
  }
187
193
  const pid = projectId || this.cdpProjectId;
188
194
  if (!pid) {
189
- console.error("CDP Project ID is required for initialization");
195
+ this.logger.error("CDP Project ID is required for initialization");
190
196
  return false;
191
197
  }
192
198
  if (!UUID_REGEX.test(pid)) {
193
- console.error("CDP Project ID must be a valid UUID");
199
+ this.logger.error("CDP Project ID must be a valid UUID");
194
200
  return false;
195
201
  }
196
202
  // Validate addresses - misconfigured zero-address defaults would irreversibly burn tokens
@@ -199,12 +205,14 @@ export const CoinbaseMixin = (Base) => {
199
205
  assertNonZeroAddress(this.tokenContractAddress, "Token contract address");
200
206
  }
201
207
  catch (e) {
202
- console.error(e instanceof Error ? e.message : "Invalid address configuration");
208
+ this.logger.error(e instanceof Error ? e.message : "Invalid address configuration");
203
209
  return false;
204
210
  }
205
211
  this._initPromise = (async () => {
206
212
  try {
207
- const [cdpCore, { createPublicClient, http }, { base, baseSepolia }] = await Promise.all([
213
+ // Namespace access (not destructuring) keeps these imports
214
+ // tree-shakable in the crypto chunk.
215
+ const [cdpCore, viem, chains] = await Promise.all([
208
216
  import("@coinbase/cdp-core"),
209
217
  import("viem"),
210
218
  import("./coinbase-chains.js"),
@@ -217,20 +225,39 @@ export const CoinbaseMixin = (Base) => {
217
225
  createOnLogin: "smart",
218
226
  },
219
227
  });
220
- this._publicClient = createPublicClient({
221
- chain: this.cryptoNetwork === "base" ? base : baseSepolia,
222
- transport: this.cryptoRpc ? http(this.cryptoRpc) : http(),
228
+ const chain = this.cryptoNetwork === "base" ? chains.base : chains.baseSepolia;
229
+ this._publicClient = viem.createPublicClient({
230
+ chain,
231
+ transport: this.cryptoRpc ? viem.http(this.cryptoRpc) : viem.http(),
223
232
  });
233
+ // Balances are read over this RPC while the user operation is sent
234
+ // on `cryptoNetwork`; a mismatch would confirm against a hash on the
235
+ // wrong chain, so refuse to initialise.
236
+ const rpcChainId = await this._publicClient.getChainId();
237
+ if (rpcChainId !== chain.id) {
238
+ this.logger.error(`RPC chain id ${rpcChainId} does not match ${this.cryptoNetwork} (${chain.id})`);
239
+ this.cleanupCoinbase();
240
+ return false;
241
+ }
224
242
  // CDP SDK calls this listener when sendUserOperation requires MFA
225
243
  this._mfaListenerUnsubscribe = this._cdpCore.registerMfaListener((context) => {
226
- this.handleMfaListenerTriggered(context);
244
+ void this.handleMfaListenerTriggered(context);
227
245
  });
228
246
  this._isInitialized = true;
247
+ // Earlier releases persisted the login email here; the SDK user
248
+ // object carries it, so clear the stale copy. Safe to remove after
249
+ // one release.
250
+ try {
251
+ localStorage.removeItem("coras-coinbase-email");
252
+ }
253
+ catch {
254
+ // localStorage may be blocked (e.g. private browsing)
255
+ }
229
256
  await this.restoreSession();
230
257
  return true;
231
258
  }
232
259
  catch {
233
- console.error("Failed to initialize CDP SDK");
260
+ this.logger.error("Failed to initialize CDP SDK");
234
261
  this.cleanupCoinbase();
235
262
  return false;
236
263
  }
@@ -248,27 +275,10 @@ export const CoinbaseMixin = (Base) => {
248
275
  return;
249
276
  try {
250
277
  const user = await this._cdpCore.getCurrentUser();
251
- if (user) {
252
- const address = this.extractAccountAddress(user);
253
- const smartAccountAddress = this.extractSmartAccountAddress(user);
254
- if (address) {
255
- // Restore persisted email (CDP SDK doesn't return it)
256
- let email;
257
- try {
258
- email = localStorage.getItem(COINBASE_EMAIL_KEY) || undefined;
259
- }
260
- catch {
261
- // localStorage may be blocked (e.g. private browsing)
262
- }
263
- this.coinbaseSession = {
264
- address,
265
- smartAccountAddress,
266
- email,
267
- userId: user.userId,
268
- isConnected: true,
269
- };
270
- await this.checkMfaEnrolled();
271
- }
278
+ const session = user ? this.sessionFromUser(user) : undefined;
279
+ if (session) {
280
+ this.coinbaseSession = session;
281
+ await this.checkMfaEnrolled();
272
282
  }
273
283
  }
274
284
  catch {
@@ -283,29 +293,20 @@ export const CoinbaseMixin = (Base) => {
283
293
  */
284
294
  async checkMfaEnrolled() {
285
295
  if (!this._cdpCore) {
286
- console.warn("CDP SDK not initialized");
296
+ this.logger.warn("CDP SDK not initialized");
287
297
  return false;
288
298
  }
289
299
  try {
290
300
  const user = await this._cdpCore.getCurrentUser();
291
301
  if (user) {
292
- // Narrow to record shape (not array) to access .totp/.sms properties
293
- const mfaMethods = user.mfaMethods;
294
- const mfaRecord = mfaMethods && !Array.isArray(mfaMethods) ? mfaMethods : null;
295
- const hasTotp = !!mfaRecord?.totp;
296
- const hasSms = !!mfaRecord?.sms;
297
- // Fallback for older SDK versions that returned different shapes
298
- const hasLegacyMfa = user.mfaEnrolled === true ||
299
- user.hasMfa === true ||
300
- (Array.isArray(user.mfaMethods) && user.mfaMethods.length > 0);
301
- const hasMfa = hasTotp || hasSms || hasLegacyMfa;
302
- this.isMfaEnrolled = hasMfa;
303
- return hasMfa;
302
+ // The transfer flow verifies over SMS only, so other methods do not count
303
+ this.isMfaEnrolled = this._cdpCore.isEnrolledInMfa(user, "sms");
304
+ return this.isMfaEnrolled;
304
305
  }
305
306
  return false;
306
307
  }
307
308
  catch {
308
- console.error("Failed to check MFA enrolled status");
309
+ this.logger.error("Failed to check MFA enrolled status");
309
310
  return false;
310
311
  }
311
312
  }
@@ -359,7 +360,7 @@ export const CoinbaseMixin = (Base) => {
359
360
  this.mfaEnrollmentError = "";
360
361
  return;
361
362
  }
362
- console.error("Failed to initiate MFA enrollment");
363
+ this.logger.error("Failed to initiate MFA enrollment");
363
364
  this.mfaEnrollmentError =
364
365
  "Failed to send MFA verification code. Please try again.";
365
366
  throw new Error("Failed to send MFA verification code. Please try again.", { cause: error });
@@ -390,7 +391,7 @@ export const CoinbaseMixin = (Base) => {
390
391
  return true;
391
392
  }
392
393
  catch {
393
- console.error("MFA enrollment verification failed");
394
+ this.logger.error("MFA enrollment verification failed");
394
395
  this.mfaEnrollmentError =
395
396
  "Invalid or expired verification code. Please try again.";
396
397
  throw new Error("Invalid or expired verification code. Please try again.");
@@ -398,21 +399,29 @@ export const CoinbaseMixin = (Base) => {
398
399
  }
399
400
  /**
400
401
  * Ensures a smart account exists for the current user.
401
- * Creates one if it doesn't exist. Smart accounts are required for gas sponsorship.
402
+ * Re-reads the SDK user first so an account created by an earlier login
403
+ * is reused; only then creates one, owned by the user's existing EOA so
404
+ * the SDK does not mint a fresh zero-balance EOA as the owner.
405
+ * Smart accounts are required for gas sponsorship.
402
406
  * @returns The smart account address or undefined if creation failed
403
407
  */
404
408
  async ensureSmartAccount() {
405
409
  if (!this._cdpCore)
406
410
  return undefined;
407
411
  try {
408
- const smartAccountAddress = await this._cdpCore.createEvmSmartAccount();
409
- if (smartAccountAddress) {
410
- return smartAccountAddress;
411
- }
412
- return undefined;
412
+ const user = await this._cdpCore.getCurrentUser();
413
+ if (!user)
414
+ return undefined;
415
+ const existing = this.extractSmartAccountAddress(user);
416
+ if (existing)
417
+ return existing;
418
+ const owner = this.extractAccountAddress(user);
419
+ if (!owner)
420
+ return undefined;
421
+ return await this._cdpCore.createEvmSmartAccount({ owner });
413
422
  }
414
423
  catch {
415
- console.error("Failed to create smart account");
424
+ this.logger.error("Failed to create smart account");
416
425
  return undefined;
417
426
  }
418
427
  }
@@ -421,6 +430,8 @@ export const CoinbaseMixin = (Base) => {
421
430
  * Safe to call multiple times.
422
431
  */
423
432
  cleanupCoinbase() {
433
+ this.cancelPendingMfa();
434
+ this._transferAbort?.abort();
424
435
  // Unregister MFA listener before cleanup
425
436
  if (this._mfaListenerUnsubscribe) {
426
437
  this._mfaListenerUnsubscribe();
@@ -464,7 +475,7 @@ export const CoinbaseMixin = (Base) => {
464
475
  this.codeSent = true;
465
476
  }
466
477
  catch {
467
- console.error("Failed to send verification code");
478
+ this.logger.error("Failed to send verification code");
468
479
  throw new Error("Failed to send verification code. Please try again.");
469
480
  }
470
481
  }
@@ -489,46 +500,32 @@ export const CoinbaseMixin = (Base) => {
489
500
  if (!code || code.trim().length === 0) {
490
501
  throw new Error("Verification code is required");
491
502
  }
492
- let result;
503
+ let user;
493
504
  try {
494
- result = await this._cdpCore.verifyEmailOTP({
505
+ ({ user } = await this._cdpCore.verifyEmailOTP({
495
506
  flowId: this._flowId,
496
507
  otp: code.trim(),
497
- });
508
+ }));
498
509
  }
499
510
  catch {
500
- console.error("Login failed");
511
+ this.logger.error("Login failed");
501
512
  throw new Error("Invalid or expired verification code");
502
513
  }
503
- if (result.user) {
504
- const address = this.extractAccountAddress(result.user);
505
- if (!address) {
506
- throw new Error("No wallet address returned from authentication");
507
- }
508
- let smartAccountAddress = this.extractSmartAccountAddress(result.user);
509
- if (!smartAccountAddress) {
510
- smartAccountAddress = await this.ensureSmartAccount();
511
- }
512
- this.coinbaseSession = {
513
- address,
514
- smartAccountAddress,
515
- email: sanitizedEmail,
516
- userId: result.user.userId,
517
- isConnected: true,
518
- };
519
- // Persist email for session restore (CDP SDK doesn't return it)
520
- try {
521
- localStorage.setItem(COINBASE_EMAIL_KEY, sanitizedEmail);
522
- }
523
- catch {
524
- // localStorage may be blocked (e.g. private browsing)
525
- }
526
- this.codeSent = false;
527
- this._flowId = null;
528
- await this.checkMfaEnrolled();
529
- return this.coinbaseSession;
514
+ const session = this.sessionFromUser(user);
515
+ if (!session) {
516
+ throw new Error("No wallet address returned from authentication");
517
+ }
518
+ if (!session.smartAccountAddress) {
519
+ session.smartAccountAddress = await this.ensureSmartAccount();
530
520
  }
531
- throw new Error("No wallet address returned from authentication");
521
+ this.coinbaseSession = {
522
+ ...session,
523
+ email: session.email ?? sanitizedEmail,
524
+ };
525
+ this.codeSent = false;
526
+ this._flowId = null;
527
+ await this.checkMfaEnrolled();
528
+ return this.coinbaseSession;
532
529
  }
533
530
  /**
534
531
  * Retrieves the current authenticated user/session.
@@ -537,34 +534,24 @@ export const CoinbaseMixin = (Base) => {
537
534
  */
538
535
  async getUser() {
539
536
  if (!this._cdpCore) {
540
- console.warn("CDP SDK not initialized");
537
+ this.logger.warn("CDP SDK not initialized");
541
538
  return undefined;
542
539
  }
543
540
  try {
544
541
  const user = await this._cdpCore.getCurrentUser();
545
542
  if (user) {
546
- const address = this.extractAccountAddress(user);
547
- if (address && !this.coinbaseSession) {
548
- this.coinbaseSession = {
549
- address,
550
- userId: user.userId,
551
- isConnected: true,
552
- };
543
+ if (!this.coinbaseSession) {
544
+ this.coinbaseSession = this.sessionFromUser(user);
553
545
  }
554
546
  return this.coinbaseSession;
555
547
  }
556
548
  return undefined;
557
549
  }
558
550
  catch {
559
- console.warn("Failed to fetch user");
551
+ this.logger.warn("Failed to fetch user");
560
552
  return undefined;
561
553
  }
562
554
  }
563
- /**
564
- * Retrieves the user's wallet.
565
- *
566
- * @returns Wallet object or null if not available
567
- */
568
555
  /**
569
556
  * Fetches the FIDA token balance for an address.
570
557
  *
@@ -573,11 +560,11 @@ export const CoinbaseMixin = (Base) => {
573
560
  */
574
561
  async getTokenBalance(address) {
575
562
  if (!this._publicClient) {
576
- console.warn("Public client not initialized");
563
+ this.logger.warn("Public client not initialized");
577
564
  return null;
578
565
  }
579
566
  if (!address || !isAddress(address)) {
580
- console.error("Invalid Ethereum address format");
567
+ this.logger.error("Invalid Ethereum address format");
581
568
  return null;
582
569
  }
583
570
  try {
@@ -590,7 +577,7 @@ export const CoinbaseMixin = (Base) => {
590
577
  return balance;
591
578
  }
592
579
  catch {
593
- console.error("Failed to fetch token balance");
580
+ this.logger.error("Failed to fetch token balance");
594
581
  return null;
595
582
  }
596
583
  }
@@ -611,91 +598,67 @@ export const CoinbaseMixin = (Base) => {
611
598
  async transferTokens(amount) {
612
599
  // Prevent concurrent transfers (double-click safety)
613
600
  if (this.isTransferPending) {
614
- return {
615
- success: false,
616
- error: "Transfer already in progress",
617
- };
601
+ return { success: false, error: "in_progress" };
618
602
  }
619
- if (!this._cdpCore) {
620
- return {
621
- success: false,
622
- error: "CDP SDK not initialized",
623
- };
624
- }
625
- if (!this._publicClient) {
626
- return {
627
- success: false,
628
- error: "Public client not initialized",
629
- };
603
+ if (!this._cdpCore || !this._publicClient) {
604
+ return { success: false, error: "not_initialized" };
630
605
  }
631
606
  if (!this.coinbaseSession?.address) {
632
- return {
633
- success: false,
634
- error: "User not authenticated",
635
- };
607
+ return { success: false, error: "not_authenticated" };
636
608
  }
637
609
  // Runtime guard - misconfigured zero-address would irreversibly burn tokens
638
610
  try {
639
611
  assertNonZeroAddress(this.recipientAddress, "Recipient address");
640
612
  assertNonZeroAddress(this.tokenContractAddress, "Token contract address");
641
613
  }
642
- catch (e) {
643
- return {
644
- success: false,
645
- error: e instanceof Error ? e.message : "Invalid address configuration",
646
- };
647
- }
648
- const numericAmount = parseFloat(amount);
649
- if (!amount || isNaN(numericAmount) || numericAmount <= 0) {
650
- return {
651
- success: false,
652
- error: "Invalid transfer amount",
653
- };
654
- }
655
- if (numericAmount > MAX_TRANSFER_AMOUNT) {
656
- return {
657
- success: false,
658
- error: `Amount exceeds maximum of ${MAX_TRANSFER_AMOUNT}`,
659
- };
660
- }
661
- // Gas sponsorship requires ERC-4337 smart accounts, not plain EOAs
662
- if (!this.coinbaseSession.smartAccountAddress) {
663
- const smartAccountAddress = await this.ensureSmartAccount();
664
- if (smartAccountAddress) {
614
+ catch {
615
+ return { success: false, error: "invalid_address" };
616
+ }
617
+ // Exact decimal parsing: floats would drift (0.1 + 0.2) and stringify
618
+ // tiny values in exponent form, which viem rejects.
619
+ let amountInWei;
620
+ try {
621
+ amountInWei = parseUnits(amount, TOKEN_DECIMALS);
622
+ }
623
+ catch {
624
+ return { success: false, error: "invalid_amount" };
625
+ }
626
+ if (amountInWei <= 0n || amountInWei > MAX_TRANSFER_AMOUNT_WEI) {
627
+ return { success: false, error: "invalid_amount" };
628
+ }
629
+ // Claimed synchronously, before the first await, so a second click
630
+ // cannot slip in while the smart account is being looked up.
631
+ const attempt = ++this._transferSequence;
632
+ // One key per attempt so a retried request cannot submit the operation twice
633
+ const idempotencyKey = crypto.randomUUID();
634
+ const abort = new AbortController();
635
+ this._transferAbort = abort;
636
+ this.isTransferPending = true;
637
+ this.pendingTransferAmount = amount;
638
+ try {
639
+ // Gas sponsorship requires ERC-4337 smart accounts, not plain EOAs
640
+ let smartAccountAddress = this.coinbaseSession.smartAccountAddress;
641
+ if (!smartAccountAddress) {
642
+ smartAccountAddress = await this.ensureSmartAccount();
643
+ if (!smartAccountAddress) {
644
+ return { success: false, error: "smart_account_unavailable" };
645
+ }
665
646
  this.coinbaseSession = {
666
647
  ...this.coinbaseSession,
667
648
  smartAccountAddress,
668
649
  };
669
650
  }
670
- else {
671
- return {
672
- success: false,
673
- error: "Smart account required for gas-sponsored transfers. Please try logging in again.",
674
- };
675
- }
676
- }
677
- try {
678
- this.isTransferPending = true;
679
- this.pendingTransferAmount = amount;
680
- // viem is already evaluated (loaded during initCoinbase), so this
681
- // resolves from the module cache without a second network round-trip.
682
- const { parseUnits, encodeFunctionData } = await import("viem");
683
- const amountInWei = parseUnits(amount, TOKEN_DECIMALS);
684
651
  const data = encodeFunctionData({
685
652
  abi: ERC20_ABI,
686
653
  functionName: "transfer",
687
654
  args: [this.recipientAddress, amountInWei],
688
655
  });
689
- const smartAccountBalance = await this.getTokenBalance(this.coinbaseSession.smartAccountAddress);
656
+ const smartAccountBalance = await this.getTokenBalance(smartAccountAddress);
690
657
  if (smartAccountBalance === null || smartAccountBalance < amountInWei) {
691
- this.isTransferPending = false;
692
- return {
693
- success: false,
694
- error: "Insufficient FIDA token balance",
695
- };
658
+ return { success: false, error: "insufficient_balance" };
696
659
  }
697
660
  const userOpResult = await this._cdpCore.sendUserOperation({
698
- evmSmartAccount: this.coinbaseSession.smartAccountAddress,
661
+ evmSmartAccount: smartAccountAddress,
699
662
  network: this.cryptoNetwork,
700
663
  calls: [
701
664
  {
@@ -705,95 +668,83 @@ export const CoinbaseMixin = (Base) => {
705
668
  },
706
669
  ],
707
670
  useCdpPaymaster: true,
671
+ idempotencyKey,
708
672
  });
709
- const receipt = await this.pollForUserOperationReceipt(userOpResult.userOperationHash);
710
- this.isTransferPending = false;
711
- this.pendingTransferAmount = "";
712
- if (receipt) {
673
+ const outcome = await this.pollForUserOperationReceipt(userOpResult.userOperationHash, smartAccountAddress, abort.signal);
674
+ if (outcome.status === "complete") {
713
675
  return {
714
676
  success: true,
715
- transactionHash: receipt,
716
- };
717
- }
718
- else {
719
- return {
720
- success: false,
721
- error: "Transaction failed or timed out",
677
+ transactionHash: outcome.transactionHash,
722
678
  };
723
679
  }
680
+ // An abort after submission is not a failure: the operation may still land
681
+ return { success: false, error: outcome.status };
724
682
  }
725
683
  catch (error) {
726
- console.error("Transfer failed");
727
- const errorMessage = error instanceof Error ? error.message : String(error);
728
- this.isTransferPending = false;
729
- this.pendingTransferAmount = "";
684
+ if (attempt !== this._transferSequence) {
685
+ // CDP rejected this attempt because a newer one superseded it;
686
+ // the newer attempt owns the pending and MFA state now.
687
+ return { success: false, error: "cancelled" };
688
+ }
689
+ if (abort.signal.aborted) {
690
+ return { success: false, error: "aborted" };
691
+ }
692
+ this.logger.error("Transfer failed");
730
693
  this.mfaVerificationRequired = false;
731
694
  this._mfaInProgress = false;
732
- // Handle user rejection
733
- if (errorMessage.includes("rejected") ||
734
- errorMessage.includes("denied") ||
735
- errorMessage.includes("cancelled")) {
736
- return {
737
- success: false,
738
- error: "Transaction was cancelled by user",
739
- };
695
+ return { success: false, error: transferErrorCode(error) };
696
+ }
697
+ finally {
698
+ if (attempt === this._transferSequence) {
699
+ this.isTransferPending = false;
700
+ this.pendingTransferAmount = "";
740
701
  }
741
- // Handle MFA rejection (user cancelled MFA verification)
742
- if (errorMessage.includes("MFA") ||
743
- errorMessage.includes("mfa") ||
744
- errorMessage.includes("verification")) {
745
- return {
746
- success: false,
747
- error: "MFA verification was cancelled or failed",
748
- };
702
+ if (this._transferAbort === abort) {
703
+ this._transferAbort = null;
749
704
  }
750
- return {
751
- success: false,
752
- error: error instanceof Error ? error.message : "Unknown transfer error",
753
- };
754
705
  }
755
706
  }
756
707
  /**
757
708
  * Polls for user operation status and transaction hash.
758
709
  * Uses CDP Core's getUserOperation method which returns EvmUserOperation.
759
710
  * The operation is complete when status is "complete" and transactionHash is populated.
760
- *
761
- * @param onStatusUpdate - Optional callback for progress updates
711
+ * Stops early once `signal` aborts (element disconnected or cleaned up).
762
712
  */
763
- async pollForUserOperationReceipt(userOpHash, onStatusUpdate) {
764
- if (!this._cdpCore)
765
- return null;
766
- if (!this.coinbaseSession?.smartAccountAddress) {
767
- console.error("Smart account address not available for polling");
768
- return null;
769
- }
713
+ async pollForUserOperationReceipt(userOpHash, smartAccountAddress, signal) {
714
+ // Captured so cleanupCoinbase nulling the field mid-loop cannot turn a
715
+ // landed operation into a failure; the abort signal ends the loop instead.
716
+ const cdpCore = this._cdpCore;
717
+ if (!cdpCore)
718
+ return { status: "aborted" };
770
719
  const maxAttempts = 60; // 120 seconds with 2s interval
771
720
  const interval = 2000;
772
721
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
722
+ if (signal.aborted)
723
+ return { status: "aborted" };
773
724
  try {
774
- const userOp = await this._cdpCore.getUserOperation({
725
+ const userOp = await cdpCore.getUserOperation({
775
726
  userOperationHash: userOpHash,
776
- evmSmartAccount: this.coinbaseSession.smartAccountAddress,
727
+ evmSmartAccount: smartAccountAddress,
777
728
  network: this.cryptoNetwork,
778
729
  });
779
- if (onStatusUpdate && userOp?.status) {
780
- onStatusUpdate(userOp.status, attempt, maxAttempts);
781
- }
782
- if (userOp?.status === "complete" && userOp?.transactionHash) {
783
- return userOp.transactionHash;
730
+ if (userOp.status === "complete" && userOp.transactionHash) {
731
+ return {
732
+ status: "complete",
733
+ transactionHash: userOp.transactionHash,
734
+ };
784
735
  }
785
- if (userOp?.status === "failed" || userOp?.status === "dropped") {
786
- console.error("User operation failed with status:", userOp?.status);
787
- return null;
736
+ if (userOp.status === "failed" || userOp.status === "dropped") {
737
+ this.logger.error("User operation failed with status:", userOp.status);
738
+ return { status: "failed" };
788
739
  }
789
740
  }
790
741
  catch {
791
742
  // Receipt polling is best-effort; timeout handles the failure path
792
743
  }
793
- await new Promise((resolve) => setTimeout(resolve, interval));
744
+ await sleep(interval, signal);
794
745
  }
795
- console.error("Polling timeout after 120 seconds");
796
- return null;
746
+ this.logger.error("Polling timeout after 120 seconds");
747
+ return { status: "timeout" };
797
748
  }
798
749
  /**
799
750
  * Handles MFA listener being triggered by CDP SDK during sendUserOperation.
@@ -804,11 +755,9 @@ export const CoinbaseMixin = (Base) => {
804
755
  if (this._mfaInProgress) {
805
756
  return;
806
757
  }
807
- this._mfaInProgress = true;
808
758
  const hasSms = context.methods.includes("sms");
809
759
  if (!hasSms) {
810
- console.error("SMS MFA not available");
811
- this._mfaInProgress = false;
760
+ this.logger.error("SMS MFA not available");
812
761
  this.mfaVerificationError = "SMS verification not available.";
813
762
  this.mfaVerificationRequired = true;
814
763
  this.requestUpdate();
@@ -816,6 +765,7 @@ export const CoinbaseMixin = (Base) => {
816
765
  }
817
766
  if (!this._cdpCore)
818
767
  return;
768
+ this._mfaInProgress = true;
819
769
  try {
820
770
  await this._cdpCore.initiateMfaVerification({
821
771
  mfaMethod: "sms",
@@ -825,7 +775,7 @@ export const CoinbaseMixin = (Base) => {
825
775
  this.requestUpdate();
826
776
  }
827
777
  catch {
828
- console.error("Failed to initiate MFA verification");
778
+ this.logger.error("Failed to initiate MFA verification");
829
779
  this.mfaVerificationError =
830
780
  "Failed to send verification code. Please try again.";
831
781
  this._mfaInProgress = false;
@@ -855,7 +805,7 @@ export const CoinbaseMixin = (Base) => {
855
805
  this.mfaVerificationError = "";
856
806
  }
857
807
  catch {
858
- console.error("Failed to initiate MFA verification");
808
+ this.logger.error("Failed to initiate MFA verification");
859
809
  this.mfaVerificationError =
860
810
  "Failed to send verification code. Please try again.";
861
811
  throw new Error("Failed to send verification code. Please try again.");
@@ -888,7 +838,7 @@ export const CoinbaseMixin = (Base) => {
888
838
  return true;
889
839
  }
890
840
  catch {
891
- console.error("MFA verification failed");
841
+ this.logger.error("MFA verification failed");
892
842
  this.mfaVerificationError =
893
843
  "Invalid or expired code. Please try again.";
894
844
  // Don't reset _mfaInProgress here - user might retry with correct code
@@ -896,14 +846,25 @@ export const CoinbaseMixin = (Base) => {
896
846
  }
897
847
  }
898
848
  /**
899
- * Resets MFA verification state.
900
- * Call this when cancelling or completing the MFA flow.
849
+ * Tells the SDK to reject the user operation that is waiting on our MFA
850
+ * prompt, so the in-flight transferTokens call settles instead of
851
+ * lingering until the next attempt supersedes it.
852
+ */
853
+ cancelPendingMfa() {
854
+ if (this._cdpCore &&
855
+ (this._mfaInProgress || this.mfaVerificationRequired)) {
856
+ this._cdpCore.cancelMfaVerification();
857
+ }
858
+ }
859
+ /**
860
+ * Resets MFA verification state and cancels the pending SDK operation.
861
+ * Call this when the user dismisses the MFA prompt. The transfer's own
862
+ * finally block clears isTransferPending once the operation rejects.
901
863
  */
902
864
  resetMfaVerificationState() {
865
+ this.cancelPendingMfa();
903
866
  this.mfaVerificationRequired = false;
904
867
  this.mfaVerificationError = "";
905
- this.isTransferPending = false;
906
- this.pendingTransferAmount = "";
907
868
  this._mfaInProgress = false;
908
869
  }
909
870
  /**
@@ -914,20 +875,22 @@ export const CoinbaseMixin = (Base) => {
914
875
  */
915
876
  async getCoinbaseAccessToken() {
916
877
  if (!this._cdpCore) {
917
- console.warn("CDP SDK not initialized");
878
+ this.logger.warn("CDP SDK not initialized");
918
879
  return null;
919
880
  }
920
881
  try {
921
882
  return await this._cdpCore.getAccessToken();
922
883
  }
923
884
  catch {
924
- console.error("Failed to retrieve Coinbase access token");
885
+ this.logger.error("Failed to retrieve Coinbase access token");
925
886
  return null;
926
887
  }
927
888
  }
928
889
  disconnectedCallback() {
929
890
  // Clean up local state so initCoinbase() can re-initialize on reconnect.
930
891
  // Don't sign out - session persists in CDP SDK storage.
892
+ this.cancelPendingMfa();
893
+ this._transferAbort?.abort();
931
894
  if (this._mfaListenerUnsubscribe) {
932
895
  this._mfaListenerUnsubscribe();
933
896
  this._mfaListenerUnsubscribe = null;