@metamask/ramps-controller 20.3.0 → 22.0.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 (290) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/dist/{NeoBankService-method-action-types.d.mts → NeoBankService-method-action-types.d.ts} +2 -2
  3. package/dist/NeoBankService-method-action-types.d.ts.map +1 -0
  4. package/dist/{NeoBankService-method-action-types.mjs → NeoBankService-method-action-types.js} +1 -1
  5. package/dist/NeoBankService-method-action-types.js.map +1 -0
  6. package/dist/{NeoBankService.d.cts → NeoBankService.d.ts} +8 -8
  7. package/dist/NeoBankService.d.ts.map +1 -0
  8. package/dist/NeoBankService.js +380 -0
  9. package/dist/NeoBankService.js.map +1 -0
  10. package/dist/{RampsController-method-action-types.d.mts → RampsController-method-action-types.d.ts} +18 -3
  11. package/dist/RampsController-method-action-types.d.ts.map +1 -0
  12. package/dist/{TransakService-method-action-types.mjs → RampsController-method-action-types.js} +1 -1
  13. package/dist/RampsController-method-action-types.js.map +1 -0
  14. package/dist/{RampsController.d.mts → RampsController.d.ts} +86 -23
  15. package/dist/RampsController.d.ts.map +1 -0
  16. package/dist/{RampsController.mjs → RampsController.js} +976 -634
  17. package/dist/RampsController.js.map +1 -0
  18. package/dist/{RampsService-method-action-types.d.cts → RampsService-method-action-types.d.ts} +2 -2
  19. package/dist/RampsService-method-action-types.d.ts.map +1 -0
  20. package/dist/{RampsService-method-action-types.mjs → RampsService-method-action-types.js} +1 -1
  21. package/dist/RampsService-method-action-types.js.map +1 -0
  22. package/dist/{RampsService.d.mts → RampsService.d.ts} +11 -5
  23. package/dist/RampsService.d.ts.map +1 -0
  24. package/dist/{RampsService.mjs → RampsService.js} +159 -147
  25. package/dist/RampsService.js.map +1 -0
  26. package/dist/{RequestCache.d.mts → RequestCache.d.ts} +3 -3
  27. package/dist/RequestCache.d.ts.map +1 -0
  28. package/dist/{RequestCache.mjs → RequestCache.js} +1 -1
  29. package/dist/RequestCache.js.map +1 -0
  30. package/dist/{TransakService-method-action-types.d.cts → TransakService-method-action-types.d.ts} +2 -2
  31. package/dist/TransakService-method-action-types.d.ts.map +1 -0
  32. package/dist/{RampsController-method-action-types.mjs → TransakService-method-action-types.js} +1 -1
  33. package/dist/TransakService-method-action-types.js.map +1 -0
  34. package/dist/{TransakService.d.cts → TransakService.d.ts} +6 -6
  35. package/dist/TransakService.d.ts.map +1 -0
  36. package/dist/TransakService.js +746 -0
  37. package/dist/TransakService.js.map +1 -0
  38. package/dist/{autoramp-types.d.cts → autoramp-types.d.ts} +1 -1
  39. package/dist/autoramp-types.d.ts.map +1 -0
  40. package/dist/autoramp-types.js +2 -0
  41. package/dist/autoramp-types.js.map +1 -0
  42. package/dist/{autorampAccount.d.mts → autorampAccount.d.ts} +3 -3
  43. package/dist/autorampAccount.d.ts.map +1 -0
  44. package/dist/{autorampAccount.mjs → autorampAccount.js} +1 -1
  45. package/dist/autorampAccount.js.map +1 -0
  46. package/dist/{client-identity.d.mts → client-identity.d.ts} +1 -1
  47. package/dist/client-identity.d.ts.map +1 -0
  48. package/dist/{client-identity.mjs → client-identity.js} +1 -1
  49. package/dist/client-identity.js.map +1 -0
  50. package/dist/{errorNormalization.d.mts → errorNormalization.d.ts} +1 -1
  51. package/dist/errorNormalization.d.ts.map +1 -0
  52. package/dist/{errorNormalization.mjs → errorNormalization.js} +1 -1
  53. package/dist/errorNormalization.js.map +1 -0
  54. package/dist/{featureFlags.d.mts → featureFlags.d.ts} +2 -2
  55. package/dist/featureFlags.d.ts.map +1 -0
  56. package/dist/{featureFlags.mjs → featureFlags.js} +1 -1
  57. package/dist/featureFlags.js.map +1 -0
  58. package/dist/{index.d.mts → index.d.ts} +37 -35
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +19 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/order-syncing/constants.d.ts +23 -0
  63. package/dist/order-syncing/constants.d.ts.map +1 -0
  64. package/dist/order-syncing/constants.js +23 -0
  65. package/dist/order-syncing/constants.js.map +1 -0
  66. package/dist/order-syncing/controller-integration.d.ts +91 -0
  67. package/dist/order-syncing/controller-integration.d.ts.map +1 -0
  68. package/dist/order-syncing/controller-integration.js +364 -0
  69. package/dist/order-syncing/controller-integration.js.map +1 -0
  70. package/dist/order-syncing/index.d.ts +7 -0
  71. package/dist/order-syncing/index.d.ts.map +1 -0
  72. package/dist/order-syncing/index.js +5 -0
  73. package/dist/order-syncing/index.js.map +1 -0
  74. package/dist/order-syncing/sync-utils.d.ts +9 -0
  75. package/dist/order-syncing/sync-utils.d.ts.map +1 -0
  76. package/dist/order-syncing/sync-utils.js +27 -0
  77. package/dist/order-syncing/sync-utils.js.map +1 -0
  78. package/dist/order-syncing/types.d.ts +66 -0
  79. package/dist/order-syncing/types.d.ts.map +1 -0
  80. package/dist/order-syncing/types.js +2 -0
  81. package/dist/order-syncing/types.js.map +1 -0
  82. package/dist/order-syncing/utils.d.ts +83 -0
  83. package/dist/order-syncing/utils.d.ts.map +1 -0
  84. package/dist/order-syncing/utils.js +144 -0
  85. package/dist/order-syncing/utils.js.map +1 -0
  86. package/dist/{orderStatus.d.mts → orderStatus.d.ts} +2 -2
  87. package/dist/orderStatus.d.ts.map +1 -0
  88. package/dist/{orderStatus.mjs → orderStatus.js} +2 -2
  89. package/dist/orderStatus.js.map +1 -0
  90. package/dist/{ownership-message.d.cts → ownership-message.d.ts} +1 -1
  91. package/dist/ownership-message.d.ts.map +1 -0
  92. package/dist/{ownership-message.mjs → ownership-message.js} +1 -1
  93. package/dist/ownership-message.js.map +1 -0
  94. package/dist/{paymentMethodMerge.d.cts → paymentMethodMerge.d.ts} +2 -2
  95. package/dist/paymentMethodMerge.d.ts.map +1 -0
  96. package/dist/{paymentMethodMerge.mjs → paymentMethodMerge.js} +1 -1
  97. package/dist/paymentMethodMerge.js.map +1 -0
  98. package/dist/{providerAvailability.d.cts → providerAvailability.d.ts} +2 -2
  99. package/dist/providerAvailability.d.ts.map +1 -0
  100. package/dist/{providerAvailability.mjs → providerAvailability.js} +1 -1
  101. package/dist/providerAvailability.js.map +1 -0
  102. package/dist/{quoteClassification.d.cts → quoteClassification.d.ts} +2 -2
  103. package/dist/quoteClassification.d.ts.map +1 -0
  104. package/dist/{quoteClassification.mjs → quoteClassification.js} +1 -1
  105. package/dist/quoteClassification.js.map +1 -0
  106. package/dist/{rampsErrorCodes.d.cts → rampsErrorCodes.d.ts} +2 -2
  107. package/dist/rampsErrorCodes.d.ts.map +1 -0
  108. package/dist/{rampsErrorCodes.mjs → rampsErrorCodes.js} +1 -1
  109. package/dist/rampsErrorCodes.js.map +1 -0
  110. package/dist/{selectors.d.mts → selectors.d.ts} +3 -3
  111. package/dist/selectors.d.ts.map +1 -0
  112. package/dist/{selectors.mjs → selectors.js} +2 -2
  113. package/dist/selectors.js.map +1 -0
  114. package/dist/{transakApiErrorUtils.d.cts → transakApiErrorUtils.d.ts} +1 -1
  115. package/dist/transakApiErrorUtils.d.ts.map +1 -0
  116. package/dist/{transakApiErrorUtils.mjs → transakApiErrorUtils.js} +3 -3
  117. package/dist/transakApiErrorUtils.js.map +1 -0
  118. package/dist/{transakErrorCodes.d.cts → transakErrorCodes.d.ts} +3 -3
  119. package/dist/transakErrorCodes.d.ts.map +1 -0
  120. package/dist/{transakErrorCodes.mjs → transakErrorCodes.js} +1 -1
  121. package/dist/transakErrorCodes.js.map +1 -0
  122. package/dist/{wallet-registration-machine.d.cts → wallet-registration-machine.d.ts} +1 -1
  123. package/dist/wallet-registration-machine.d.ts.map +1 -0
  124. package/dist/{wallet-registration-machine.mjs → wallet-registration-machine.js} +1 -1
  125. package/dist/wallet-registration-machine.js.map +1 -0
  126. package/dist/{wallet-registration-service.d.cts → wallet-registration-service.d.ts} +1 -1
  127. package/dist/wallet-registration-service.d.ts.map +1 -0
  128. package/dist/{wallet-registration-service.mjs → wallet-registration-service.js} +60 -69
  129. package/dist/wallet-registration-service.js.map +1 -0
  130. package/package.json +18 -21
  131. package/dist/NeoBankService-method-action-types.cjs +0 -7
  132. package/dist/NeoBankService-method-action-types.cjs.map +0 -1
  133. package/dist/NeoBankService-method-action-types.d.cts +0 -126
  134. package/dist/NeoBankService-method-action-types.d.cts.map +0 -1
  135. package/dist/NeoBankService-method-action-types.d.mts.map +0 -1
  136. package/dist/NeoBankService-method-action-types.mjs.map +0 -1
  137. package/dist/NeoBankService.cjs +0 -387
  138. package/dist/NeoBankService.cjs.map +0 -1
  139. package/dist/NeoBankService.d.cts.map +0 -1
  140. package/dist/NeoBankService.d.mts +0 -191
  141. package/dist/NeoBankService.d.mts.map +0 -1
  142. package/dist/NeoBankService.mjs +0 -379
  143. package/dist/NeoBankService.mjs.map +0 -1
  144. package/dist/RampsController-method-action-types.cjs +0 -7
  145. package/dist/RampsController-method-action-types.cjs.map +0 -1
  146. package/dist/RampsController-method-action-types.d.cts +0 -758
  147. package/dist/RampsController-method-action-types.d.cts.map +0 -1
  148. package/dist/RampsController-method-action-types.d.mts.map +0 -1
  149. package/dist/RampsController-method-action-types.mjs.map +0 -1
  150. package/dist/RampsController.cjs +0 -2799
  151. package/dist/RampsController.cjs.map +0 -1
  152. package/dist/RampsController.d.cts +0 -968
  153. package/dist/RampsController.d.cts.map +0 -1
  154. package/dist/RampsController.d.mts.map +0 -1
  155. package/dist/RampsController.mjs.map +0 -1
  156. package/dist/RampsService-method-action-types.cjs +0 -7
  157. package/dist/RampsService-method-action-types.cjs.map +0 -1
  158. package/dist/RampsService-method-action-types.d.cts.map +0 -1
  159. package/dist/RampsService-method-action-types.d.mts +0 -171
  160. package/dist/RampsService-method-action-types.d.mts.map +0 -1
  161. package/dist/RampsService-method-action-types.mjs.map +0 -1
  162. package/dist/RampsService.cjs +0 -708
  163. package/dist/RampsService.cjs.map +0 -1
  164. package/dist/RampsService.d.cts +0 -944
  165. package/dist/RampsService.d.cts.map +0 -1
  166. package/dist/RampsService.d.mts.map +0 -1
  167. package/dist/RampsService.mjs.map +0 -1
  168. package/dist/RequestCache.cjs +0 -103
  169. package/dist/RequestCache.cjs.map +0 -1
  170. package/dist/RequestCache.d.cts +0 -110
  171. package/dist/RequestCache.d.cts.map +0 -1
  172. package/dist/RequestCache.d.mts.map +0 -1
  173. package/dist/RequestCache.mjs.map +0 -1
  174. package/dist/TransakService-method-action-types.cjs +0 -7
  175. package/dist/TransakService-method-action-types.cjs.map +0 -1
  176. package/dist/TransakService-method-action-types.d.cts.map +0 -1
  177. package/dist/TransakService-method-action-types.d.mts +0 -140
  178. package/dist/TransakService-method-action-types.d.mts.map +0 -1
  179. package/dist/TransakService-method-action-types.mjs.map +0 -1
  180. package/dist/TransakService.cjs +0 -743
  181. package/dist/TransakService.cjs.map +0 -1
  182. package/dist/TransakService.d.cts.map +0 -1
  183. package/dist/TransakService.d.mts +0 -370
  184. package/dist/TransakService.d.mts.map +0 -1
  185. package/dist/TransakService.mjs +0 -734
  186. package/dist/TransakService.mjs.map +0 -1
  187. package/dist/autoramp-types.cjs +0 -3
  188. package/dist/autoramp-types.cjs.map +0 -1
  189. package/dist/autoramp-types.d.cts.map +0 -1
  190. package/dist/autoramp-types.d.mts +0 -22
  191. package/dist/autoramp-types.d.mts.map +0 -1
  192. package/dist/autoramp-types.mjs +0 -2
  193. package/dist/autoramp-types.mjs.map +0 -1
  194. package/dist/autorampAccount.cjs +0 -155
  195. package/dist/autorampAccount.cjs.map +0 -1
  196. package/dist/autorampAccount.d.cts +0 -126
  197. package/dist/autorampAccount.d.cts.map +0 -1
  198. package/dist/autorampAccount.d.mts.map +0 -1
  199. package/dist/autorampAccount.mjs.map +0 -1
  200. package/dist/client-identity.cjs +0 -28
  201. package/dist/client-identity.cjs.map +0 -1
  202. package/dist/client-identity.d.cts +0 -24
  203. package/dist/client-identity.d.cts.map +0 -1
  204. package/dist/client-identity.d.mts.map +0 -1
  205. package/dist/client-identity.mjs.map +0 -1
  206. package/dist/errorNormalization.cjs +0 -84
  207. package/dist/errorNormalization.cjs.map +0 -1
  208. package/dist/errorNormalization.d.cts +0 -56
  209. package/dist/errorNormalization.d.cts.map +0 -1
  210. package/dist/errorNormalization.d.mts.map +0 -1
  211. package/dist/errorNormalization.mjs.map +0 -1
  212. package/dist/featureFlags.cjs +0 -144
  213. package/dist/featureFlags.cjs.map +0 -1
  214. package/dist/featureFlags.d.cts +0 -82
  215. package/dist/featureFlags.d.cts.map +0 -1
  216. package/dist/featureFlags.d.mts.map +0 -1
  217. package/dist/featureFlags.mjs.map +0 -1
  218. package/dist/index.cjs +0 -82
  219. package/dist/index.cjs.map +0 -1
  220. package/dist/index.d.cts +0 -35
  221. package/dist/index.d.cts.map +0 -1
  222. package/dist/index.d.mts.map +0 -1
  223. package/dist/index.mjs +0 -18
  224. package/dist/index.mjs.map +0 -1
  225. package/dist/orderStatus.cjs +0 -34
  226. package/dist/orderStatus.cjs.map +0 -1
  227. package/dist/orderStatus.d.cts +0 -18
  228. package/dist/orderStatus.d.cts.map +0 -1
  229. package/dist/orderStatus.d.mts.map +0 -1
  230. package/dist/orderStatus.mjs.map +0 -1
  231. package/dist/ownership-message.cjs +0 -26
  232. package/dist/ownership-message.cjs.map +0 -1
  233. package/dist/ownership-message.d.cts.map +0 -1
  234. package/dist/ownership-message.d.mts +0 -22
  235. package/dist/ownership-message.d.mts.map +0 -1
  236. package/dist/ownership-message.mjs.map +0 -1
  237. package/dist/paymentMethodMerge.cjs +0 -51
  238. package/dist/paymentMethodMerge.cjs.map +0 -1
  239. package/dist/paymentMethodMerge.d.cts.map +0 -1
  240. package/dist/paymentMethodMerge.d.mts +0 -26
  241. package/dist/paymentMethodMerge.d.mts.map +0 -1
  242. package/dist/paymentMethodMerge.mjs.map +0 -1
  243. package/dist/providerAvailability.cjs +0 -134
  244. package/dist/providerAvailability.cjs.map +0 -1
  245. package/dist/providerAvailability.d.cts.map +0 -1
  246. package/dist/providerAvailability.d.mts +0 -101
  247. package/dist/providerAvailability.d.mts.map +0 -1
  248. package/dist/providerAvailability.mjs.map +0 -1
  249. package/dist/quoteClassification.cjs +0 -44
  250. package/dist/quoteClassification.cjs.map +0 -1
  251. package/dist/quoteClassification.d.cts.map +0 -1
  252. package/dist/quoteClassification.d.mts +0 -33
  253. package/dist/quoteClassification.d.mts.map +0 -1
  254. package/dist/quoteClassification.mjs.map +0 -1
  255. package/dist/rampsErrorCodes.cjs +0 -11
  256. package/dist/rampsErrorCodes.cjs.map +0 -1
  257. package/dist/rampsErrorCodes.d.cts.map +0 -1
  258. package/dist/rampsErrorCodes.d.mts +0 -9
  259. package/dist/rampsErrorCodes.d.mts.map +0 -1
  260. package/dist/rampsErrorCodes.mjs.map +0 -1
  261. package/dist/selectors.cjs +0 -85
  262. package/dist/selectors.cjs.map +0 -1
  263. package/dist/selectors.d.cts +0 -78
  264. package/dist/selectors.d.cts.map +0 -1
  265. package/dist/selectors.d.mts.map +0 -1
  266. package/dist/selectors.mjs.map +0 -1
  267. package/dist/transakApiErrorUtils.cjs +0 -15
  268. package/dist/transakApiErrorUtils.cjs.map +0 -1
  269. package/dist/transakApiErrorUtils.d.cts.map +0 -1
  270. package/dist/transakApiErrorUtils.d.mts +0 -3
  271. package/dist/transakApiErrorUtils.d.mts.map +0 -1
  272. package/dist/transakApiErrorUtils.mjs.map +0 -1
  273. package/dist/transakErrorCodes.cjs +0 -14
  274. package/dist/transakErrorCodes.cjs.map +0 -1
  275. package/dist/transakErrorCodes.d.cts.map +0 -1
  276. package/dist/transakErrorCodes.d.mts +0 -12
  277. package/dist/transakErrorCodes.d.mts.map +0 -1
  278. package/dist/transakErrorCodes.mjs.map +0 -1
  279. package/dist/wallet-registration-machine.cjs +0 -144
  280. package/dist/wallet-registration-machine.cjs.map +0 -1
  281. package/dist/wallet-registration-machine.d.cts.map +0 -1
  282. package/dist/wallet-registration-machine.d.mts +0 -81
  283. package/dist/wallet-registration-machine.d.mts.map +0 -1
  284. package/dist/wallet-registration-machine.mjs.map +0 -1
  285. package/dist/wallet-registration-service.cjs +0 -351
  286. package/dist/wallet-registration-service.cjs.map +0 -1
  287. package/dist/wallet-registration-service.d.cts.map +0 -1
  288. package/dist/wallet-registration-service.d.mts +0 -144
  289. package/dist/wallet-registration-service.d.mts.map +0 -1
  290. package/dist/wallet-registration-service.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet-registration-service.cjs","sourceRoot":"","sources":["../src/wallet-registration-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmDA,iEAAiE;AACjE,MAAa,uBAAwB,SAAQ,KAAK;IAOhD,YACE,IAAiC,EACjC,OAIC;QAED,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,+BAA+B,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AArBD,0DAqBC;AA0CD;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,MAAc;IACrC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,YAAY,CAAC;QACtB,KAAK,GAAG;YACN,OAAO,cAAc,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,aAAa,CAAC;QACvB;YACE,OAAO,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;IACtD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB;IAClC,MAAM,SAAS,GAAG,UAAU,CAAC,MA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AAO,EAAE,8BAA8B;SACxC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE;QACvC,UAAU,EAAE,MAAM;QAClB,IAAI;QACJ,OAAO,EAAE,IAAI,IAAI,SAAS;KAC3B,CAAC,CAAC;AACL,CAAC,iGAEe,MAA+B;IAC7C,IAAI,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,uBAAuB,CAAC,mBAAmB,EAAE;YACrD,OAAO,EAAE,+BAA+B;SACzC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,uBAAuB,CAAC,mBAAmB,EAAE;YACrD,OAAO,EAAE,2CAA2C;SACrD,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,cAAc;QAC9B,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;KAChC,CAAC;AACJ,CAAC","sourcesContent":["/** The only blockchain supported by the Money Account POC. */\nexport type Blockchain = 'Monad';\n\n/** Normalized view of a single registered self-hosted address. */\nexport type SelfHostedRegistration = {\n id: string;\n address: string;\n blockchain: Blockchain;\n disabled: boolean;\n isSelf: boolean;\n};\n\n/** Result of reconciling a wallet against the customer's registered addresses. */\nexport type RegistrationStatus =\n | { type: 'active'; registration: SelfHostedRegistration }\n | { type: 'disabled'; registration: SelfHostedRegistration }\n | { type: 'absent' };\n\n/**\n * Discriminated error kinds surfaced to the state machine. Every non-success\n * path maps to exactly one of these so the machine can decide deterministically.\n */\nexport type WalletRegistrationErrorKind =\n | 'validation'\n | 'unauthorized'\n | 'forbidden'\n | 'notFound'\n | 'conflict'\n | 'rateLimited'\n | 'transient'\n | 'lookupUnavailable'\n | 'malformedResponse';\n\n/** Minimal HTTP response shape, so the service is environment-agnostic. */\ntype HttpResponse = {\n ok: boolean;\n status: number;\n json: () => Promise<unknown>;\n text: () => Promise<string>;\n};\n\n/** Minimal `fetch`-like function the service depends on. */\ntype FetchLike = (\n url: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n },\n) => Promise<HttpResponse>;\n\n/** Typed error carrying enough context for state transitions. */\nexport class WalletRegistrationError extends Error {\n readonly kind: WalletRegistrationErrorKind;\n\n readonly httpStatus?: number;\n\n readonly body?: string;\n\n constructor(\n kind: WalletRegistrationErrorKind,\n options: {\n message?: string;\n httpStatus?: number;\n body?: string;\n },\n ) {\n super(options.message ?? `wallet registration failed: ${kind}`);\n this.name = 'WalletRegistrationError';\n this.kind = kind;\n this.httpStatus = options.httpStatus;\n this.body = options.body;\n }\n}\n\nexport type WalletRegistrationServiceOptions = {\n fetch: FetchLike;\n /**\n * Base URL of the Money Movement neobank-proxy host\n * (e.g. `https://on-ramp.dev-api.cx.metamask.io`). Paths are under `/neobank`.\n */\n baseUrl: string;\n getAuthToken: () => Promise<string>;\n /**\n * MetaMask profile / partner external id used as MoonPay `external_id`\n * (typically `AuthenticationController:getSessionProfile().canonicalProfileId`).\n */\n getExternalId: () => Promise<string>;\n};\n\nexport type GetRegistrationStatusRequest = {\n customerId: string;\n address: string;\n blockchain: Blockchain;\n};\n\nexport type RegisterSelfHostedWalletRequest = {\n customerId: string;\n address: string;\n blockchain: Blockchain;\n message: string;\n signature: string;\n /**\n * Stable key reused across retries of the same ownership proof. Generated\n * when omitted.\n */\n idempotencyKey?: string;\n};\n\n/** Successful registration outcome. */\nexport type RegistrationOutcome = {\n type: 'registered';\n registration: SelfHostedRegistration;\n};\n\n/**\n * Normalizes a Monad EVM address for case-insensitive comparison.\n *\n * @param address - Raw address string.\n * @returns The comparison key for the address.\n */\nfunction normalizeAddress(address: string): string {\n return address.toLowerCase();\n}\n\n/**\n * Maps an HTTP status to the typed error kind the state machine reacts to.\n *\n * @param status - HTTP status code from the proxy/Iron response.\n * @returns The corresponding error kind.\n */\nfunction mapStatusToKind(status: number): WalletRegistrationErrorKind {\n switch (status) {\n case 400:\n return 'validation';\n case 401:\n return 'unauthorized';\n case 403:\n return 'forbidden';\n case 404:\n return 'notFound';\n case 409:\n return 'conflict';\n case 429:\n return 'rateLimited';\n default:\n return status >= 500 ? 'transient' : 'validation';\n }\n}\n\n/**\n * Builds a client-side Idempotency-Key for MoonPay POSTs. Prefer a stable\n * caller-supplied key across retries of the same proof.\n *\n * @returns A random UUID when available, otherwise a timestamped fallback.\n */\nexport function createIdempotencyKey(): string {\n const cryptoObj = globalThis.crypto as\n | { randomUUID?: () => string }\n | undefined;\n if (typeof cryptoObj?.randomUUID === 'function') {\n return cryptoObj.randomUUID();\n }\n return `wallet-reg-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n}\n\n/**\n * Extracts a human-readable error body from a transparent neobank-proxy\n * response. Upstream may return a plain string or a JSON value; both are\n * mirrored 1:1 (no `{ code: 'iron_error' }` envelope).\n *\n * @param raw - Raw response text.\n * @returns Normalized body string for {@link WalletRegistrationError}.\n */\nexport function extractErrorBody(raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) {\n return raw;\n }\n try {\n const parsed: unknown = JSON.parse(trimmed);\n if (typeof parsed === 'string') {\n return parsed;\n }\n if (parsed && typeof parsed === 'object') {\n const { message } = parsed as { message?: unknown };\n if (typeof message === 'string') {\n return message;\n }\n }\n return trimmed;\n } catch {\n return trimmed;\n }\n}\n\n/**\n * Data service that talks to the Money Movement neobank-proxy for MoonPay Iron\n * self-hosted wallet registration. It never calls Iron directly, so the Iron\n * API key never ships in the client.\n */\nexport class WalletRegistrationService {\n readonly #fetch: FetchLike;\n\n readonly #baseUrl: string;\n\n readonly #getAuthToken: () => Promise<string>;\n\n readonly #getExternalId: () => Promise<string>;\n\n constructor(options: WalletRegistrationServiceOptions) {\n this.#fetch = options.fetch;\n this.#baseUrl = options.baseUrl.replace(/\\/$/u, '');\n this.#getAuthToken = options.getAuthToken;\n this.#getExternalId = options.getExternalId;\n }\n\n /**\n * Resolves Iron's internal customer id via\n * `GET /neobank/customers/{external_id}/external`, using the MetaMask\n * profile/canonical id as `external_id`.\n *\n * @returns Iron's internal customer id.\n */\n async getMoonpayCustomerId(): Promise<string> {\n const [token, externalId] = await Promise.all([\n this.#getAuthToken(),\n this.#getExternalId(),\n ]);\n if (!externalId) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MetaMask external id (canonical profile id) is empty',\n });\n }\n\n const response = await this.#fetch(\n `${this.#baseUrl}/neobank/customers/${encodeURIComponent(externalId)}/external`,\n {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n },\n },\n );\n\n if (!response.ok) {\n throw await this.#toHttpError(response);\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MoonPay customer body was not valid JSON',\n });\n }\n\n const { id } = payload as { id?: unknown };\n if (typeof id !== 'string' || id.length === 0) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MoonPay customer body missing id',\n });\n }\n return id;\n }\n\n /**\n * Reconciles a wallet against the customer's registered self-hosted addresses\n * via `GET /neobank/addresses/crypto/{customer_id}?filter=SelfHosted`.\n * Upstream returns all self-hosted chains; Monad filtering stays client-side\n * for the POC. Transport failures are reported as `lookupUnavailable`;\n * malformed successful responses are reported as `malformedResponse`.\n * Neither is downgraded to `absent`.\n *\n * @param request - Customer id and Monad address to reconcile.\n * @returns The active / disabled / absent status for the address.\n */\n async getRegistrationStatus(\n request: GetRegistrationStatusRequest,\n ): Promise<RegistrationStatus> {\n const { customerId, address, blockchain } = request;\n\n let response: HttpResponse;\n try {\n const token = await this.#getAuthToken();\n const url = new URL(\n `${this.#baseUrl}/neobank/addresses/crypto/${encodeURIComponent(customerId)}`,\n );\n url.searchParams.set('filter', 'SelfHosted');\n response = await this.#fetch(url.toString(), {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n },\n });\n } catch (error) {\n throw new WalletRegistrationError('lookupUnavailable', {\n message: 'self-hosted address lookup failed',\n body: error instanceof Error ? error.message : undefined,\n });\n }\n\n if (!response.ok) {\n let body: string;\n try {\n body = extractErrorBody(await response.text());\n } catch (error) {\n body = error instanceof Error ? error.message : '';\n }\n throw new WalletRegistrationError('lookupUnavailable', {\n httpStatus: response.status,\n body,\n });\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'self-hosted address list body was not valid JSON',\n });\n }\n if (!Array.isArray(payload)) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'expected an array of registered addresses',\n });\n }\n\n const target = normalizeAddress(address);\n const match = payload.find((entry) => {\n const record = entry as Record<string, unknown>;\n const walletAddress = record.wallet_address;\n if (typeof walletAddress !== 'string') {\n return false;\n }\n return (\n normalizeAddress(walletAddress) === target &&\n record.blockchain === blockchain\n );\n }) as Record<string, unknown> | undefined;\n\n if (!match) {\n return { type: 'absent' };\n }\n\n const registration = this.#toRegistration(match);\n return registration.disabled\n ? { type: 'disabled', registration }\n : { type: 'active', registration };\n }\n\n /**\n * Registers a self-hosted wallet through neobank-proxy\n * `POST /neobank/addresses/crypto/selfhosted`. The client supplies\n * `customer_id` and an `Idempotency-Key` (generated when omitted). Every\n * non-2xx response is mapped to a typed error; `409` is deliberately\n * surfaced as an ambiguous `conflict` that the caller must reconcile with a\n * follow-up status lookup.\n *\n * @param request - Customer id, address, blockchain, message, and signature.\n * @returns The registered outcome on success.\n */\n async registerSelfHostedWallet(\n request: RegisterSelfHostedWalletRequest,\n ): Promise<RegistrationOutcome> {\n const idempotencyKey = request.idempotencyKey ?? createIdempotencyKey();\n let response: HttpResponse;\n try {\n const token = await this.#getAuthToken();\n response = await this.#fetch(\n `${this.#baseUrl}/neobank/addresses/crypto/selfhosted`,\n {\n method: 'POST',\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n authorization: `Bearer ${token}`,\n 'Idempotency-Key': idempotencyKey,\n },\n body: JSON.stringify({\n customer_id: request.customerId,\n address: request.address,\n blockchain: request.blockchain,\n message: request.message,\n signature: request.signature,\n }),\n },\n );\n } catch (error) {\n throw new WalletRegistrationError('transient', {\n message: 'self-hosted registration request failed',\n body: error instanceof Error ? error.message : undefined,\n });\n }\n\n if (!response.ok) {\n throw await this.#toHttpError(response);\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registration success body was not valid JSON',\n });\n }\n\n const record = payload as Record<string, unknown>;\n if (typeof record.id !== 'string' || typeof record.address !== 'string') {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registration success body missing id/address',\n });\n }\n\n return {\n type: 'registered',\n registration: {\n id: record.id,\n address: record.address,\n blockchain: request.blockchain,\n disabled: Boolean(record.disabled),\n isSelf: true,\n },\n };\n }\n\n async #toHttpError(response: HttpResponse): Promise<WalletRegistrationError> {\n let raw = '';\n try {\n raw = await response.text();\n } catch {\n return new WalletRegistrationError('malformedResponse', {\n httpStatus: response.status,\n message: 'error body could not be read',\n });\n }\n\n const { status } = response;\n const kind = mapStatusToKind(status);\n const body = extractErrorBody(raw);\n return new WalletRegistrationError(kind, {\n httpStatus: status,\n body,\n message: body || undefined,\n });\n }\n\n #toRegistration(record: Record<string, unknown>): SelfHostedRegistration {\n if (typeof record.id !== 'string' || record.id.length === 0) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registered address missing id',\n });\n }\n if (typeof record.wallet_address !== 'string') {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registered address missing wallet_address',\n });\n }\n return {\n id: record.id,\n address: record.wallet_address,\n blockchain: 'Monad',\n disabled: Boolean(record.disabled),\n isSelf: Boolean(record.is_self),\n };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet-registration-service.d.cts","sourceRoot":"","sources":["../src/wallet-registration-service.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEjC,kEAAkE;AAClE,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,YAAY,EAAE,sBAAsB,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,sBAAsB,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GACnC,YAAY,GACZ,cAAc,GACd,WAAW,GACX,UAAU,GACV,UAAU,GACV,aAAa,GACb,WAAW,GACX,mBAAmB,GACnB,mBAAmB,CAAC;AAExB,2EAA2E;AAC3E,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,4DAA4D;AAC5D,KAAK,SAAS,GAAG,CACf,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,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AAY,CAAC;IACnB,YAAY,EAAE,sBAAsB,CAAC;CACtC,CAAC;AAqCF;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoBpD;AAED;;;;GAIG;AACH,qBAAa,yBAAyB;;gBASxB,OAAO,EAAE,gCAAgC;IAOrD;;;;;;OAMG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IA4C7C;;;;;;;;;;OAUG;IACG,qBAAqB,CACzB,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,kBAAkB,CAAC;IA0E9B;;;;;;;;;;OAUG;IACG,wBAAwB,CAC5B,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,mBAAmB,CAAC;CAuGhC"}
@@ -1,144 +0,0 @@
1
- /** The only blockchain supported by the Money Account POC. */
2
- export type Blockchain = 'Monad';
3
- /** Normalized view of a single registered self-hosted address. */
4
- export type SelfHostedRegistration = {
5
- id: string;
6
- address: string;
7
- blockchain: Blockchain;
8
- disabled: boolean;
9
- isSelf: boolean;
10
- };
11
- /** Result of reconciling a wallet against the customer's registered addresses. */
12
- export type RegistrationStatus = {
13
- type: 'active';
14
- registration: SelfHostedRegistration;
15
- } | {
16
- type: 'disabled';
17
- registration: SelfHostedRegistration;
18
- } | {
19
- type: 'absent';
20
- };
21
- /**
22
- * Discriminated error kinds surfaced to the state machine. Every non-success
23
- * path maps to exactly one of these so the machine can decide deterministically.
24
- */
25
- export type WalletRegistrationErrorKind = 'validation' | 'unauthorized' | 'forbidden' | 'notFound' | 'conflict' | 'rateLimited' | 'transient' | 'lookupUnavailable' | 'malformedResponse';
26
- /** Minimal HTTP response shape, so the service is environment-agnostic. */
27
- type HttpResponse = {
28
- ok: boolean;
29
- status: number;
30
- json: () => Promise<unknown>;
31
- text: () => Promise<string>;
32
- };
33
- /** Minimal `fetch`-like function the service depends on. */
34
- type FetchLike = (url: string, init?: {
35
- method?: string;
36
- headers?: Record<string, string>;
37
- body?: string;
38
- }) => Promise<HttpResponse>;
39
- /** Typed error carrying enough context for state transitions. */
40
- export declare class WalletRegistrationError extends Error {
41
- readonly kind: WalletRegistrationErrorKind;
42
- readonly httpStatus?: number;
43
- readonly body?: string;
44
- constructor(kind: WalletRegistrationErrorKind, options: {
45
- message?: string;
46
- httpStatus?: number;
47
- body?: string;
48
- });
49
- }
50
- export type WalletRegistrationServiceOptions = {
51
- fetch: FetchLike;
52
- /**
53
- * Base URL of the Money Movement neobank-proxy host
54
- * (e.g. `https://on-ramp.dev-api.cx.metamask.io`). Paths are under `/neobank`.
55
- */
56
- baseUrl: string;
57
- getAuthToken: () => Promise<string>;
58
- /**
59
- * MetaMask profile / partner external id used as MoonPay `external_id`
60
- * (typically `AuthenticationController:getSessionProfile().canonicalProfileId`).
61
- */
62
- getExternalId: () => Promise<string>;
63
- };
64
- export type GetRegistrationStatusRequest = {
65
- customerId: string;
66
- address: string;
67
- blockchain: Blockchain;
68
- };
69
- export type RegisterSelfHostedWalletRequest = {
70
- customerId: string;
71
- address: string;
72
- blockchain: Blockchain;
73
- message: string;
74
- signature: string;
75
- /**
76
- * Stable key reused across retries of the same ownership proof. Generated
77
- * when omitted.
78
- */
79
- idempotencyKey?: string;
80
- };
81
- /** Successful registration outcome. */
82
- export type RegistrationOutcome = {
83
- type: 'registered';
84
- registration: SelfHostedRegistration;
85
- };
86
- /**
87
- * Builds a client-side Idempotency-Key for MoonPay POSTs. Prefer a stable
88
- * caller-supplied key across retries of the same proof.
89
- *
90
- * @returns A random UUID when available, otherwise a timestamped fallback.
91
- */
92
- export declare function createIdempotencyKey(): string;
93
- /**
94
- * Extracts a human-readable error body from a transparent neobank-proxy
95
- * response. Upstream may return a plain string or a JSON value; both are
96
- * mirrored 1:1 (no `{ code: 'iron_error' }` envelope).
97
- *
98
- * @param raw - Raw response text.
99
- * @returns Normalized body string for {@link WalletRegistrationError}.
100
- */
101
- export declare function extractErrorBody(raw: string): string;
102
- /**
103
- * Data service that talks to the Money Movement neobank-proxy for MoonPay Iron
104
- * self-hosted wallet registration. It never calls Iron directly, so the Iron
105
- * API key never ships in the client.
106
- */
107
- export declare class WalletRegistrationService {
108
- #private;
109
- constructor(options: WalletRegistrationServiceOptions);
110
- /**
111
- * Resolves Iron's internal customer id via
112
- * `GET /neobank/customers/{external_id}/external`, using the MetaMask
113
- * profile/canonical id as `external_id`.
114
- *
115
- * @returns Iron's internal customer id.
116
- */
117
- getMoonpayCustomerId(): Promise<string>;
118
- /**
119
- * Reconciles a wallet against the customer's registered self-hosted addresses
120
- * via `GET /neobank/addresses/crypto/{customer_id}?filter=SelfHosted`.
121
- * Upstream returns all self-hosted chains; Monad filtering stays client-side
122
- * for the POC. Transport failures are reported as `lookupUnavailable`;
123
- * malformed successful responses are reported as `malformedResponse`.
124
- * Neither is downgraded to `absent`.
125
- *
126
- * @param request - Customer id and Monad address to reconcile.
127
- * @returns The active / disabled / absent status for the address.
128
- */
129
- getRegistrationStatus(request: GetRegistrationStatusRequest): Promise<RegistrationStatus>;
130
- /**
131
- * Registers a self-hosted wallet through neobank-proxy
132
- * `POST /neobank/addresses/crypto/selfhosted`. The client supplies
133
- * `customer_id` and an `Idempotency-Key` (generated when omitted). Every
134
- * non-2xx response is mapped to a typed error; `409` is deliberately
135
- * surfaced as an ambiguous `conflict` that the caller must reconcile with a
136
- * follow-up status lookup.
137
- *
138
- * @param request - Customer id, address, blockchain, message, and signature.
139
- * @returns The registered outcome on success.
140
- */
141
- registerSelfHostedWallet(request: RegisterSelfHostedWalletRequest): Promise<RegistrationOutcome>;
142
- }
143
- export {};
144
- //# sourceMappingURL=wallet-registration-service.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet-registration-service.d.mts","sourceRoot":"","sources":["../src/wallet-registration-service.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEj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C7C;;;;;;;;;;OAUG;IACG,qBAAqB,CACzB,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,kBAAkB,CAAC;IA0E9B;;;;;;;;;;OAUG;IACG,wBAAwB,CAC5B,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,mBAAmB,CAAC;CAuGhC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet-registration-service.mjs","sourceRoot":"","sources":["../src/wallet-registration-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAmDA,iEAAiE;AACjE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAOhD,YACE,IAAiC,EACjC,OAIC;QAED,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,+BAA+B,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AA0CD;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,MAAc;IACrC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,YAAY,CAAC;QACtB,KAAK,GAAG;YACN,OAAO,cAAc,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,aAAa,CAAC;QACvB;YACE,OAAO,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;IACtD,CAAC;AACH,CAAC;AAED;;;;;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AAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,OAAO,EAAE,8BAA8B;SACxC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE;QACvC,UAAU,EAAE,MAAM;QAClB,IAAI;QACJ,OAAO,EAAE,IAAI,IAAI,SAAS;KAC3B,CAAC,CAAC;AACL,CAAC,iGAEe,MAA+B;IAC7C,IAAI,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,uBAAuB,CAAC,mBAAmB,EAAE;YACrD,OAAO,EAAE,+BAA+B;SACzC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,uBAAuB,CAAC,mBAAmB,EAAE;YACrD,OAAO,EAAE,2CAA2C;SACrD,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,cAAc;QAC9B,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;KAChC,CAAC;AACJ,CAAC","sourcesContent":["/** The only blockchain supported by the Money Account POC. */\nexport type Blockchain = 'Monad';\n\n/** Normalized view of a single registered self-hosted address. */\nexport type SelfHostedRegistration = {\n id: string;\n address: string;\n blockchain: Blockchain;\n disabled: boolean;\n isSelf: boolean;\n};\n\n/** Result of reconciling a wallet against the customer's registered addresses. */\nexport type RegistrationStatus =\n | { type: 'active'; registration: SelfHostedRegistration }\n | { type: 'disabled'; registration: SelfHostedRegistration }\n | { type: 'absent' };\n\n/**\n * Discriminated error kinds surfaced to the state machine. Every non-success\n * path maps to exactly one of these so the machine can decide deterministically.\n */\nexport type WalletRegistrationErrorKind =\n | 'validation'\n | 'unauthorized'\n | 'forbidden'\n | 'notFound'\n | 'conflict'\n | 'rateLimited'\n | 'transient'\n | 'lookupUnavailable'\n | 'malformedResponse';\n\n/** Minimal HTTP response shape, so the service is environment-agnostic. */\ntype HttpResponse = {\n ok: boolean;\n status: number;\n json: () => Promise<unknown>;\n text: () => Promise<string>;\n};\n\n/** Minimal `fetch`-like function the service depends on. */\ntype FetchLike = (\n url: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n },\n) => Promise<HttpResponse>;\n\n/** Typed error carrying enough context for state transitions. */\nexport class WalletRegistrationError extends Error {\n readonly kind: WalletRegistrationErrorKind;\n\n readonly httpStatus?: number;\n\n readonly body?: string;\n\n constructor(\n kind: WalletRegistrationErrorKind,\n options: {\n message?: string;\n httpStatus?: number;\n body?: string;\n },\n ) {\n super(options.message ?? `wallet registration failed: ${kind}`);\n this.name = 'WalletRegistrationError';\n this.kind = kind;\n this.httpStatus = options.httpStatus;\n this.body = options.body;\n }\n}\n\nexport type WalletRegistrationServiceOptions = {\n fetch: FetchLike;\n /**\n * Base URL of the Money Movement neobank-proxy host\n * (e.g. `https://on-ramp.dev-api.cx.metamask.io`). Paths are under `/neobank`.\n */\n baseUrl: string;\n getAuthToken: () => Promise<string>;\n /**\n * MetaMask profile / partner external id used as MoonPay `external_id`\n * (typically `AuthenticationController:getSessionProfile().canonicalProfileId`).\n */\n getExternalId: () => Promise<string>;\n};\n\nexport type GetRegistrationStatusRequest = {\n customerId: string;\n address: string;\n blockchain: Blockchain;\n};\n\nexport type RegisterSelfHostedWalletRequest = {\n customerId: string;\n address: string;\n blockchain: Blockchain;\n message: string;\n signature: string;\n /**\n * Stable key reused across retries of the same ownership proof. Generated\n * when omitted.\n */\n idempotencyKey?: string;\n};\n\n/** Successful registration outcome. */\nexport type RegistrationOutcome = {\n type: 'registered';\n registration: SelfHostedRegistration;\n};\n\n/**\n * Normalizes a Monad EVM address for case-insensitive comparison.\n *\n * @param address - Raw address string.\n * @returns The comparison key for the address.\n */\nfunction normalizeAddress(address: string): string {\n return address.toLowerCase();\n}\n\n/**\n * Maps an HTTP status to the typed error kind the state machine reacts to.\n *\n * @param status - HTTP status code from the proxy/Iron response.\n * @returns The corresponding error kind.\n */\nfunction mapStatusToKind(status: number): WalletRegistrationErrorKind {\n switch (status) {\n case 400:\n return 'validation';\n case 401:\n return 'unauthorized';\n case 403:\n return 'forbidden';\n case 404:\n return 'notFound';\n case 409:\n return 'conflict';\n case 429:\n return 'rateLimited';\n default:\n return status >= 500 ? 'transient' : 'validation';\n }\n}\n\n/**\n * Builds a client-side Idempotency-Key for MoonPay POSTs. Prefer a stable\n * caller-supplied key across retries of the same proof.\n *\n * @returns A random UUID when available, otherwise a timestamped fallback.\n */\nexport function createIdempotencyKey(): string {\n const cryptoObj = globalThis.crypto as\n | { randomUUID?: () => string }\n | undefined;\n if (typeof cryptoObj?.randomUUID === 'function') {\n return cryptoObj.randomUUID();\n }\n return `wallet-reg-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n}\n\n/**\n * Extracts a human-readable error body from a transparent neobank-proxy\n * response. Upstream may return a plain string or a JSON value; both are\n * mirrored 1:1 (no `{ code: 'iron_error' }` envelope).\n *\n * @param raw - Raw response text.\n * @returns Normalized body string for {@link WalletRegistrationError}.\n */\nexport function extractErrorBody(raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) {\n return raw;\n }\n try {\n const parsed: unknown = JSON.parse(trimmed);\n if (typeof parsed === 'string') {\n return parsed;\n }\n if (parsed && typeof parsed === 'object') {\n const { message } = parsed as { message?: unknown };\n if (typeof message === 'string') {\n return message;\n }\n }\n return trimmed;\n } catch {\n return trimmed;\n }\n}\n\n/**\n * Data service that talks to the Money Movement neobank-proxy for MoonPay Iron\n * self-hosted wallet registration. It never calls Iron directly, so the Iron\n * API key never ships in the client.\n */\nexport class WalletRegistrationService {\n readonly #fetch: FetchLike;\n\n readonly #baseUrl: string;\n\n readonly #getAuthToken: () => Promise<string>;\n\n readonly #getExternalId: () => Promise<string>;\n\n constructor(options: WalletRegistrationServiceOptions) {\n this.#fetch = options.fetch;\n this.#baseUrl = options.baseUrl.replace(/\\/$/u, '');\n this.#getAuthToken = options.getAuthToken;\n this.#getExternalId = options.getExternalId;\n }\n\n /**\n * Resolves Iron's internal customer id via\n * `GET /neobank/customers/{external_id}/external`, using the MetaMask\n * profile/canonical id as `external_id`.\n *\n * @returns Iron's internal customer id.\n */\n async getMoonpayCustomerId(): Promise<string> {\n const [token, externalId] = await Promise.all([\n this.#getAuthToken(),\n this.#getExternalId(),\n ]);\n if (!externalId) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MetaMask external id (canonical profile id) is empty',\n });\n }\n\n const response = await this.#fetch(\n `${this.#baseUrl}/neobank/customers/${encodeURIComponent(externalId)}/external`,\n {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n },\n },\n );\n\n if (!response.ok) {\n throw await this.#toHttpError(response);\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MoonPay customer body was not valid JSON',\n });\n }\n\n const { id } = payload as { id?: unknown };\n if (typeof id !== 'string' || id.length === 0) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'MoonPay customer body missing id',\n });\n }\n return id;\n }\n\n /**\n * Reconciles a wallet against the customer's registered self-hosted addresses\n * via `GET /neobank/addresses/crypto/{customer_id}?filter=SelfHosted`.\n * Upstream returns all self-hosted chains; Monad filtering stays client-side\n * for the POC. Transport failures are reported as `lookupUnavailable`;\n * malformed successful responses are reported as `malformedResponse`.\n * Neither is downgraded to `absent`.\n *\n * @param request - Customer id and Monad address to reconcile.\n * @returns The active / disabled / absent status for the address.\n */\n async getRegistrationStatus(\n request: GetRegistrationStatusRequest,\n ): Promise<RegistrationStatus> {\n const { customerId, address, blockchain } = request;\n\n let response: HttpResponse;\n try {\n const token = await this.#getAuthToken();\n const url = new URL(\n `${this.#baseUrl}/neobank/addresses/crypto/${encodeURIComponent(customerId)}`,\n );\n url.searchParams.set('filter', 'SelfHosted');\n response = await this.#fetch(url.toString(), {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n },\n });\n } catch (error) {\n throw new WalletRegistrationError('lookupUnavailable', {\n message: 'self-hosted address lookup failed',\n body: error instanceof Error ? error.message : undefined,\n });\n }\n\n if (!response.ok) {\n let body: string;\n try {\n body = extractErrorBody(await response.text());\n } catch (error) {\n body = error instanceof Error ? error.message : '';\n }\n throw new WalletRegistrationError('lookupUnavailable', {\n httpStatus: response.status,\n body,\n });\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'self-hosted address list body was not valid JSON',\n });\n }\n if (!Array.isArray(payload)) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'expected an array of registered addresses',\n });\n }\n\n const target = normalizeAddress(address);\n const match = payload.find((entry) => {\n const record = entry as Record<string, unknown>;\n const walletAddress = record.wallet_address;\n if (typeof walletAddress !== 'string') {\n return false;\n }\n return (\n normalizeAddress(walletAddress) === target &&\n record.blockchain === blockchain\n );\n }) as Record<string, unknown> | undefined;\n\n if (!match) {\n return { type: 'absent' };\n }\n\n const registration = this.#toRegistration(match);\n return registration.disabled\n ? { type: 'disabled', registration }\n : { type: 'active', registration };\n }\n\n /**\n * Registers a self-hosted wallet through neobank-proxy\n * `POST /neobank/addresses/crypto/selfhosted`. The client supplies\n * `customer_id` and an `Idempotency-Key` (generated when omitted). Every\n * non-2xx response is mapped to a typed error; `409` is deliberately\n * surfaced as an ambiguous `conflict` that the caller must reconcile with a\n * follow-up status lookup.\n *\n * @param request - Customer id, address, blockchain, message, and signature.\n * @returns The registered outcome on success.\n */\n async registerSelfHostedWallet(\n request: RegisterSelfHostedWalletRequest,\n ): Promise<RegistrationOutcome> {\n const idempotencyKey = request.idempotencyKey ?? createIdempotencyKey();\n let response: HttpResponse;\n try {\n const token = await this.#getAuthToken();\n response = await this.#fetch(\n `${this.#baseUrl}/neobank/addresses/crypto/selfhosted`,\n {\n method: 'POST',\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n authorization: `Bearer ${token}`,\n 'Idempotency-Key': idempotencyKey,\n },\n body: JSON.stringify({\n customer_id: request.customerId,\n address: request.address,\n blockchain: request.blockchain,\n message: request.message,\n signature: request.signature,\n }),\n },\n );\n } catch (error) {\n throw new WalletRegistrationError('transient', {\n message: 'self-hosted registration request failed',\n body: error instanceof Error ? error.message : undefined,\n });\n }\n\n if (!response.ok) {\n throw await this.#toHttpError(response);\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registration success body was not valid JSON',\n });\n }\n\n const record = payload as Record<string, unknown>;\n if (typeof record.id !== 'string' || typeof record.address !== 'string') {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registration success body missing id/address',\n });\n }\n\n return {\n type: 'registered',\n registration: {\n id: record.id,\n address: record.address,\n blockchain: request.blockchain,\n disabled: Boolean(record.disabled),\n isSelf: true,\n },\n };\n }\n\n async #toHttpError(response: HttpResponse): Promise<WalletRegistrationError> {\n let raw = '';\n try {\n raw = await response.text();\n } catch {\n return new WalletRegistrationError('malformedResponse', {\n httpStatus: response.status,\n message: 'error body could not be read',\n });\n }\n\n const { status } = response;\n const kind = mapStatusToKind(status);\n const body = extractErrorBody(raw);\n return new WalletRegistrationError(kind, {\n httpStatus: status,\n body,\n message: body || undefined,\n });\n }\n\n #toRegistration(record: Record<string, unknown>): SelfHostedRegistration {\n if (typeof record.id !== 'string' || record.id.length === 0) {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registered address missing id',\n });\n }\n if (typeof record.wallet_address !== 'string') {\n throw new WalletRegistrationError('malformedResponse', {\n message: 'registered address missing wallet_address',\n });\n }\n return {\n id: record.id,\n address: record.wallet_address,\n blockchain: 'Monad',\n disabled: Boolean(record.disabled),\n isSelf: Boolean(record.is_self),\n };\n }\n}\n"]}