@internetarchive/elements 1.1.7-webdev-9378.0 → 1.1.7-webdev-9054.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 (207) hide show
  1. package/dist/src/elements/ia-donation-form/analytics.d.ts +12 -0
  2. package/dist/src/elements/ia-donation-form/analytics.d.ts.map +1 -0
  3. package/dist/src/elements/ia-donation-form/analytics.js +2 -0
  4. package/dist/src/elements/ia-donation-form/analytics.js.map +1 -0
  5. package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.d.ts +79 -0
  6. package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.d.ts.map +1 -0
  7. package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.js +2 -0
  8. package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.js.map +1 -0
  9. package/dist/src/elements/ia-donation-form/braintree/braintree-manager.d.ts +73 -0
  10. package/dist/src/elements/ia-donation-form/braintree/braintree-manager.d.ts.map +1 -0
  11. package/dist/src/elements/ia-donation-form/braintree/braintree-manager.js +126 -0
  12. package/dist/src/elements/ia-donation-form/braintree/braintree-manager.js.map +1 -0
  13. package/dist/src/elements/ia-donation-form/braintree/hosting-environment.d.ts +10 -0
  14. package/dist/src/elements/ia-donation-form/braintree/hosting-environment.d.ts.map +1 -0
  15. package/dist/src/elements/ia-donation-form/braintree/hosting-environment.js +9 -0
  16. package/dist/src/elements/ia-donation-form/braintree/hosting-environment.js.map +1 -0
  17. package/dist/src/elements/ia-donation-form/braintree/payment-clients.d.ts +47 -0
  18. package/dist/src/elements/ia-donation-form/braintree/payment-clients.d.ts.map +1 -0
  19. package/dist/src/elements/ia-donation-form/braintree/payment-clients.js +104 -0
  20. package/dist/src/elements/ia-donation-form/braintree/payment-clients.js.map +1 -0
  21. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.d.ts +11 -0
  22. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.d.ts.map +1 -0
  23. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.js +2 -0
  24. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.js.map +1 -0
  25. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts +20 -0
  26. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts.map +1 -0
  27. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.js +2 -0
  28. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.js.map +1 -0
  29. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.d.ts +21 -0
  30. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.d.ts.map +1 -0
  31. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.js +83 -0
  32. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -0
  33. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.d.ts +11 -0
  34. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.d.ts.map +1 -0
  35. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.js +13 -0
  36. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.js.map +1 -0
  37. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.d.ts +27 -0
  38. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.d.ts.map +1 -0
  39. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.js +67 -0
  40. package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.js.map +1 -0
  41. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.d.ts +19 -0
  42. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.d.ts.map +1 -0
  43. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.js +2 -0
  44. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.js.map +1 -0
  45. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.d.ts +42 -0
  46. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.d.ts.map +1 -0
  47. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.js +99 -0
  48. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.js.map +1 -0
  49. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.d.ts +14 -0
  50. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.d.ts.map +1 -0
  51. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.js +9 -0
  52. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.js.map +1 -0
  53. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.d.ts +40 -0
  54. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.d.ts.map +1 -0
  55. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.js +58 -0
  56. package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.js.map +1 -0
  57. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.d.ts +8 -0
  58. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.d.ts.map +1 -0
  59. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.js +2 -0
  60. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.js.map +1 -0
  61. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.d.ts +19 -0
  62. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.d.ts.map +1 -0
  63. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.js +45 -0
  64. package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.js.map +1 -0
  65. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.d.ts +57 -0
  66. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.d.ts.map +1 -0
  67. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.js +44 -0
  68. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.js.map +1 -0
  69. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.d.ts +14 -0
  70. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.d.ts.map +1 -0
  71. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.js +2 -0
  72. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.js.map +1 -0
  73. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.d.ts +27 -0
  74. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.d.ts.map +1 -0
  75. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.js +44 -0
  76. package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.js.map +1 -0
  77. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.d.ts +8 -0
  78. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.d.ts.map +1 -0
  79. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.js +2 -0
  80. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.js.map +1 -0
  81. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.d.ts +44 -0
  82. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.d.ts.map +1 -0
  83. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.js +65 -0
  84. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.js.map +1 -0
  85. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.d.ts +25 -0
  86. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.d.ts.map +1 -0
  87. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.js +42 -0
  88. package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.js.map +1 -0
  89. package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.d.ts +18 -0
  90. package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.d.ts.map +1 -0
  91. package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.js +2 -0
  92. package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.js.map +1 -0
  93. package/dist/src/elements/ia-donation-form/braintree/payment-providers.d.ts +42 -0
  94. package/dist/src/elements/ia-donation-form/braintree/payment-providers.d.ts.map +1 -0
  95. package/dist/src/elements/ia-donation-form/braintree/payment-providers.js +99 -0
  96. package/dist/src/elements/ia-donation-form/braintree/payment-providers.js.map +1 -0
  97. package/dist/src/elements/ia-donation-form/donation-form-error.d.ts +5 -0
  98. package/dist/src/elements/ia-donation-form/donation-form-error.d.ts.map +1 -0
  99. package/dist/src/elements/ia-donation-form/donation-form-error.js +8 -0
  100. package/dist/src/elements/ia-donation-form/donation-form-error.js.map +1 -0
  101. package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.d.ts +118 -0
  102. package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.d.ts.map +1 -0
  103. package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.js +194 -0
  104. package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.js.map +1 -0
  105. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.d.ts +24 -0
  106. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.d.ts.map +1 -0
  107. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.js +70 -0
  108. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.js.map +1 -0
  109. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.d.ts +44 -0
  110. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.d.ts.map +1 -0
  111. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.js +116 -0
  112. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.js.map +1 -0
  113. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.d.ts +24 -0
  114. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.d.ts.map +1 -0
  115. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.js +74 -0
  116. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.js.map +1 -0
  117. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.d.ts +47 -0
  118. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.d.ts.map +1 -0
  119. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.js +204 -0
  120. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.js.map +1 -0
  121. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.d.ts +30 -0
  122. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.d.ts.map +1 -0
  123. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.js +77 -0
  124. package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.js.map +1 -0
  125. package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.d.ts +80 -0
  126. package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.d.ts.map +1 -0
  127. package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.js +72 -0
  128. package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.js.map +1 -0
  129. package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.d.ts +2 -0
  130. package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.d.ts.map +1 -0
  131. package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.js +2 -0
  132. package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.js.map +1 -0
  133. package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.d.ts +3 -0
  134. package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.d.ts.map +1 -0
  135. package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.js +254 -0
  136. package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.js.map +1 -0
  137. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts +68 -0
  138. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts.map +1 -0
  139. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js +483 -0
  140. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js.map +1 -0
  141. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.d.ts +26 -0
  142. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.d.ts.map +1 -0
  143. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.js +163 -0
  144. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.js.map +1 -0
  145. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.d.ts +39 -0
  146. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.d.ts.map +1 -0
  147. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.js +212 -0
  148. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.js.map +1 -0
  149. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts +118 -0
  150. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts.map +1 -0
  151. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js +774 -0
  152. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js.map +1 -0
  153. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.d.ts +31 -0
  154. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.d.ts.map +1 -0
  155. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.js +93 -0
  156. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.js.map +1 -0
  157. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.d.ts +33 -0
  158. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.d.ts.map +1 -0
  159. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.js +380 -0
  160. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.js.map +1 -0
  161. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts +11 -0
  162. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts.map +1 -0
  163. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js +59 -0
  164. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js.map +1 -0
  165. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts +10 -0
  166. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts.map +1 -0
  167. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js +75 -0
  168. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js.map +1 -0
  169. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts +111 -0
  170. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts.map +1 -0
  171. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js +522 -0
  172. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js.map +1 -0
  173. package/dist/src/elements/ia-donation-form/ia-donation-form.d.ts +95 -0
  174. package/dist/src/elements/ia-donation-form/ia-donation-form.d.ts.map +1 -0
  175. package/dist/src/elements/ia-donation-form/ia-donation-form.js +522 -0
  176. package/dist/src/elements/ia-donation-form/ia-donation-form.js.map +1 -0
  177. package/dist/src/elements/ia-donation-form/icons/apple-pay.svg +22 -0
  178. package/dist/src/elements/ia-donation-form/icons/calendar.svg +15 -0
  179. package/dist/src/elements/ia-donation-form/icons/credit-card.svg +15 -0
  180. package/dist/src/elements/ia-donation-form/icons/google-pay.svg +38 -0
  181. package/dist/src/elements/ia-donation-form/icons/lock.svg +6 -0
  182. package/dist/src/elements/ia-donation-form/icons/paypal.svg +39 -0
  183. package/dist/src/elements/ia-donation-form/icons/venmo.svg +9 -0
  184. package/dist/src/elements/ia-donation-form/icons.d.ts +9 -0
  185. package/dist/src/elements/ia-donation-form/icons.d.ts.map +1 -0
  186. package/dist/src/elements/ia-donation-form/icons.js +27 -0
  187. package/dist/src/elements/ia-donation-form/icons.js.map +1 -0
  188. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts +27 -0
  189. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts.map +1 -0
  190. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js +195 -0
  191. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js.map +1 -0
  192. package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.d.ts +7 -0
  193. package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.d.ts.map +1 -0
  194. package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.js +63 -0
  195. package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.js.map +1 -0
  196. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts +28 -0
  197. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts.map +1 -0
  198. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js +313 -0
  199. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js.map +1 -0
  200. package/dist/src/elements/ia-donation-form/recaptcha-manager.d.ts +36 -0
  201. package/dist/src/elements/ia-donation-form/recaptcha-manager.d.ts.map +1 -0
  202. package/dist/src/elements/ia-donation-form/recaptcha-manager.js +76 -0
  203. package/dist/src/elements/ia-donation-form/recaptcha-manager.js.map +1 -0
  204. package/dist/src/elements/ia-image-viewer/image-viewer-gestures.d.ts.map +1 -1
  205. package/dist/src/elements/ia-image-viewer/image-viewer-gestures.js +2 -4
  206. package/dist/src/elements/ia-image-viewer/image-viewer-gestures.js.map +1 -1
  207. package/package.json +12 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay-session-datasource-interface.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { DonationPaymentInfo } from '../../../models/donation-payment-info';\nimport type { DonationResponse } from '../../../models/donation-response';\n\n/** Anything interested in how an Apple Pay session ends. */\nexport interface ApplePaySessionDataSourceDelegate {\n paymentComplete(response: DonationResponse): void;\n paymentFailed(error: unknown): void;\n paymentCancelled(): void;\n}\n\n/**\n * Handles the callbacks of one `ApplePaySession`: validating the merchant,\n * submitting the authorized payment, and cancellation.\n */\nexport interface ApplePaySessionDataSourceInterface {\n delegate?: ApplePaySessionDataSourceDelegate;\n donationInfo: DonationPaymentInfo;\n onvalidatemerchant(\n event: ApplePayJS.ApplePayValidateMerchantEvent,\n ): Promise<void>;\n onpaymentauthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n ): Promise<void>;\n oncancel(): Promise<void>;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type * as braintree from 'braintree-web';
2
+ import type { DonationPaymentInfo } from '../../../models/donation-payment-info.js';
3
+ import type { BraintreeManagerInterface } from '../../braintree-manager-interface.js';
4
+ import type { ApplePaySessionDataSourceDelegate, ApplePaySessionDataSourceInterface } from './apple-pay-session-datasource-interface.js';
5
+ export declare class ApplePaySessionDataSource implements ApplePaySessionDataSourceInterface {
6
+ delegate?: ApplePaySessionDataSourceDelegate;
7
+ donationInfo: DonationPaymentInfo;
8
+ private session;
9
+ private applePayInstance;
10
+ private braintreeManager;
11
+ constructor(options: {
12
+ donationInfo: DonationPaymentInfo;
13
+ session: ApplePaySession;
14
+ applePayInstance: braintree.ApplePay;
15
+ braintreeManager: BraintreeManagerInterface;
16
+ });
17
+ onvalidatemerchant(event: ApplePayJS.ApplePayValidateMerchantEvent): Promise<void>;
18
+ oncancel(): Promise<void>;
19
+ onpaymentauthorized(event: ApplePayJS.ApplePayPaymentAuthorizedEvent): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=apple-pay-session-datasource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay-session-datasource.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,KAAK,EACV,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,0CAA0C,CAAC;AAElD,qBAAa,yBACX,YAAW,kCAAkC;IAE7C,QAAQ,CAAC,EAAE,iCAAiC,CAAC;IAC7C,YAAY,EAAE,mBAAmB,CAAC;IAElC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,gBAAgB,CAA4B;gBAExC,OAAO,EAAE;QACnB,YAAY,EAAE,mBAAmB,CAAC;QAClC,OAAO,EAAE,eAAe,CAAC;QACzB,gBAAgB,EAAE,SAAS,CAAC,QAAQ,CAAC;QACrC,gBAAgB,EAAE,yBAAyB,CAAC;KAC7C;IAOK,kBAAkB,CACtB,KAAK,EAAE,UAAU,CAAC,6BAA6B,GAC9C,OAAO,CAAC,IAAI,CAAC;IAqBV,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,mBAAmB,CACvB,KAAK,EAAE,UAAU,CAAC,8BAA8B,GAC/C,OAAO,CAAC,IAAI,CAAC;CAoDjB"}
@@ -0,0 +1,83 @@
1
+ import { BillingInfo, CustomerInfo } from '../../../models/donor-contact-info.js';
2
+ import { PaymentProvider } from '../../../models/payment-provider.js';
3
+ export class ApplePaySessionDataSource {
4
+ constructor(options) {
5
+ this.session = options.session;
6
+ this.donationInfo = options.donationInfo;
7
+ this.applePayInstance = options.applePayInstance;
8
+ this.braintreeManager = options.braintreeManager;
9
+ }
10
+ async onvalidatemerchant(event) {
11
+ return new Promise((resolve, reject) => {
12
+ this.applePayInstance.performValidation({
13
+ validationURL: event.validationURL,
14
+ displayName: 'Internet Archive',
15
+ }, (validationErr, validationData) => {
16
+ if (validationErr) {
17
+ this.delegate?.paymentFailed(validationErr);
18
+ this.session.abort();
19
+ reject(`Merchant validation error: ${validationErr}`);
20
+ }
21
+ else {
22
+ this.session.completeMerchantValidation(validationData);
23
+ resolve();
24
+ }
25
+ });
26
+ });
27
+ }
28
+ async oncancel() {
29
+ this.delegate?.paymentCancelled();
30
+ }
31
+ async onpaymentauthorized(event) {
32
+ let payload;
33
+ try {
34
+ payload = await this.applePayInstance.tokenize({
35
+ token: event.payment.token,
36
+ });
37
+ }
38
+ catch (err) {
39
+ this.delegate?.paymentFailed(err);
40
+ this.session.completePayment(ApplePaySession.STATUS_FAILURE);
41
+ return;
42
+ }
43
+ const payment = event.payment;
44
+ const billingContact = payment.billingContact;
45
+ const shippingContact = payment.shippingContact;
46
+ const [line1, line2] = billingContact?.addressLines ?? [];
47
+ const billingInfo = new BillingInfo({
48
+ streetAddress: line1,
49
+ extendedAddress: line2,
50
+ locality: billingContact?.locality,
51
+ region: billingContact?.administrativeArea,
52
+ postalCode: billingContact?.postalCode,
53
+ countryCodeAlpha2: billingContact?.countryCode,
54
+ });
55
+ const customerInfo = new CustomerInfo({
56
+ email: shippingContact?.emailAddress,
57
+ firstName: shippingContact?.givenName,
58
+ lastName: shippingContact?.familyName,
59
+ });
60
+ try {
61
+ const donationResponse = await this.braintreeManager.submitDonation({
62
+ nonce: payload.nonce,
63
+ paymentProvider: PaymentProvider.ApplePay,
64
+ donationInfo: this.donationInfo,
65
+ billingInfo,
66
+ customerInfo,
67
+ });
68
+ if (donationResponse.success) {
69
+ this.delegate?.paymentComplete(donationResponse);
70
+ this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
71
+ }
72
+ else {
73
+ this.delegate?.paymentFailed('Failure submitting data');
74
+ this.session.completePayment(ApplePaySession.STATUS_FAILURE);
75
+ }
76
+ }
77
+ catch (err) {
78
+ this.delegate?.paymentFailed(err);
79
+ this.session.completePayment(ApplePaySession.STATUS_FAILURE);
80
+ }
81
+ }
82
+ }
83
+ //# sourceMappingURL=apple-pay-session-datasource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay-session-datasource.js","sourceRoot":"","sources":["../../../../../../../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AAC,YAAY;gBAC/B,WAAW;gBACX,YAAY;aACb,CAAC,CAAC;YACH,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAC7B,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC;gBACjD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;gBACxD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF","sourcesContent":["import type * as braintree from 'braintree-web';\n\nimport type { DonationPaymentInfo } from '../../../models/donation-payment-info';\nimport { BillingInfo, CustomerInfo } from '../../../models/donor-contact-info';\nimport { PaymentProvider } from '../../../models/payment-provider';\nimport type { BraintreeManagerInterface } from '../../braintree-manager-interface';\nimport type {\n ApplePaySessionDataSourceDelegate,\n ApplePaySessionDataSourceInterface,\n} from './apple-pay-session-datasource-interface';\n\nexport class ApplePaySessionDataSource\n implements ApplePaySessionDataSourceInterface\n{\n delegate?: ApplePaySessionDataSourceDelegate;\n donationInfo: DonationPaymentInfo;\n\n private session: ApplePaySession;\n private applePayInstance: braintree.ApplePay;\n private braintreeManager: BraintreeManagerInterface;\n\n constructor(options: {\n donationInfo: DonationPaymentInfo;\n session: ApplePaySession;\n applePayInstance: braintree.ApplePay;\n braintreeManager: BraintreeManagerInterface;\n }) {\n this.session = options.session;\n this.donationInfo = options.donationInfo;\n this.applePayInstance = options.applePayInstance;\n this.braintreeManager = options.braintreeManager;\n }\n\n async onvalidatemerchant(\n event: ApplePayJS.ApplePayValidateMerchantEvent,\n ): Promise<void> {\n return new Promise((resolve, reject) => {\n this.applePayInstance.performValidation(\n {\n validationURL: event.validationURL,\n displayName: 'Internet Archive',\n },\n (validationErr, validationData) => {\n if (validationErr) {\n this.delegate?.paymentFailed(validationErr);\n this.session.abort();\n reject(`Merchant validation error: ${validationErr}`);\n } else {\n this.session.completeMerchantValidation(validationData);\n resolve();\n }\n },\n );\n });\n }\n\n async oncancel(): Promise<void> {\n this.delegate?.paymentCancelled();\n }\n\n async onpaymentauthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n ): Promise<void> {\n let payload: braintree.ApplePayPayload;\n try {\n payload = await this.applePayInstance.tokenize({\n token: event.payment.token,\n });\n } catch (err) {\n this.delegate?.paymentFailed(err);\n this.session.completePayment(ApplePaySession.STATUS_FAILURE);\n return;\n }\n\n const payment = event.payment;\n const billingContact = payment.billingContact;\n const shippingContact = payment.shippingContact;\n const [line1, line2] = billingContact?.addressLines ?? [];\n\n const billingInfo = new BillingInfo({\n streetAddress: line1,\n extendedAddress: line2,\n locality: billingContact?.locality,\n region: billingContact?.administrativeArea,\n postalCode: billingContact?.postalCode,\n countryCodeAlpha2: billingContact?.countryCode,\n });\n\n const customerInfo = new CustomerInfo({\n email: shippingContact?.emailAddress,\n firstName: shippingContact?.givenName,\n lastName: shippingContact?.familyName,\n });\n\n try {\n const donationResponse = await this.braintreeManager.submitDonation({\n nonce: payload.nonce,\n paymentProvider: PaymentProvider.ApplePay,\n donationInfo: this.donationInfo,\n billingInfo,\n customerInfo,\n });\n if (donationResponse.success) {\n this.delegate?.paymentComplete(donationResponse);\n this.session.completePayment(ApplePaySession.STATUS_SUCCESS);\n } else {\n this.delegate?.paymentFailed('Failure submitting data');\n this.session.completePayment(ApplePaySession.STATUS_FAILURE);\n }\n } catch (err) {\n this.delegate?.paymentFailed(err);\n this.session.completePayment(ApplePaySession.STATUS_FAILURE);\n }\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export interface ApplePaySessionManagerInterface {
2
+ canMakePayments(): boolean;
3
+ createNewPaymentSession(paymentRequest: ApplePayJS.ApplePayPaymentRequest): ApplePaySession;
4
+ }
5
+ /** A thin wrapper over the browser's `ApplePaySession` so it can be mocked. */
6
+ export declare class ApplePaySessionManager implements ApplePaySessionManagerInterface {
7
+ static VERSION: number;
8
+ canMakePayments(): boolean;
9
+ createNewPaymentSession(paymentRequest: ApplePayJS.ApplePayPaymentRequest): ApplePaySession;
10
+ }
11
+ //# sourceMappingURL=apple-pay-session-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay-session-manager.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,+BAA+B;IAC9C,eAAe,IAAI,OAAO,CAAC;IAC3B,uBAAuB,CACrB,cAAc,EAAE,UAAU,CAAC,sBAAsB,GAChD,eAAe,CAAC;CACpB;AAED,+EAA+E;AAC/E,qBAAa,sBAAuB,YAAW,+BAA+B;IAC5E,MAAM,CAAC,OAAO,SAAK;IAEnB,eAAe,IAAI,OAAO;IAQ1B,uBAAuB,CACrB,cAAc,EAAE,UAAU,CAAC,sBAAsB,GAChD,eAAe;CAGnB"}
@@ -0,0 +1,13 @@
1
+ /** A thin wrapper over the browser's `ApplePaySession` so it can be mocked. */
2
+ export class ApplePaySessionManager {
3
+ canMakePayments() {
4
+ return ('ApplePaySession' in window &&
5
+ ApplePaySession.supportsVersion(ApplePaySessionManager.VERSION) &&
6
+ ApplePaySession.canMakePayments());
7
+ }
8
+ createNewPaymentSession(paymentRequest) {
9
+ return new ApplePaySession(ApplePaySessionManager.VERSION, paymentRequest);
10
+ }
11
+ }
12
+ ApplePaySessionManager.VERSION = 3;
13
+ //# sourceMappingURL=apple-pay-session-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay-session-manager.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.ts"],"names":[],"mappings":"AAOA,+EAA+E;AAC/E,MAAM,OAAO,sBAAsB;IAGjC,eAAe;QACb,OAAO,CACL,iBAAiB,IAAI,MAAM;YAC3B,eAAe,CAAC,eAAe,CAAC,sBAAsB,CAAC,OAAO,CAAC;YAC/D,eAAe,CAAC,eAAe,EAAE,CAClC,CAAC;IACJ,CAAC;IAED,uBAAuB,CACrB,cAAiD;QAEjD,OAAO,IAAI,eAAe,CAAC,sBAAsB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC7E,CAAC;;AAdM,8BAAO,GAAG,CAAC,CAAC","sourcesContent":["export interface ApplePaySessionManagerInterface {\n canMakePayments(): boolean;\n createNewPaymentSession(\n paymentRequest: ApplePayJS.ApplePayPaymentRequest,\n ): ApplePaySession;\n}\n\n/** A thin wrapper over the browser's `ApplePaySession` so it can be mocked. */\nexport class ApplePaySessionManager implements ApplePaySessionManagerInterface {\n static VERSION = 3;\n\n canMakePayments(): boolean {\n return (\n 'ApplePaySession' in window &&\n ApplePaySession.supportsVersion(ApplePaySessionManager.VERSION) &&\n ApplePaySession.canMakePayments()\n );\n }\n\n createNewPaymentSession(\n paymentRequest: ApplePayJS.ApplePayPaymentRequest,\n ): ApplePaySession {\n return new ApplePaySession(ApplePaySessionManager.VERSION, paymentRequest);\n }\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import type * as braintree from 'braintree-web';
2
+ import { PromisedSingleton } from '@internetarchive/promised-singleton';
3
+ import type { DonationPaymentInfo } from '../../../models/donation-payment-info.js';
4
+ import type { BraintreeManagerInterface } from '../../braintree-manager-interface.js';
5
+ import type { ApplePayHandlerInterface } from './apple-pay-interface.js';
6
+ import { ApplePaySessionDataSource } from './apple-pay-session-datasource.js';
7
+ import type { ApplePaySessionManagerInterface } from './apple-pay-session-manager.js';
8
+ export declare class ApplePayHandler implements ApplePayHandlerInterface {
9
+ instance: PromisedSingleton<braintree.ApplePay | undefined>;
10
+ constructor(options: {
11
+ braintreeManager: BraintreeManagerInterface;
12
+ applePayClient: typeof braintree.applePay;
13
+ applePaySessionManager: ApplePaySessionManagerInterface;
14
+ instancePromisedSingleton?: PromisedSingleton<braintree.ApplePay | undefined>;
15
+ });
16
+ private braintreeManager;
17
+ private applePaySessionManager;
18
+ private applePayClient;
19
+ isAvailable(): Promise<boolean>;
20
+ /**
21
+ * Starts the Apple Pay sheet. The event that triggered it has to be passed
22
+ * in, even though nothing here reads it: Apple Pay refuses to launch outside
23
+ * a user gesture.
24
+ */
25
+ createPaymentRequest(_e: Event, donationInfo: DonationPaymentInfo): Promise<ApplePaySessionDataSource>;
26
+ }
27
+ //# sourceMappingURL=apple-pay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAEjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAEnF,qBAAa,eAAgB,YAAW,wBAAwB;IAC9D,QAAQ,EAAE,iBAAiB,CAAC,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;gBAEhD,OAAO,EAAE;QACnB,gBAAgB,EAAE,yBAAyB,CAAC;QAC5C,cAAc,EAAE,OAAO,SAAS,CAAC,QAAQ,CAAC;QAC1C,sBAAsB,EAAE,+BAA+B,CAAC;QACxD,yBAAyB,CAAC,EAAE,iBAAiB,CAC3C,SAAS,CAAC,QAAQ,GAAG,SAAS,CAC/B,CAAC;KACH;IAmBD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,sBAAsB,CAAkC;IAEhE,OAAO,CAAC,cAAc,CAA4B;IAE5C,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;;;OAIG;IACG,oBAAoB,CACxB,EAAE,EAAE,KAAK,EACT,YAAY,EAAE,mBAAmB,GAChC,OAAO,CAAC,yBAAyB,CAAC;CAwCtC"}
@@ -0,0 +1,67 @@
1
+ import { PromisedSingleton } from '@internetarchive/promised-singleton';
2
+ import { DonationType } from '../../../models/donation-type.js';
3
+ import { ApplePaySessionDataSource } from './apple-pay-session-datasource.js';
4
+ export class ApplePayHandler {
5
+ constructor(options) {
6
+ this.braintreeManager = options.braintreeManager;
7
+ this.applePayClient = options.applePayClient;
8
+ this.applePaySessionManager = options.applePaySessionManager;
9
+ this.instance =
10
+ options.instancePromisedSingleton ??
11
+ new PromisedSingleton({
12
+ generator: async () => {
13
+ if (!this.applePaySessionManager.canMakePayments()) {
14
+ return undefined;
15
+ }
16
+ const braintreeClient = await this.braintreeManager.instance.get();
17
+ return this.applePayClient.create({ client: braintreeClient });
18
+ },
19
+ });
20
+ }
21
+ async isAvailable() {
22
+ try {
23
+ const instance = await this.instance.get();
24
+ return !!instance;
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
30
+ /**
31
+ * Starts the Apple Pay sheet. The event that triggered it has to be passed
32
+ * in, even though nothing here reads it: Apple Pay refuses to launch outside
33
+ * a user gesture.
34
+ */
35
+ async createPaymentRequest(_e, donationInfo) {
36
+ const applePayInstance = await this.instance.get();
37
+ if (!applePayInstance) {
38
+ throw new Error('Apple Pay is not available in this browser');
39
+ }
40
+ const label = donationInfo.donationType === DonationType.OneTime
41
+ ? 'Internet Archive'
42
+ : 'Internet Archive Monthly';
43
+ const paymentRequest = applePayInstance.createPaymentRequest({
44
+ total: {
45
+ label,
46
+ amount: `${donationInfo.total}`,
47
+ },
48
+ requiredBillingContactFields: ['postalAddress'],
49
+ requiredShippingContactFields: ['name', 'email'],
50
+ });
51
+ const session = this.applePaySessionManager.createNewPaymentSession(paymentRequest);
52
+ const sessionDataSource = new ApplePaySessionDataSource({
53
+ donationInfo,
54
+ session,
55
+ applePayInstance,
56
+ braintreeManager: this.braintreeManager,
57
+ });
58
+ session.onvalidatemerchant =
59
+ sessionDataSource.onvalidatemerchant.bind(sessionDataSource);
60
+ session.onpaymentauthorized =
61
+ sessionDataSource.onpaymentauthorized.bind(sessionDataSource);
62
+ session.oncancel = sessionDataSource.oncancel.bind(sessionDataSource);
63
+ session.begin();
64
+ return sessionDataSource;
65
+ }
66
+ }
67
+ //# sourceMappingURL=apple-pay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,MAAM,OAAO,eAAe;IAG1B,YAAY,OAOX;QACC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;QAE7D,IAAI,CAAC,QAAQ;YACX,OAAO,CAAC,yBAAyB;gBACjC,IAAI,iBAAiB,CAAiC;oBACpD,SAAS,EAAE,KAAK,IAAI,EAAE;wBACpB,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,eAAe,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yBAAyB,CAAC;YACtD,YAAY;YACZ,OAAO;YACP,gBAAgB;YAChB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC,CAAC;QAEH,OAAO,CAAC,kBAAkB;YACxB,iBAAiB,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/D,OAAO,CAAC,mBAAmB;YACzB,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChE,OAAO,CAAC,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEtE,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import type * as braintree from 'braintree-web';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\n\nimport type { DonationPaymentInfo } from '../../../models/donation-payment-info';\nimport { DonationType } from '../../../models/donation-type';\nimport type { BraintreeManagerInterface } from '../../braintree-manager-interface';\nimport type { ApplePayHandlerInterface } from './apple-pay-interface';\nimport { ApplePaySessionDataSource } from './apple-pay-session-datasource';\nimport type { ApplePaySessionManagerInterface } from './apple-pay-session-manager';\n\nexport class ApplePayHandler implements ApplePayHandlerInterface {\n instance: PromisedSingleton<braintree.ApplePay | undefined>;\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n applePayClient: typeof braintree.applePay;\n applePaySessionManager: ApplePaySessionManagerInterface;\n instancePromisedSingleton?: PromisedSingleton<\n braintree.ApplePay | undefined\n >;\n }) {\n this.braintreeManager = options.braintreeManager;\n this.applePayClient = options.applePayClient;\n this.applePaySessionManager = options.applePaySessionManager;\n\n this.instance =\n options.instancePromisedSingleton ??\n new PromisedSingleton<braintree.ApplePay | undefined>({\n generator: async () => {\n if (!this.applePaySessionManager.canMakePayments()) {\n return undefined;\n }\n\n const braintreeClient = await this.braintreeManager.instance.get();\n return this.applePayClient.create({ client: braintreeClient });\n },\n });\n }\n\n private braintreeManager: BraintreeManagerInterface;\n\n private applePaySessionManager: ApplePaySessionManagerInterface;\n\n private applePayClient: typeof braintree.applePay;\n\n async isAvailable(): Promise<boolean> {\n try {\n const instance = await this.instance.get();\n return !!instance;\n } catch {\n return false;\n }\n }\n\n /**\n * Starts the Apple Pay sheet. The event that triggered it has to be passed\n * in, even though nothing here reads it: Apple Pay refuses to launch outside\n * a user gesture.\n */\n async createPaymentRequest(\n _e: Event,\n donationInfo: DonationPaymentInfo,\n ): Promise<ApplePaySessionDataSource> {\n const applePayInstance = await this.instance.get();\n if (!applePayInstance) {\n throw new Error('Apple Pay is not available in this browser');\n }\n\n const label =\n donationInfo.donationType === DonationType.OneTime\n ? 'Internet Archive'\n : 'Internet Archive Monthly';\n\n const paymentRequest = applePayInstance.createPaymentRequest({\n total: {\n label,\n amount: `${donationInfo.total}`,\n },\n requiredBillingContactFields: ['postalAddress'],\n requiredShippingContactFields: ['name', 'email'],\n });\n const session = this.applePaySessionManager.createNewPaymentSession(\n paymentRequest as ApplePayJS.ApplePayPaymentRequest,\n );\n\n const sessionDataSource = new ApplePaySessionDataSource({\n donationInfo,\n session,\n applePayInstance,\n braintreeManager: this.braintreeManager,\n });\n\n session.onvalidatemerchant =\n sessionDataSource.onvalidatemerchant.bind(sessionDataSource);\n session.onpaymentauthorized =\n sessionDataSource.onpaymentauthorized.bind(sessionDataSource);\n session.oncancel = sessionDataSource.oncancel.bind(sessionDataSource);\n\n session.begin();\n\n return sessionDataSource;\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type * as braintree from 'braintree-web';
2
+ import type { PromisedSingleton } from '@internetarchive/promised-singleton';
3
+ import type { Unsubscribe } from 'nanoevents';
4
+ import type { HostedFieldName } from './hosted-field-container.js';
5
+ export interface CreditCardHandlerEvents {
6
+ hostedFieldsRetry: (retryNumber: number) => void;
7
+ hostedFieldsFailed: (error: unknown) => void;
8
+ }
9
+ export interface CreditCardHandlerInterface {
10
+ instance: PromisedSingleton<braintree.HostedFields | undefined>;
11
+ tokenizeHostedFields(): Promise<braintree.HostedFieldsTokenizePayload | undefined>;
12
+ focusField(field: HostedFieldName): Promise<void>;
13
+ markFieldErrors(fields: HostedFieldName[]): void;
14
+ removeFieldErrors(fields: HostedFieldName[]): void;
15
+ showErrorMessage(message?: string): void;
16
+ hideErrorMessage(): void;
17
+ on<E extends keyof CreditCardHandlerEvents>(event: E, callback: CreditCardHandlerEvents[E]): Unsubscribe;
18
+ }
19
+ //# sourceMappingURL=credit-card-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-card-interface.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,iBAAiB,CAAC,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;IAChE,oBAAoB,IAAI,OAAO,CAC7B,SAAS,CAAC,2BAA2B,GAAG,SAAS,CAClD,CAAC;IACF,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IACjD,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IACnD,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,gBAAgB,IAAI,IAAI,CAAC;IACzB,EAAE,CAAC,CAAC,SAAS,MAAM,uBAAuB,EACxC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACnC,WAAW,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=credit-card-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-card-interface.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type * as braintree from 'braintree-web';\nimport type { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport type { Unsubscribe } from 'nanoevents';\n\nimport type { HostedFieldName } from './hosted-field-container';\n\nexport interface CreditCardHandlerEvents {\n hostedFieldsRetry: (retryNumber: number) => void;\n hostedFieldsFailed: (error: unknown) => void;\n}\n\nexport interface CreditCardHandlerInterface {\n instance: PromisedSingleton<braintree.HostedFields | undefined>;\n tokenizeHostedFields(): Promise<\n braintree.HostedFieldsTokenizePayload | undefined\n >;\n focusField(field: HostedFieldName): Promise<void>;\n markFieldErrors(fields: HostedFieldName[]): void;\n removeFieldErrors(fields: HostedFieldName[]): void;\n showErrorMessage(message?: string): void;\n hideErrorMessage(): void;\n on<E extends keyof CreditCardHandlerEvents>(\n event: E,\n callback: CreditCardHandlerEvents[E],\n ): Unsubscribe;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import type * as braintree from 'braintree-web';
2
+ import { PromisedSingleton } from '@internetarchive/promised-singleton';
3
+ import { type Unsubscribe } from 'nanoevents';
4
+ import type { BraintreeManagerInterface } from '../../braintree-manager-interface.js';
5
+ import type { CreditCardHandlerEvents, CreditCardHandlerInterface } from './credit-card-interface.js';
6
+ import type { HostedFieldConfiguration } from './hosted-field-configuration.js';
7
+ import type { HostedFieldName } from './hosted-field-container.js';
8
+ export declare class CreditCardHandler implements CreditCardHandlerInterface {
9
+ on<E extends keyof CreditCardHandlerEvents>(event: E, callback: CreditCardHandlerEvents[E]): Unsubscribe;
10
+ instance: PromisedSingleton<braintree.HostedFields | undefined>;
11
+ private emitter;
12
+ private maxRetryCount;
13
+ /** In milliseconds */
14
+ private loadTimeout;
15
+ constructor(options: {
16
+ braintreeManager: BraintreeManagerInterface;
17
+ hostedFieldClient: typeof braintree.hostedFields;
18
+ hostedFieldConfig: HostedFieldConfiguration;
19
+ maxRetryCount?: number;
20
+ /** In seconds */
21
+ loadTimeout?: number;
22
+ });
23
+ private braintreeManager;
24
+ private hostedFieldClient;
25
+ private hostedFieldConfig;
26
+ /**
27
+ * Creates the hosted fields, retrying on a timeout.
28
+ *
29
+ * Braintree's own timeout is 60 seconds, but their support recommends a
30
+ * shorter one: 99% of donors load the fields within 4 seconds and 99.9%
31
+ * within 18. So this races the create against its own timer, and a timer
32
+ * win throws into the retry path.
33
+ */
34
+ private createHostedFields;
35
+ tokenizeHostedFields(): Promise<braintree.HostedFieldsTokenizePayload | undefined>;
36
+ focusField(field: HostedFieldName): Promise<void>;
37
+ markFieldErrors(fields: HostedFieldName[]): void;
38
+ removeFieldErrors(fields: HostedFieldName[]): void;
39
+ showErrorMessage(message?: string): void;
40
+ hideErrorMessage(): void;
41
+ }
42
+ //# sourceMappingURL=credit-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-card.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAGhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,K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/promised-singleton';
2
+ import { createNanoEvents } from 'nanoevents';
3
+ import { DonationFormError } from '../../../donation-form-error.js';
4
+ /** A promise that never settles, for a race branch that should be decided elsewhere. */
5
+ const never = new Promise(() => { });
6
+ export class CreditCardHandler {
7
+ on(event, callback) {
8
+ return this.emitter.on(event, callback);
9
+ }
10
+ constructor(options) {
11
+ this.instance = new PromisedSingleton({
12
+ generator: async () => {
13
+ const braintreeClient = await this.braintreeManager.instance.get();
14
+ return this.createHostedFields(braintreeClient);
15
+ },
16
+ });
17
+ this.emitter = createNanoEvents();
18
+ this.braintreeManager = options.braintreeManager;
19
+ this.hostedFieldClient = options.hostedFieldClient;
20
+ this.hostedFieldConfig = options.hostedFieldConfig;
21
+ this.maxRetryCount = options.maxRetryCount ?? 2;
22
+ this.loadTimeout = (options.loadTimeout ?? 6) * 1000;
23
+ }
24
+ /**
25
+ * Creates the hosted fields, retrying on a timeout.
26
+ *
27
+ * Braintree's own timeout is 60 seconds, but their support recommends a
28
+ * shorter one: 99% of donors load the fields within 4 seconds and 99.9%
29
+ * within 18. So this races the create against its own timer, and a timer
30
+ * win throws into the retry path.
31
+ */
32
+ async createHostedFields(braintreeClient, retryCount = 0) {
33
+ // Mainly for the retries, but harmless on the first try
34
+ this.hostedFieldConfig.hostedFieldContainer.resetHostedFields();
35
+ let timeout;
36
+ try {
37
+ const timeoutPromise = new Promise((_resolve, reject) => {
38
+ timeout = window.setTimeout(() => {
39
+ reject(new DonationFormError('Timeout loading Hosted Fields'));
40
+ }, this.loadTimeout);
41
+ });
42
+ // Starts from a resolved promise so a synchronous throw from `create`
43
+ // becomes a rejection like any other failure.
44
+ const hostedFieldsPromise = Promise.resolve()
45
+ .then(() => this.hostedFieldClient.create({
46
+ client: braintreeClient,
47
+ styles: this.hostedFieldConfig.hostedFieldStyle,
48
+ fields: this.hostedFieldConfig.hostedFieldFieldOptions,
49
+ }))
50
+ .catch((error) => {
51
+ if (error instanceof Error &&
52
+ error.message.includes('Hosted Fields timed out')) {
53
+ // Braintree's own timeout, which the timer above has already
54
+ // turned into a retry. Nothing more to do with it.
55
+ return never;
56
+ }
57
+ // Anything else is a real failure, which should reach Sentry
58
+ throw error;
59
+ });
60
+ // If the timer wins the race, a later rejection here has nowhere to go
61
+ hostedFieldsPromise.catch(() => undefined);
62
+ return await Promise.race([timeoutPromise, hostedFieldsPromise]);
63
+ }
64
+ catch (error) {
65
+ if (retryCount >= this.maxRetryCount) {
66
+ this.emitter.emit('hostedFieldsFailed', error);
67
+ throw error;
68
+ }
69
+ const newRetryCount = retryCount + 1;
70
+ this.emitter.emit('hostedFieldsRetry', newRetryCount);
71
+ return this.createHostedFields(braintreeClient, newRetryCount);
72
+ }
73
+ finally {
74
+ // Whichever way it went, the timer must not fire afterwards
75
+ window.clearTimeout(timeout);
76
+ }
77
+ }
78
+ async tokenizeHostedFields() {
79
+ const hostedFields = await this.instance.get();
80
+ return hostedFields?.tokenize();
81
+ }
82
+ async focusField(field) {
83
+ const hostedFields = await this.instance.get();
84
+ await hostedFields?.focus(field);
85
+ }
86
+ markFieldErrors(fields) {
87
+ this.hostedFieldConfig.hostedFieldContainer.markFieldErrors(fields);
88
+ }
89
+ removeFieldErrors(fields) {
90
+ this.hostedFieldConfig.hostedFieldContainer.removeFieldErrors(fields);
91
+ }
92
+ showErrorMessage(message) {
93
+ this.hostedFieldConfig.hostedFieldContainer.showErrorMessage(message);
94
+ }
95
+ hideErrorMessage() {
96
+ this.hostedFieldConfig.hostedFieldContainer.hideErrorMessage();
97
+ }
98
+ }
99
+ //# sourceMappingURL=credit-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-card.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAoB,MAAM,YAAY,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAA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CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC;gBAAS,CAAC;YACT,4DAA4D;YAC5D,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,oBAAoB;QAGxB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC/C,OAAO,YAAY,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAsB;QACrC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC/C,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,eAAe,CAAC,MAAyB;QACvC,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAED,iBAAiB,CAAC,MAAyB;QACzC,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,gBAAgB,CAAC,OAAgB;QAC/B,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,CAAC;IACjE,CAAC;CACF","sourcesContent":["import type * as braintree from 'braintree-web';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport { createNanoEvents, type Unsubscribe } from 'nanoevents';\n\nimport { DonationFormError } from '../../../donation-form-error';\nimport type { BraintreeManagerInterface } from '../../braintree-manager-interface';\nimport type {\n CreditCardHandlerEvents,\n CreditCardHandlerInterface,\n} from './credit-card-interface';\nimport type { HostedFieldConfiguration } from './hosted-field-configuration';\nimport type { HostedFieldName } from './hosted-field-container';\n\n/** A promise that never settles, for a race branch that should be decided elsewhere. */\nconst never = new Promise<never>(() => {});\n\nexport class CreditCardHandler implements CreditCardHandlerInterface {\n on<E extends keyof CreditCardHandlerEvents>(\n event: E,\n callback: CreditCardHandlerEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n instance = new PromisedSingleton<braintree.HostedFields | undefined>({\n generator: async () => {\n const braintreeClient = await this.braintreeManager.instance.get();\n return this.createHostedFields(braintreeClient);\n },\n });\n\n private emitter = createNanoEvents<CreditCardHandlerEvents>();\n\n private maxRetryCount: number;\n\n /** In milliseconds */\n private loadTimeout: number;\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n hostedFieldClient: typeof braintree.hostedFields;\n hostedFieldConfig: HostedFieldConfiguration;\n maxRetryCount?: number;\n /** In seconds */\n loadTimeout?: number;\n }) {\n this.braintreeManager = options.braintreeManager;\n this.hostedFieldClient = options.hostedFieldClient;\n this.hostedFieldConfig = options.hostedFieldConfig;\n this.maxRetryCount = options.maxRetryCount ?? 2;\n this.loadTimeout = (options.loadTimeout ?? 6) * 1000;\n }\n\n private braintreeManager: BraintreeManagerInterface;\n private hostedFieldClient: typeof braintree.hostedFields;\n private hostedFieldConfig: HostedFieldConfiguration;\n\n /**\n * Creates the hosted fields, retrying on a timeout.\n *\n * Braintree's own timeout is 60 seconds, but their support recommends a\n * shorter one: 99% of donors load the fields within 4 seconds and 99.9%\n * within 18. So this races the create against its own timer, and a timer\n * win throws into the retry path.\n */\n private async createHostedFields(\n braintreeClient: braintree.Client,\n retryCount = 0,\n ): Promise<braintree.HostedFields | undefined> {\n // Mainly for the retries, but harmless on the first try\n this.hostedFieldConfig.hostedFieldContainer.resetHostedFields();\n let timeout: number | undefined;\n try {\n const timeoutPromise = new Promise<never>((_resolve, reject) => {\n timeout = window.setTimeout(() => {\n reject(new DonationFormError('Timeout loading Hosted Fields'));\n }, this.loadTimeout);\n });\n\n // Starts from a resolved promise so a synchronous throw from `create`\n // becomes a rejection like any other failure.\n const hostedFieldsPromise = Promise.resolve()\n .then(() =>\n this.hostedFieldClient.create({\n client: braintreeClient,\n styles: this.hostedFieldConfig.hostedFieldStyle,\n fields: this.hostedFieldConfig.hostedFieldFieldOptions,\n }),\n )\n .catch((error: unknown) => {\n if (\n error instanceof Error &&\n error.message.includes('Hosted Fields timed out')\n ) {\n // Braintree's own timeout, which the timer above has already\n // turned into a retry. Nothing more to do with it.\n return never;\n }\n // Anything else is a real failure, which should reach Sentry\n throw error;\n });\n // If the timer wins the race, a later rejection here has nowhere to go\n hostedFieldsPromise.catch(() => undefined);\n\n return await Promise.race([timeoutPromise, hostedFieldsPromise]);\n } catch (error) {\n if (retryCount >= this.maxRetryCount) {\n this.emitter.emit('hostedFieldsFailed', error);\n throw error;\n }\n const newRetryCount = retryCount + 1;\n this.emitter.emit('hostedFieldsRetry', newRetryCount);\n return this.createHostedFields(braintreeClient, newRetryCount);\n } finally {\n // Whichever way it went, the timer must not fire afterwards\n window.clearTimeout(timeout);\n }\n }\n\n async tokenizeHostedFields(): Promise<\n braintree.HostedFieldsTokenizePayload | undefined\n > {\n const hostedFields = await this.instance.get();\n return hostedFields?.tokenize();\n }\n\n async focusField(field: HostedFieldName): Promise<void> {\n const hostedFields = await this.instance.get();\n await hostedFields?.focus(field);\n }\n\n markFieldErrors(fields: HostedFieldName[]): void {\n this.hostedFieldConfig.hostedFieldContainer.markFieldErrors(fields);\n }\n\n removeFieldErrors(fields: HostedFieldName[]): void {\n this.hostedFieldConfig.hostedFieldContainer.removeFieldErrors(fields);\n }\n\n showErrorMessage(message?: string): void {\n this.hostedFieldConfig.hostedFieldContainer.showErrorMessage(message);\n }\n\n hideErrorMessage(): void {\n this.hostedFieldConfig.hostedFieldContainer.hideErrorMessage();\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type * as braintree from 'braintree-web';
2
+ import type { HostedFieldContainerInterface } from './hosted-field-container.js';
3
+ /** Everything Braintree needs to render its hosted credit card fields into the form. */
4
+ export declare class HostedFieldConfiguration {
5
+ hostedFieldStyle: Record<string, Record<string, string>>;
6
+ hostedFieldFieldOptions: braintree.HostedFieldFieldOptions;
7
+ hostedFieldContainer: HostedFieldContainerInterface;
8
+ constructor(options: {
9
+ hostedFieldStyle: Record<string, Record<string, string>>;
10
+ hostedFieldFieldOptions: braintree.HostedFieldFieldOptions;
11
+ hostedFieldContainer: HostedFieldContainerInterface;
12
+ });
13
+ }
14
+ //# sourceMappingURL=hosted-field-configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-field-configuration.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAE9E,wFAAwF;AACxF,qBAAa,wBAAwB;IACnC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEzD,uBAAuB,EAAE,SAAS,CAAC,uBAAuB,CAAC;IAE3D,oBAAoB,EAAE,6BAA6B,CAAC;gBAExC,OAAO,EAAE;QACnB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACzD,uBAAuB,EAAE,SAAS,CAAC,uBAAuB,CAAC;QAC3D,oBAAoB,EAAE,6BAA6B,CAAC;KACrD;CAKF"}
@@ -0,0 +1,9 @@
1
+ /** Everything Braintree needs to render its hosted credit card fields into the form. */
2
+ export class HostedFieldConfiguration {
3
+ constructor(options) {
4
+ this.hostedFieldFieldOptions = options.hostedFieldFieldOptions;
5
+ this.hostedFieldStyle = options.hostedFieldStyle;
6
+ this.hostedFieldContainer = options.hostedFieldContainer;
7
+ }
8
+ }
9
+ //# sourceMappingURL=hosted-field-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-field-configuration.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.ts"],"names":[],"mappings":"AAIA,wFAAwF;AACxF,MAAM,OAAO,wBAAwB;IAOnC,YAAY,OAIX;QACC,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAC/D,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAC3D,CAAC;CACF","sourcesContent":["import type * as braintree from 'braintree-web';\n\nimport type { HostedFieldContainerInterface } from './hosted-field-container';\n\n/** Everything Braintree needs to render its hosted credit card fields into the form. */\nexport class HostedFieldConfiguration {\n hostedFieldStyle: Record<string, Record<string, string>>;\n\n hostedFieldFieldOptions: braintree.HostedFieldFieldOptions;\n\n hostedFieldContainer: HostedFieldContainerInterface;\n\n constructor(options: {\n hostedFieldStyle: Record<string, Record<string, string>>;\n hostedFieldFieldOptions: braintree.HostedFieldFieldOptions;\n hostedFieldContainer: HostedFieldContainerInterface;\n }) {\n this.hostedFieldFieldOptions = options.hostedFieldFieldOptions;\n this.hostedFieldStyle = options.hostedFieldStyle;\n this.hostedFieldContainer = options.hostedFieldContainer;\n }\n}\n"]}
@@ -0,0 +1,40 @@
1
+ /** The three hosted credit card fields. The values are Braintree's field names. */
2
+ export declare const HostedFieldName: {
3
+ readonly Number: "number";
4
+ readonly CVV: "cvv";
5
+ readonly ExpirationDate: "expirationDate";
6
+ };
7
+ export type HostedFieldName = (typeof HostedFieldName)[keyof typeof HostedFieldName];
8
+ export interface HostedFieldContainerInterface {
9
+ fieldFor(field: HostedFieldName): HTMLDivElement;
10
+ markFieldErrors(fields: HostedFieldName[]): void;
11
+ removeFieldErrors(fields: HostedFieldName[]): void;
12
+ showErrorMessage(message?: string): void;
13
+ hideErrorMessage(): void;
14
+ /** Empty the hosted field containers so they can be re-rendered after a timeout */
15
+ resetHostedFields(): void;
16
+ }
17
+ /**
18
+ * Holds the DOM containers Braintree renders its hosted fields into, and
19
+ * toggles their error state. Each container's parent is the badged input
20
+ * wrapping it, which is what shows the error.
21
+ */
22
+ export declare class HostedFieldContainer implements HostedFieldContainerInterface {
23
+ private number;
24
+ private cvv;
25
+ private expirationDate;
26
+ private errorContainer;
27
+ fieldFor(field: HostedFieldName): HTMLDivElement;
28
+ markFieldErrors(fields: HostedFieldName[]): void;
29
+ removeFieldErrors(fields: HostedFieldName[]): void;
30
+ showErrorMessage(message?: string): void;
31
+ hideErrorMessage(): void;
32
+ resetHostedFields(): void;
33
+ constructor(options: {
34
+ number: HTMLDivElement;
35
+ cvv: HTMLDivElement;
36
+ expirationDate: HTMLDivElement;
37
+ errorContainer: HTMLDivElement;
38
+ });
39
+ }
40
+ //# sourceMappingURL=hosted-field-container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-field-container.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,eAAe,GACzB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAUzD,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,cAAc,CAAC;IACjD,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IACjD,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IACnD,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,gBAAgB,IAAI,IAAI,CAAC;IACzB,mFAAmF;IACnF,iBAAiB,IAAI,IAAI,CAAC;CAC3B;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,6BAA6B;IACxE,OAAO,CAAC,MAAM,CAAiB;IAE/B,OAAO,CAAC,GAAG,CAAiB;IAE5B,OAAO,CAAC,cAAc,CAAiB;IAEvC,OAAO,CAAC,cAAc,CAAiB;IAEvC,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,cAAc;IAWhD,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI;IAOhD,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI;IAOlD,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAOxC,gBAAgB,IAAI,IAAI;IAIxB,iBAAiB,IAAI,IAAI;gBASb,OAAO,EAAE;QACnB,MAAM,EAAE,cAAc,CAAC;QACvB,GAAG,EAAE,cAAc,CAAC;QACpB,cAAc,EAAE,cAAc,CAAC;QAC/B,cAAc,EAAE,cAAc,CAAC;KAChC;CAMF"}