@metamask-previews/notification-services-controller 0.0.0-preview-b09c2ed

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 (391) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +20 -0
  3. package/README.md +15 -0
  4. package/dist/NotificationServicesController/NotificationServicesController.js +18 -0
  5. package/dist/NotificationServicesController/NotificationServicesController.js.map +1 -0
  6. package/dist/NotificationServicesController/NotificationServicesController.mjs +18 -0
  7. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -0
  8. package/dist/NotificationServicesController/constants/constants.js +10 -0
  9. package/dist/NotificationServicesController/constants/constants.js.map +1 -0
  10. package/dist/NotificationServicesController/constants/constants.mjs +10 -0
  11. package/dist/NotificationServicesController/constants/constants.mjs.map +1 -0
  12. package/dist/NotificationServicesController/constants/index.js +27 -0
  13. package/dist/NotificationServicesController/constants/index.js.map +1 -0
  14. package/dist/NotificationServicesController/constants/index.mjs +27 -0
  15. package/dist/NotificationServicesController/constants/index.mjs.map +1 -0
  16. package/dist/NotificationServicesController/constants/notification-schema.js +20 -0
  17. package/dist/NotificationServicesController/constants/notification-schema.js.map +1 -0
  18. package/dist/NotificationServicesController/constants/notification-schema.mjs +20 -0
  19. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -0
  20. package/dist/NotificationServicesController/index.js +44 -0
  21. package/dist/NotificationServicesController/index.js.map +1 -0
  22. package/dist/NotificationServicesController/index.mjs +44 -0
  23. package/dist/NotificationServicesController/index.mjs.map +1 -0
  24. package/dist/NotificationServicesController/processors/index.js +22 -0
  25. package/dist/NotificationServicesController/processors/index.js.map +1 -0
  26. package/dist/NotificationServicesController/processors/index.mjs +22 -0
  27. package/dist/NotificationServicesController/processors/index.mjs.map +1 -0
  28. package/dist/NotificationServicesController/processors/process-feature-announcement.js +10 -0
  29. package/dist/NotificationServicesController/processors/process-feature-announcement.js.map +1 -0
  30. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +10 -0
  31. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -0
  32. package/dist/NotificationServicesController/processors/process-notifications.js +13 -0
  33. package/dist/NotificationServicesController/processors/process-notifications.js.map +1 -0
  34. package/dist/NotificationServicesController/processors/process-notifications.mjs +13 -0
  35. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -0
  36. package/dist/NotificationServicesController/processors/process-onchain-notifications.js +8 -0
  37. package/dist/NotificationServicesController/processors/process-onchain-notifications.js.map +1 -0
  38. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +8 -0
  39. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +1 -0
  40. package/dist/NotificationServicesController/services/feature-announcements.js +14 -0
  41. package/dist/NotificationServicesController/services/feature-announcements.js.map +1 -0
  42. package/dist/NotificationServicesController/services/feature-announcements.mjs +14 -0
  43. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -0
  44. package/dist/NotificationServicesController/services/onchain-notifications.js +29 -0
  45. package/dist/NotificationServicesController/services/onchain-notifications.js.map +1 -0
  46. package/dist/NotificationServicesController/services/onchain-notifications.mjs +29 -0
  47. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -0
  48. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js +2 -0
  49. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js.map +1 -0
  50. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs +2 -0
  51. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs.map +1 -0
  52. package/dist/NotificationServicesController/types/feature-announcement/index.js +5 -0
  53. package/dist/NotificationServicesController/types/feature-announcement/index.js.map +1 -0
  54. package/dist/NotificationServicesController/types/feature-announcement/index.mjs +5 -0
  55. package/dist/NotificationServicesController/types/feature-announcement/index.mjs.map +1 -0
  56. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js +2 -0
  57. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js.map +1 -0
  58. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs +2 -0
  59. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs.map +1 -0
  60. package/dist/NotificationServicesController/types/feature-announcement/type-links.js +2 -0
  61. package/dist/NotificationServicesController/types/feature-announcement/type-links.js.map +1 -0
  62. package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs +2 -0
  63. package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs.map +1 -0
  64. package/dist/NotificationServicesController/types/index.js +12 -0
  65. package/dist/NotificationServicesController/types/index.js.map +1 -0
  66. package/dist/NotificationServicesController/types/index.mjs +12 -0
  67. package/dist/NotificationServicesController/types/index.mjs.map +1 -0
  68. package/dist/NotificationServicesController/types/notification/index.js +3 -0
  69. package/dist/NotificationServicesController/types/notification/index.js.map +1 -0
  70. package/dist/NotificationServicesController/types/notification/index.mjs +3 -0
  71. package/dist/NotificationServicesController/types/notification/index.mjs.map +1 -0
  72. package/dist/NotificationServicesController/types/notification/notification.js +2 -0
  73. package/dist/NotificationServicesController/types/notification/notification.js.map +1 -0
  74. package/dist/NotificationServicesController/types/notification/notification.mjs +2 -0
  75. package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -0
  76. package/dist/NotificationServicesController/types/on-chain-notification/index.js +3 -0
  77. package/dist/NotificationServicesController/types/on-chain-notification/index.js.map +1 -0
  78. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs +3 -0
  79. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +1 -0
  80. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js +2 -0
  81. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js.map +1 -0
  82. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +2 -0
  83. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +1 -0
  84. package/dist/NotificationServicesController/types/on-chain-notification/schema.js +1 -0
  85. package/dist/NotificationServicesController/types/on-chain-notification/schema.js.map +1 -0
  86. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs +1 -0
  87. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +1 -0
  88. package/dist/NotificationServicesController/types/type-utils.js +1 -0
  89. package/dist/NotificationServicesController/types/type-utils.js.map +1 -0
  90. package/dist/NotificationServicesController/types/type-utils.mjs +1 -0
  91. package/dist/NotificationServicesController/types/type-utils.mjs.map +1 -0
  92. package/dist/NotificationServicesController/types/user-storage/index.js +3 -0
  93. package/dist/NotificationServicesController/types/user-storage/index.js.map +1 -0
  94. package/dist/NotificationServicesController/types/user-storage/index.mjs +3 -0
  95. package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -0
  96. package/dist/NotificationServicesController/types/user-storage/user-storage.js +2 -0
  97. package/dist/NotificationServicesController/types/user-storage/user-storage.js.map +1 -0
  98. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +2 -0
  99. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -0
  100. package/dist/NotificationServicesController/utils/utils.js +32 -0
  101. package/dist/NotificationServicesController/utils/utils.js.map +1 -0
  102. package/dist/NotificationServicesController/utils/utils.mjs +32 -0
  103. package/dist/NotificationServicesController/utils/utils.mjs.map +1 -0
  104. package/dist/NotificationServicesPushController/NotificationServicesPushController.js +34 -0
  105. package/dist/NotificationServicesPushController/NotificationServicesPushController.js.map +1 -0
  106. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +34 -0
  107. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -0
  108. package/dist/NotificationServicesPushController/constants.js +26 -0
  109. package/dist/NotificationServicesPushController/constants.js.map +1 -0
  110. package/dist/NotificationServicesPushController/constants.mjs +26 -0
  111. package/dist/NotificationServicesPushController/constants.mjs.map +1 -0
  112. package/dist/NotificationServicesPushController/index.js +49 -0
  113. package/dist/NotificationServicesPushController/index.js.map +1 -0
  114. package/dist/NotificationServicesPushController/index.mjs +49 -0
  115. package/dist/NotificationServicesPushController/index.mjs.map +1 -0
  116. package/dist/NotificationServicesPushController/services/endpoints.js +8 -0
  117. package/dist/NotificationServicesPushController/services/endpoints.js.map +1 -0
  118. package/dist/NotificationServicesPushController/services/endpoints.mjs +8 -0
  119. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -0
  120. package/dist/NotificationServicesPushController/services/push/index.js +1 -0
  121. package/dist/NotificationServicesPushController/services/push/index.js.map +1 -0
  122. package/dist/NotificationServicesPushController/services/push/index.mjs +1 -0
  123. package/dist/NotificationServicesPushController/services/push/index.mjs.map +1 -0
  124. package/dist/NotificationServicesPushController/services/push/push-web.js +37 -0
  125. package/dist/NotificationServicesPushController/services/push/push-web.js.map +1 -0
  126. package/dist/NotificationServicesPushController/services/push/push-web.mjs +37 -0
  127. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -0
  128. package/dist/NotificationServicesPushController/services/services.js +43 -0
  129. package/dist/NotificationServicesPushController/services/services.js.map +1 -0
  130. package/dist/NotificationServicesPushController/services/services.mjs +43 -0
  131. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -0
  132. package/dist/NotificationServicesPushController/types/firebase.js +2 -0
  133. package/dist/NotificationServicesPushController/types/firebase.js.map +1 -0
  134. package/dist/NotificationServicesPushController/types/firebase.mjs +2 -0
  135. package/dist/NotificationServicesPushController/types/firebase.mjs.map +1 -0
  136. package/dist/NotificationServicesPushController/types/index.js +3 -0
  137. package/dist/NotificationServicesPushController/types/index.js.map +1 -0
  138. package/dist/NotificationServicesPushController/types/index.mjs +3 -0
  139. package/dist/NotificationServicesPushController/types/index.mjs.map +1 -0
  140. package/dist/NotificationServicesPushController/utils/get-notification-data.js +14 -0
  141. package/dist/NotificationServicesPushController/utils/get-notification-data.js.map +1 -0
  142. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +14 -0
  143. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -0
  144. package/dist/NotificationServicesPushController/utils/get-notification-message.js +36 -0
  145. package/dist/NotificationServicesPushController/utils/get-notification-message.js.map +1 -0
  146. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +36 -0
  147. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -0
  148. package/dist/NotificationServicesPushController/utils/index.js +46 -0
  149. package/dist/NotificationServicesPushController/utils/index.js.map +1 -0
  150. package/dist/NotificationServicesPushController/utils/index.mjs +46 -0
  151. package/dist/NotificationServicesPushController/utils/index.mjs.map +1 -0
  152. package/dist/chunk-232HZSEV.js +7 -0
  153. package/dist/chunk-232HZSEV.js.map +1 -0
  154. package/dist/chunk-26CCETCM.mjs +70 -0
  155. package/dist/chunk-26CCETCM.mjs.map +1 -0
  156. package/dist/chunk-3F4M3OUO.mjs +119 -0
  157. package/dist/chunk-3F4M3OUO.mjs.map +1 -0
  158. package/dist/chunk-3ZS2HAEG.js +1 -0
  159. package/dist/chunk-3ZS2HAEG.js.map +1 -0
  160. package/dist/chunk-4BTNTREI.mjs +1 -0
  161. package/dist/chunk-4BTNTREI.mjs.map +1 -0
  162. package/dist/chunk-4QXAPVW3.mjs +1 -0
  163. package/dist/chunk-4QXAPVW3.mjs.map +1 -0
  164. package/dist/chunk-52CALMRA.js +28 -0
  165. package/dist/chunk-52CALMRA.js.map +1 -0
  166. package/dist/chunk-52NKJDI2.mjs +93 -0
  167. package/dist/chunk-52NKJDI2.mjs.map +1 -0
  168. package/dist/chunk-5OYPOYXZ.mjs +802 -0
  169. package/dist/chunk-5OYPOYXZ.mjs.map +1 -0
  170. package/dist/chunk-5WWCWQCE.js +214 -0
  171. package/dist/chunk-5WWCWQCE.js.map +1 -0
  172. package/dist/chunk-6B5FOWRH.js +119 -0
  173. package/dist/chunk-6B5FOWRH.js.map +1 -0
  174. package/dist/chunk-6ZDVTRRT.mjs +9 -0
  175. package/dist/chunk-6ZDVTRRT.mjs.map +1 -0
  176. package/dist/chunk-7LWR54U7.js +7 -0
  177. package/dist/chunk-7LWR54U7.js.map +1 -0
  178. package/dist/chunk-7RM3YNTD.mjs +1 -0
  179. package/dist/chunk-7RM3YNTD.mjs.map +1 -0
  180. package/dist/chunk-A2RPVX47.mjs +1 -0
  181. package/dist/chunk-A2RPVX47.mjs.map +1 -0
  182. package/dist/chunk-B25TJ7KS.js +8 -0
  183. package/dist/chunk-B25TJ7KS.js.map +1 -0
  184. package/dist/chunk-B4ECJJ5C.mjs +7 -0
  185. package/dist/chunk-B4ECJJ5C.mjs.map +1 -0
  186. package/dist/chunk-BONB66A2.mjs +14 -0
  187. package/dist/chunk-BONB66A2.mjs.map +1 -0
  188. package/dist/chunk-CQ6CGSKZ.js +35 -0
  189. package/dist/chunk-CQ6CGSKZ.js.map +1 -0
  190. package/dist/chunk-D42BBXBM.mjs +28 -0
  191. package/dist/chunk-D42BBXBM.mjs.map +1 -0
  192. package/dist/chunk-DMH4NSLF.js +1 -0
  193. package/dist/chunk-DMH4NSLF.js.map +1 -0
  194. package/dist/chunk-DNTK4U5M.js +4300 -0
  195. package/dist/chunk-DNTK4U5M.js.map +1 -0
  196. package/dist/chunk-DY4ELDRQ.js +176 -0
  197. package/dist/chunk-DY4ELDRQ.js.map +1 -0
  198. package/dist/chunk-EJ52BDLB.js +55 -0
  199. package/dist/chunk-EJ52BDLB.js.map +1 -0
  200. package/dist/chunk-EQWVJX6K.mjs +91 -0
  201. package/dist/chunk-EQWVJX6K.mjs.map +1 -0
  202. package/dist/chunk-FFQNSBPU.js +31 -0
  203. package/dist/chunk-FFQNSBPU.js.map +1 -0
  204. package/dist/chunk-G52DNXFH.mjs +1 -0
  205. package/dist/chunk-G52DNXFH.mjs.map +1 -0
  206. package/dist/chunk-GETQWOTI.js +1 -0
  207. package/dist/chunk-GETQWOTI.js.map +1 -0
  208. package/dist/chunk-GFAESVZA.js +48 -0
  209. package/dist/chunk-GFAESVZA.js.map +1 -0
  210. package/dist/chunk-HPUQYDVC.js +1 -0
  211. package/dist/chunk-HPUQYDVC.js.map +1 -0
  212. package/dist/chunk-IDO4JFV5.mjs +1 -0
  213. package/dist/chunk-IDO4JFV5.mjs.map +1 -0
  214. package/dist/chunk-IKWNHNJQ.mjs +8 -0
  215. package/dist/chunk-IKWNHNJQ.mjs.map +1 -0
  216. package/dist/chunk-IOMDG67D.mjs +7 -0
  217. package/dist/chunk-IOMDG67D.mjs.map +1 -0
  218. package/dist/chunk-IPI7BAW3.js +1 -0
  219. package/dist/chunk-IPI7BAW3.js.map +1 -0
  220. package/dist/chunk-JLHFZ2UG.mjs +31 -0
  221. package/dist/chunk-JLHFZ2UG.mjs.map +1 -0
  222. package/dist/chunk-JQ7WKFCI.mjs +1 -0
  223. package/dist/chunk-JQ7WKFCI.mjs.map +1 -0
  224. package/dist/chunk-KTQP5UDT.mjs +4300 -0
  225. package/dist/chunk-KTQP5UDT.mjs.map +1 -0
  226. package/dist/chunk-LYEXYTOI.js +14 -0
  227. package/dist/chunk-LYEXYTOI.js.map +1 -0
  228. package/dist/chunk-NJBJIZLR.js +93 -0
  229. package/dist/chunk-NJBJIZLR.js.map +1 -0
  230. package/dist/chunk-NMLYB3XT.js +149 -0
  231. package/dist/chunk-NMLYB3XT.js.map +1 -0
  232. package/dist/chunk-ODI2BTKS.mjs +55 -0
  233. package/dist/chunk-ODI2BTKS.mjs.map +1 -0
  234. package/dist/chunk-OUPWMPLU.mjs +214 -0
  235. package/dist/chunk-OUPWMPLU.mjs.map +1 -0
  236. package/dist/chunk-PGMXFZ6Y.js +207 -0
  237. package/dist/chunk-PGMXFZ6Y.js.map +1 -0
  238. package/dist/chunk-PIZCE3JD.js +243 -0
  239. package/dist/chunk-PIZCE3JD.js.map +1 -0
  240. package/dist/chunk-PNCS6GEX.mjs +1 -0
  241. package/dist/chunk-PNCS6GEX.mjs.map +1 -0
  242. package/dist/chunk-PROWNV4M.js +1 -0
  243. package/dist/chunk-PROWNV4M.js.map +1 -0
  244. package/dist/chunk-QB5IFRLA.mjs +1 -0
  245. package/dist/chunk-QB5IFRLA.mjs.map +1 -0
  246. package/dist/chunk-QTK2RMF7.mjs +29 -0
  247. package/dist/chunk-QTK2RMF7.mjs.map +1 -0
  248. package/dist/chunk-RAUV5UV4.mjs +1 -0
  249. package/dist/chunk-RAUV5UV4.mjs.map +1 -0
  250. package/dist/chunk-RQWUD2FB.mjs +48 -0
  251. package/dist/chunk-RQWUD2FB.mjs.map +1 -0
  252. package/dist/chunk-SMKJEA45.mjs +243 -0
  253. package/dist/chunk-SMKJEA45.mjs.map +1 -0
  254. package/dist/chunk-SSWX2N73.mjs +207 -0
  255. package/dist/chunk-SSWX2N73.mjs.map +1 -0
  256. package/dist/chunk-TLX5QQK5.js +9 -0
  257. package/dist/chunk-TLX5QQK5.js.map +1 -0
  258. package/dist/chunk-TT56I53C.mjs +149 -0
  259. package/dist/chunk-TT56I53C.mjs.map +1 -0
  260. package/dist/chunk-U74Q3BRP.mjs +1 -0
  261. package/dist/chunk-U74Q3BRP.mjs.map +1 -0
  262. package/dist/chunk-UIRZIKC3.mjs +187 -0
  263. package/dist/chunk-UIRZIKC3.mjs.map +1 -0
  264. package/dist/chunk-UPVIT75F.js +29 -0
  265. package/dist/chunk-UPVIT75F.js.map +1 -0
  266. package/dist/chunk-V46WVGWN.js +70 -0
  267. package/dist/chunk-V46WVGWN.js.map +1 -0
  268. package/dist/chunk-V5HMYDWE.js +1 -0
  269. package/dist/chunk-V5HMYDWE.js.map +1 -0
  270. package/dist/chunk-VC6J62JI.mjs +176 -0
  271. package/dist/chunk-VC6J62JI.mjs.map +1 -0
  272. package/dist/chunk-VE4DTN4R.mjs +35 -0
  273. package/dist/chunk-VE4DTN4R.mjs.map +1 -0
  274. package/dist/chunk-VOZ7Y2OO.js +187 -0
  275. package/dist/chunk-VOZ7Y2OO.js.map +1 -0
  276. package/dist/chunk-WRYFIWNK.js +1 -0
  277. package/dist/chunk-WRYFIWNK.js.map +1 -0
  278. package/dist/chunk-XNBTOK6G.js +802 -0
  279. package/dist/chunk-XNBTOK6G.js.map +1 -0
  280. package/dist/chunk-XZEVRYUE.js +1 -0
  281. package/dist/chunk-XZEVRYUE.js.map +1 -0
  282. package/dist/chunk-ZBNBZN5H.js +1 -0
  283. package/dist/chunk-ZBNBZN5H.js.map +1 -0
  284. package/dist/chunk-ZMNXLHAC.js +91 -0
  285. package/dist/chunk-ZMNXLHAC.js.map +1 -0
  286. package/dist/chunk-ZV3DFBO4.js +1 -0
  287. package/dist/chunk-ZV3DFBO4.js.map +1 -0
  288. package/dist/index.js +43 -0
  289. package/dist/index.js.map +1 -0
  290. package/dist/index.mjs +43 -0
  291. package/dist/index.mjs.map +1 -0
  292. package/dist/tsconfig.build.tsbuildinfo +1 -0
  293. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts +222 -0
  294. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +1 -0
  295. package/dist/types/NotificationServicesController/__fixtures__/index.d.ts +7 -0
  296. package/dist/types/NotificationServicesController/__fixtures__/index.d.ts.map +1 -0
  297. package/dist/types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts +15 -0
  298. package/dist/types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts.map +1 -0
  299. package/dist/types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts +9 -0
  300. package/dist/types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts.map +1 -0
  301. package/dist/types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts +35 -0
  302. package/dist/types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts.map +1 -0
  303. package/dist/types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts +82 -0
  304. package/dist/types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts.map +1 -0
  305. package/dist/types/NotificationServicesController/__fixtures__/mockResponses.d.ts +28 -0
  306. package/dist/types/NotificationServicesController/__fixtures__/mockResponses.d.ts.map +1 -0
  307. package/dist/types/NotificationServicesController/__fixtures__/mockServices.d.ts +12 -0
  308. package/dist/types/NotificationServicesController/__fixtures__/mockServices.d.ts.map +1 -0
  309. package/dist/types/NotificationServicesController/__fixtures__/test-utils.d.ts +14 -0
  310. package/dist/types/NotificationServicesController/__fixtures__/test-utils.d.ts.map +1 -0
  311. package/dist/types/NotificationServicesController/constants/constants.d.ts +3 -0
  312. package/dist/types/NotificationServicesController/constants/constants.d.ts.map +1 -0
  313. package/dist/types/NotificationServicesController/constants/index.d.ts +3 -0
  314. package/dist/types/NotificationServicesController/constants/index.d.ts.map +1 -0
  315. package/dist/types/NotificationServicesController/constants/notification-schema.d.ts +42 -0
  316. package/dist/types/NotificationServicesController/constants/notification-schema.d.ts.map +1 -0
  317. package/dist/types/NotificationServicesController/index.d.ts +6 -0
  318. package/dist/types/NotificationServicesController/index.d.ts.map +1 -0
  319. package/dist/types/NotificationServicesController/processors/index.d.ts +4 -0
  320. package/dist/types/NotificationServicesController/processors/index.d.ts.map +1 -0
  321. package/dist/types/NotificationServicesController/processors/process-feature-announcement.d.ts +19 -0
  322. package/dist/types/NotificationServicesController/processors/process-feature-announcement.d.ts.map +1 -0
  323. package/dist/types/NotificationServicesController/processors/process-notifications.d.ts +19 -0
  324. package/dist/types/NotificationServicesController/processors/process-notifications.d.ts.map +1 -0
  325. package/dist/types/NotificationServicesController/processors/process-onchain-notifications.d.ts +10 -0
  326. package/dist/types/NotificationServicesController/processors/process-onchain-notifications.d.ts.map +1 -0
  327. package/dist/types/NotificationServicesController/services/feature-announcements.d.ts +28 -0
  328. package/dist/types/NotificationServicesController/services/feature-announcements.d.ts.map +1 -0
  329. package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts +62 -0
  330. package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts.map +1 -0
  331. package/dist/types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts +30 -0
  332. package/dist/types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts.map +1 -0
  333. package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts +4 -0
  334. package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts.map +1 -0
  335. package/dist/types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts +38 -0
  336. package/dist/types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts.map +1 -0
  337. package/dist/types/NotificationServicesController/types/feature-announcement/type-links.d.ts +24 -0
  338. package/dist/types/NotificationServicesController/types/feature-announcement/type-links.d.ts.map +1 -0
  339. package/dist/types/NotificationServicesController/types/index.d.ts +5 -0
  340. package/dist/types/NotificationServicesController/types/index.d.ts.map +1 -0
  341. package/dist/types/NotificationServicesController/types/notification/index.d.ts +2 -0
  342. package/dist/types/NotificationServicesController/types/notification/index.d.ts.map +1 -0
  343. package/dist/types/NotificationServicesController/types/notification/notification.d.ts +25 -0
  344. package/dist/types/NotificationServicesController/types/notification/notification.d.ts.map +1 -0
  345. package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts +2 -0
  346. package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts.map +1 -0
  347. package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts +42 -0
  348. package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts.map +1 -0
  349. package/dist/types/NotificationServicesController/types/on-chain-notification/schema.d.ts +283 -0
  350. package/dist/types/NotificationServicesController/types/on-chain-notification/schema.d.ts.map +1 -0
  351. package/dist/types/NotificationServicesController/types/type-utils.d.ts +7 -0
  352. package/dist/types/NotificationServicesController/types/type-utils.d.ts.map +1 -0
  353. package/dist/types/NotificationServicesController/types/user-storage/index.d.ts +2 -0
  354. package/dist/types/NotificationServicesController/types/user-storage/index.d.ts.map +1 -0
  355. package/dist/types/NotificationServicesController/types/user-storage/user-storage.d.ts +26 -0
  356. package/dist/types/NotificationServicesController/types/user-storage/user-storage.d.ts.map +1 -0
  357. package/dist/types/NotificationServicesController/utils/utils.d.ts +144 -0
  358. package/dist/types/NotificationServicesController/utils/utils.d.ts.map +1 -0
  359. package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts +103 -0
  360. package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts.map +1 -0
  361. package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts +3 -0
  362. package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts.map +1 -0
  363. package/dist/types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts +43 -0
  364. package/dist/types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts.map +1 -0
  365. package/dist/types/NotificationServicesPushController/__fixtures__/mockServices.d.ts +9 -0
  366. package/dist/types/NotificationServicesPushController/__fixtures__/mockServices.d.ts.map +1 -0
  367. package/dist/types/NotificationServicesPushController/constants.d.ts +11 -0
  368. package/dist/types/NotificationServicesPushController/constants.d.ts.map +1 -0
  369. package/dist/types/NotificationServicesPushController/index.d.ts +5 -0
  370. package/dist/types/NotificationServicesPushController/index.d.ts.map +1 -0
  371. package/dist/types/NotificationServicesPushController/services/endpoints.d.ts +2 -0
  372. package/dist/types/NotificationServicesPushController/services/endpoints.d.ts.map +1 -0
  373. package/dist/types/NotificationServicesPushController/services/push/index.d.ts +6 -0
  374. package/dist/types/NotificationServicesPushController/services/push/index.d.ts.map +1 -0
  375. package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts +32 -0
  376. package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts.map +1 -0
  377. package/dist/types/NotificationServicesPushController/services/services.d.ts +95 -0
  378. package/dist/types/NotificationServicesPushController/services/services.d.ts.map +1 -0
  379. package/dist/types/NotificationServicesPushController/types/firebase.d.ts +53 -0
  380. package/dist/types/NotificationServicesPushController/types/firebase.d.ts.map +1 -0
  381. package/dist/types/NotificationServicesPushController/types/index.d.ts +2 -0
  382. package/dist/types/NotificationServicesPushController/types/index.d.ts.map +1 -0
  383. package/dist/types/NotificationServicesPushController/utils/get-notification-data.d.ts +42 -0
  384. package/dist/types/NotificationServicesPushController/utils/get-notification-data.d.ts.map +1 -0
  385. package/dist/types/NotificationServicesPushController/utils/get-notification-message.d.ts +67 -0
  386. package/dist/types/NotificationServicesPushController/utils/get-notification-message.d.ts.map +1 -0
  387. package/dist/types/NotificationServicesPushController/utils/index.d.ts +3 -0
  388. package/dist/types/NotificationServicesPushController/utils/index.d.ts.map +1 -0
  389. package/dist/types/index.d.ts +3 -0
  390. package/dist/types/index.d.ts.map +1 -0
  391. package/package.json +80 -0
@@ -0,0 +1,207 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkEJ52BDLBjs = require('./chunk-EJ52BDLB.js');
5
+
6
+
7
+ var _chunkCQ6CGSKZjs = require('./chunk-CQ6CGSKZ.js');
8
+
9
+ // src/NotificationServicesPushController/utils/get-notification-message.ts
10
+ var createOnChainPushNotificationMessages = (translationKeys) => {
11
+ const t = (...args) => {
12
+ const [key, ...otherArgs] = args;
13
+ const fn = translationKeys[key];
14
+ return fn(...otherArgs);
15
+ };
16
+ return {
17
+ erc20_sent: {
18
+ title: t("pushPlatformNotificationsFundsSentTitle"),
19
+ defaultDescription: t(
20
+ "pushPlatformNotificationsFundsSentDescriptionDefault"
21
+ ),
22
+ getDescription: (n) => {
23
+ const symbol = n?.data?.token?.symbol;
24
+ const tokenAmount = n?.data?.token?.amount;
25
+ const tokenDecimals = n?.data?.token?.decimals;
26
+ if (!symbol || !tokenAmount || !tokenDecimals) {
27
+ return null;
28
+ }
29
+ const amount = _chunkEJ52BDLBjs.getAmount.call(void 0, tokenAmount, tokenDecimals, {
30
+ shouldEllipse: true
31
+ });
32
+ return t(
33
+ "pushPlatformNotificationsFundsSentDescription",
34
+ amount,
35
+ symbol
36
+ );
37
+ }
38
+ },
39
+ eth_sent: {
40
+ title: t("pushPlatformNotificationsFundsSentTitle"),
41
+ defaultDescription: t(
42
+ "pushPlatformNotificationsFundsSentDescriptionDefault"
43
+ ),
44
+ getDescription: (n) => {
45
+ const symbol = getChainSymbol(n?.chain_id);
46
+ const tokenAmount = n?.data?.amount?.eth;
47
+ if (!symbol || !tokenAmount) {
48
+ return null;
49
+ }
50
+ const amount = _chunkEJ52BDLBjs.formatAmount.call(void 0, parseFloat(tokenAmount), {
51
+ shouldEllipse: true
52
+ });
53
+ return t(
54
+ "pushPlatformNotificationsFundsSentDescription",
55
+ amount,
56
+ symbol
57
+ );
58
+ }
59
+ },
60
+ erc20_received: {
61
+ title: t("pushPlatformNotificationsFundsReceivedTitle"),
62
+ defaultDescription: t(
63
+ "pushPlatformNotificationsFundsReceivedDescriptionDefault"
64
+ ),
65
+ getDescription: (n) => {
66
+ const symbol = n?.data?.token?.symbol;
67
+ const tokenAmount = n?.data?.token?.amount;
68
+ const tokenDecimals = n?.data?.token?.decimals;
69
+ if (!symbol || !tokenAmount || !tokenDecimals) {
70
+ return null;
71
+ }
72
+ const amount = _chunkEJ52BDLBjs.getAmount.call(void 0, tokenAmount, tokenDecimals, {
73
+ shouldEllipse: true
74
+ });
75
+ return t(
76
+ "pushPlatformNotificationsFundsReceivedDescription",
77
+ amount,
78
+ symbol
79
+ );
80
+ }
81
+ },
82
+ eth_received: {
83
+ title: t("pushPlatformNotificationsFundsReceivedTitle"),
84
+ defaultDescription: t(
85
+ "pushPlatformNotificationsFundsReceivedDescriptionDefault"
86
+ ),
87
+ getDescription: (n) => {
88
+ const symbol = getChainSymbol(n?.chain_id);
89
+ const tokenAmount = n?.data?.amount?.eth;
90
+ if (!symbol || !tokenAmount) {
91
+ return null;
92
+ }
93
+ const amount = _chunkEJ52BDLBjs.formatAmount.call(void 0, parseFloat(tokenAmount), {
94
+ shouldEllipse: true
95
+ });
96
+ return t(
97
+ "pushPlatformNotificationsFundsReceivedDescription",
98
+ amount,
99
+ symbol
100
+ );
101
+ }
102
+ },
103
+ metamask_swap_completed: {
104
+ title: t("pushPlatformNotificationsSwapCompletedTitle"),
105
+ defaultDescription: t(
106
+ "pushPlatformNotificationsSwapCompletedDescription"
107
+ )
108
+ },
109
+ erc721_sent: {
110
+ title: t("pushPlatformNotificationsNftSentTitle"),
111
+ defaultDescription: t("pushPlatformNotificationsNftSentDescription")
112
+ },
113
+ erc1155_sent: {
114
+ title: t("pushPlatformNotificationsNftSentTitle"),
115
+ defaultDescription: t("pushPlatformNotificationsNftSentDescription")
116
+ },
117
+ erc721_received: {
118
+ title: t("pushPlatformNotificationsNftReceivedTitle"),
119
+ defaultDescription: t("pushPlatformNotificationsNftReceivedDescription")
120
+ },
121
+ erc1155_received: {
122
+ title: t("pushPlatformNotificationsNftReceivedTitle"),
123
+ defaultDescription: t("pushPlatformNotificationsNftReceivedDescription")
124
+ },
125
+ rocketpool_stake_completed: {
126
+ title: t("pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle"),
127
+ defaultDescription: t(
128
+ "pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription"
129
+ )
130
+ },
131
+ rocketpool_unstake_completed: {
132
+ title: t(
133
+ "pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle"
134
+ ),
135
+ defaultDescription: t(
136
+ "pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription"
137
+ )
138
+ },
139
+ lido_stake_completed: {
140
+ title: t("pushPlatformNotificationsStakingLidoStakeCompletedTitle"),
141
+ defaultDescription: t(
142
+ "pushPlatformNotificationsStakingLidoStakeCompletedDescription"
143
+ )
144
+ },
145
+ lido_stake_ready_to_be_withdrawn: {
146
+ title: t(
147
+ "pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle"
148
+ ),
149
+ defaultDescription: t(
150
+ "pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription"
151
+ )
152
+ },
153
+ lido_withdrawal_requested: {
154
+ title: t("pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle"),
155
+ defaultDescription: t(
156
+ "pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription"
157
+ )
158
+ },
159
+ lido_withdrawal_completed: {
160
+ title: t("pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle"),
161
+ defaultDescription: t(
162
+ "pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription"
163
+ )
164
+ }
165
+ };
166
+ };
167
+ function getChainSymbol(chainId) {
168
+ return _chunkCQ6CGSKZjs.constants_exports.CHAIN_SYMBOLS[chainId] ?? null;
169
+ }
170
+ function isOnChainNotification(n) {
171
+ const assumed = n;
172
+ const isValidEnoughToBeOnChainNotification = [
173
+ assumed?.id,
174
+ assumed?.data,
175
+ assumed?.trigger_id
176
+ ].every((field) => field !== void 0);
177
+ return isValidEnoughToBeOnChainNotification;
178
+ }
179
+ function createOnChainPushNotificationMessage(n, translations) {
180
+ if (!n?.type) {
181
+ return null;
182
+ }
183
+ const notificationMessage = createOnChainPushNotificationMessages(translations)[n.type];
184
+ if (!notificationMessage) {
185
+ return null;
186
+ }
187
+ let description = null;
188
+ try {
189
+ description = // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
+ notificationMessage?.getDescription?.(n) ?? notificationMessage.defaultDescription ?? null;
191
+ } catch (e) {
192
+ description = notificationMessage.defaultDescription ?? null;
193
+ }
194
+ return {
195
+ title: notificationMessage.title ?? "",
196
+ // Ensure title is always a string
197
+ description: description ?? ""
198
+ // Fallback to empty string if null
199
+ };
200
+ }
201
+
202
+
203
+
204
+
205
+
206
+ exports.createOnChainPushNotificationMessages = createOnChainPushNotificationMessages; exports.isOnChainNotification = isOnChainNotification; exports.createOnChainPushNotificationMessage = createOnChainPushNotificationMessage;
207
+ //# sourceMappingURL=chunk-PGMXFZ6Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":";;;;;;;;;AA4DO,IAAM,wCAAwC,CACnD,oBAC4B;AAI5B,QAAM,IAAmB,IAAI,SAAS;AACpC,UAAM,CAAC,KAAK,GAAG,SAAS,IAAI;AAI5B,UAAM,KAAU,gBAAgB,GAAG;AACnC,WAAO,GAAG,GAAG,SAAS;AAAA,EACxB;AAEA,SAAO;AAAA,IACL,YAAY;AAAA,MACV,OAAO,EAAE,yCAAyC;AAAA,MAClD,o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;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,IACA,kCAAkC;AAAA,MAChC,OAAO;AAAA,QACL;AAAA,MACF;AAAA,MACA,oBAAoB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,IACA,2BAA2B;AAAA,MACzB,OAAO,EAAE,8DAA8D;AAAA,MACvE,oBAAoB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,IACA,2BAA2B;AAAA,MACzB,OAAO,EAAE,8DAA8D;AAAA,MACvE,oBAAoB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAQA,SAAS,eAAe,SAAiB;AACvC,SAAO,kBAAU,cAAc,OAAO,KAAK;AAC7C;AAQO,SAAS,sBACd,GACmC;AACnC,QAAM,UAAU;AAIhB,QAAM,uCAAuC;AAAA,IAC3C,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,EACX,EAAE,MAAM,CAAC,UAAU,UAAU,MAAS;AACtC,SAAO;AACT;AASO,SAAS,qCACd,GACA,cACgC;AAChC,MAAI,CAAC,GAAG,MAAM;AACZ,WAAO;AAAA,EACT;AACA,QAAM,sBACJ,sCAAsC,YAAY,EAAE,EAAE,IAAI;AAE5D,MAAI,CAAC,qBAAqB;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,cAA6B;AACjC,MAAI;AACF;AAAA,IAEE,qBAAqB,iBAAiB,CAAQ,KAC9C,oBAAoB,sBACpB;AAAA,EACJ,SAAS,GAAG;AACV,kBAAc,oBAAoB,sBAAsB;AAAA,EAC1D;AAEA,SAAO;AAAA,IACL,OAAO,oBAAoB,SAAS;AAAA;AAAA,IACpC,aAAa,eAAe;AAAA;AAAA,EAC9B;AACF","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { Types } from '../../NotificationServicesController';\nimport { Constants } from '../../NotificationServicesController';\nimport { getAmount, formatAmount } from './get-notification-data';\n\nexport type TranslationKeys = {\n pushPlatformNotificationsFundsSentTitle: () => string;\n pushPlatformNotificationsFundsSentDescriptionDefault: () => string;\n pushPlatformNotificationsFundsSentDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsFundsReceivedTitle: () => string;\n pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;\n pushPlatformNotificationsFundsReceivedDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsSwapCompletedTitle: () => string;\n pushPlatformNotificationsSwapCompletedDescription: () => string;\n pushPlatformNotificationsNftSentTitle: () => string;\n pushPlatformNotificationsNftSentDescription: () => string;\n pushPlatformNotificationsNftReceivedTitle: () => string;\n pushPlatformNotificationsNftReceivedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;\n};\n\ntype PushNotificationMessage = {\n title: string;\n description: string;\n};\n\ntype NotificationMessage<N extends Types.INotification> = {\n title: string | null;\n defaultDescription: string | null;\n getDescription?: (n: N) => string | null;\n};\n\ntype NotificationMessageDict = {\n [K in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: K }>\n >;\n};\n\n/**\n * On Chain Push Notification Messages.\n * This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension\n *\n * @param translationKeys - all translations supported\n * @returns A translation push message object.\n */\nexport const createOnChainPushNotificationMessages = (\n translationKeys: TranslationKeys,\n): NotificationMessageDict => {\n type TranslationFn = <K extends keyof TranslationKeys>(\n ...args: [K, ...Parameters<TranslationKeys[K]>]\n ) => string;\n const t: TranslationFn = (...args) => {\n const [key, ...otherArgs] = args;\n\n // Coerce types for the translation function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn: any = translationKeys[key];\n return fn(...otherArgs);\n };\n\n return {\n erc20_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsSwapCompletedDescription',\n ),\n },\n erc721_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n };\n};\n\n/**\n * Retrieves the symbol associated with a given chain ID.\n *\n * @param chainId - The ID of the chain.\n * @returns The symbol associated with the chain ID, or null if not found.\n */\nfunction getChainSymbol(chainId: number) {\n return Constants.CHAIN_SYMBOLS[chainId] ?? null;\n}\n\n/**\n * Checks if the given value is an OnChainRawNotification object.\n *\n * @param n - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainNotification(\n n: unknown,\n): n is Types.OnChainRawNotification {\n const assumed = n as Types.OnChainRawNotification;\n\n // We don't have a validation/parsing library to check all possible types of an on chain notification\n // It is safe enough just to check \"some\" fields, and catch any errors down the line if the shape is bad.\n const isValidEnoughToBeOnChainNotification = [\n assumed?.id,\n assumed?.data,\n assumed?.trigger_id,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param n - processed notification.\n * @param translations - translates keys into text\n * @returns The push notification message object, or null if the notification is invalid.\n */\nexport function createOnChainPushNotificationMessage(\n n: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!n?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[n.type];\n\n if (!notificationMessage) {\n return null;\n }\n\n let description: string | null = null;\n try {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage?.getDescription?.(n as any) ??\n notificationMessage.defaultDescription ??\n null;\n } catch (e) {\n description = notificationMessage.defaultDescription ?? null;\n }\n\n return {\n title: notificationMessage.title ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
@@ -0,0 +1,243 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunkDY4ELDRQjs = require('./chunk-DY4ELDRQ.js');
4
+
5
+
6
+
7
+ var _chunkTLX5QQK5js = require('./chunk-TLX5QQK5.js');
8
+
9
+ // src/NotificationServicesController/utils/utils.ts
10
+ var _loglevel = require('loglevel'); var _loglevel2 = _interopRequireDefault(_loglevel);
11
+ var _uuid = require('uuid');
12
+ var triggerToId = (trigger) => trigger.id;
13
+ var triggerIdentity = (trigger) => trigger;
14
+ function initializeUserStorage(accounts, state) {
15
+ const userStorage = {
16
+ [_chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY]: _chunkTLX5QQK5js.USER_STORAGE_VERSION
17
+ };
18
+ accounts.forEach((account) => {
19
+ const address = account.address?.toLowerCase();
20
+ if (!address) {
21
+ return;
22
+ }
23
+ if (!userStorage[address]) {
24
+ userStorage[address] = {};
25
+ }
26
+ Object.entries(_chunkDY4ELDRQjs.TRIGGERS).forEach(
27
+ ([trigger, { supported_chains: supportedChains }]) => {
28
+ supportedChains.forEach((chain) => {
29
+ if (!userStorage[address]?.[chain]) {
30
+ userStorage[address][chain] = {};
31
+ }
32
+ userStorage[address][chain][_uuid.v4.call(void 0, )] = {
33
+ k: trigger,
34
+ // use 'k' instead of 'kind' to reduce the json weight
35
+ e: state
36
+ // use 'e' instead of 'enabled' to reduce the json weight
37
+ };
38
+ });
39
+ }
40
+ );
41
+ });
42
+ return userStorage;
43
+ }
44
+ function traverseUserStorageTriggers(userStorage, options) {
45
+ const triggers = [];
46
+ const mapTrigger = options?.mapTrigger ?? triggerIdentity;
47
+ for (const address in userStorage) {
48
+ if (address === _chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY) {
49
+ continue;
50
+ }
51
+ if (options?.address && address !== options.address) {
52
+ continue;
53
+ }
54
+ for (const chainId in userStorage[address]) {
55
+ if (chainId in userStorage[address]) {
56
+ for (const uuid in userStorage[address][chainId]) {
57
+ if (uuid) {
58
+ const mappedTrigger = mapTrigger({
59
+ id: uuid,
60
+ kind: userStorage[address]?.[chainId]?.[uuid]?.k,
61
+ chainId,
62
+ address,
63
+ enabled: userStorage[address]?.[chainId]?.[uuid]?.e ?? false
64
+ });
65
+ if (mappedTrigger) {
66
+ triggers.push(mappedTrigger);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ return triggers;
74
+ }
75
+ function checkAccountsPresence(userStorage, accounts) {
76
+ const presenceRecord = {};
77
+ accounts.forEach((account) => {
78
+ presenceRecord[account.toLowerCase()] = isAccountEnabled(
79
+ account,
80
+ userStorage
81
+ );
82
+ });
83
+ return presenceRecord;
84
+ }
85
+ function isAccountEnabled(accountAddress, userStorage) {
86
+ const accountObject = userStorage[accountAddress?.toLowerCase()];
87
+ if (!accountObject) {
88
+ return false;
89
+ }
90
+ for (const [triggerKind, triggerConfig] of Object.entries(_chunkDY4ELDRQjs.TRIGGERS)) {
91
+ for (const chain of triggerConfig.supported_chains) {
92
+ if (!accountObject[chain]) {
93
+ return false;
94
+ }
95
+ const triggerExists = Object.values(accountObject[chain]).some(
96
+ (obj) => obj.k === triggerKind
97
+ );
98
+ if (!triggerExists) {
99
+ return false;
100
+ }
101
+ for (const uuid in accountObject[chain]) {
102
+ if (!accountObject[chain][uuid].e) {
103
+ return false;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ return true;
109
+ }
110
+ function inferEnabledKinds(userStorage) {
111
+ const allSupportedKinds = /* @__PURE__ */ new Set();
112
+ traverseUserStorageTriggers(userStorage, {
113
+ mapTrigger: (t) => {
114
+ allSupportedKinds.add(t.kind);
115
+ }
116
+ });
117
+ return Array.from(allSupportedKinds);
118
+ }
119
+ function getUUIDsForAccount(userStorage, address) {
120
+ return traverseUserStorageTriggers(userStorage, {
121
+ address,
122
+ mapTrigger: triggerToId
123
+ });
124
+ }
125
+ function getAllUUIDs(userStorage) {
126
+ return traverseUserStorageTriggers(userStorage, {
127
+ mapTrigger: triggerToId
128
+ });
129
+ }
130
+ function getUUIDsForKinds(userStorage, allowedKinds) {
131
+ const kindsSet = new Set(allowedKinds);
132
+ return traverseUserStorageTriggers(userStorage, {
133
+ mapTrigger: (t) => kindsSet.has(t.kind) ? t.id : void 0
134
+ });
135
+ }
136
+ function getUUIDsForAccountByKinds(userStorage, address, allowedKinds) {
137
+ const allowedKindsSet = new Set(allowedKinds);
138
+ return traverseUserStorageTriggers(userStorage, {
139
+ address,
140
+ mapTrigger: (trigger) => {
141
+ if (allowedKindsSet.has(trigger.kind)) {
142
+ return trigger;
143
+ }
144
+ return void 0;
145
+ }
146
+ });
147
+ }
148
+ function upsertAddressTriggers(_account, userStorage) {
149
+ const account = _account.toLowerCase();
150
+ userStorage[account] = userStorage[account] || {};
151
+ for (const [trigger, { supported_chains: supportedChains }] of Object.entries(
152
+ _chunkDY4ELDRQjs.TRIGGERS
153
+ )) {
154
+ for (const chain of supportedChains) {
155
+ userStorage[account][chain] = userStorage[account][chain] || {};
156
+ const existingTrigger = Object.values(userStorage[account][chain]).find(
157
+ (obj) => obj.k === trigger
158
+ );
159
+ if (!existingTrigger) {
160
+ const uuid = _uuid.v4.call(void 0, );
161
+ userStorage[account][chain][uuid] = {
162
+ k: trigger,
163
+ e: false
164
+ };
165
+ }
166
+ }
167
+ }
168
+ return userStorage;
169
+ }
170
+ function upsertTriggerTypeTriggers(triggerType, userStorage) {
171
+ Object.entries(userStorage).forEach(([account, chains]) => {
172
+ if (account === _chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY) {
173
+ return;
174
+ }
175
+ Object.entries(chains).forEach(([chain, triggers]) => {
176
+ const existingTrigger = Object.values(triggers).find(
177
+ (obj) => obj.k === triggerType
178
+ );
179
+ if (!existingTrigger) {
180
+ const uuid = _uuid.v4.call(void 0, );
181
+ userStorage[account][chain][uuid] = {
182
+ k: triggerType,
183
+ e: false
184
+ };
185
+ }
186
+ });
187
+ });
188
+ return userStorage;
189
+ }
190
+ function toggleUserStorageTriggerStatus(userStorage, address, chainId, uuid, enabled) {
191
+ if (userStorage?.[address]?.[chainId]?.[uuid]) {
192
+ userStorage[address][chainId][uuid].e = enabled;
193
+ }
194
+ return userStorage;
195
+ }
196
+ async function fetchWithRetry(url, options, retries = 3, retryDelay = 1e3) {
197
+ for (let attempt = 1; attempt <= retries; attempt++) {
198
+ try {
199
+ const response = await fetch(url, options);
200
+ if (!response.ok) {
201
+ throw new Error(`Fetch failed with status: ${response.status}`);
202
+ }
203
+ return response;
204
+ } catch (error) {
205
+ _loglevel2.default.error(`Attempt ${attempt} failed for fetch:`, error);
206
+ if (attempt < retries) {
207
+ await new Promise((resolve) => setTimeout(resolve, retryDelay));
208
+ } else {
209
+ throw new Error(
210
+ `Fetching failed after ${retries} retries. Last error: ${error instanceof Error ? error.message : "Unknown error"}`
211
+ );
212
+ }
213
+ }
214
+ }
215
+ throw new Error("Unexpected error in fetchWithRetry");
216
+ }
217
+ async function makeApiCall(bearerToken, endpoint, method, body, retries = 3, retryDelay = 1e3) {
218
+ const options = {
219
+ method,
220
+ headers: {
221
+ "Content-Type": "application/json",
222
+ Authorization: `Bearer ${bearerToken}`
223
+ },
224
+ body: JSON.stringify(body)
225
+ };
226
+ return fetchWithRetry(endpoint, options, retries, retryDelay);
227
+ }
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+ exports.initializeUserStorage = initializeUserStorage; exports.traverseUserStorageTriggers = traverseUserStorageTriggers; exports.checkAccountsPresence = checkAccountsPresence; exports.inferEnabledKinds = inferEnabledKinds; exports.getUUIDsForAccount = getUUIDsForAccount; exports.getAllUUIDs = getAllUUIDs; exports.getUUIDsForKinds = getUUIDsForKinds; exports.getUUIDsForAccountByKinds = getUUIDsForAccountByKinds; exports.upsertAddressTriggers = upsertAddressTriggers; exports.upsertTriggerTypeTriggers = upsertTriggerTypeTriggers; exports.toggleUserStorageTriggerStatus = toggleUserStorageTriggerStatus; exports.makeApiCall = makeApiCall;
243
+ //# sourceMappingURL=chunk-PIZCE3JD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/utils/utils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS;AAChB,SAAS,MAAM,cAAc;AAmC7B,IAAM,cAAc,CAAC,YAAyC,QAAQ;AAUtE,IAAM,kBAAkB,CAAC,YACvB;AAgBK,SAAS,sBACd,UACA,OACa;AACb,QAAM,cAA2B;AAAA,IAC/B,CAAC,wBAAwB,GAAG;AAAA,EAC9B;AAEA,WAAS,QAAQ,CAAC,YAAY;AAC5B,UAAM,UAAU,QAAQ,SAAS,YAAY;AAC7C,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AACA,QAAI,CAAC,YAAY,OAAO,GAAG;AACzB,kBAAY,OAAO,IAAI,CAAC;AAAA,IAC1B;AAEA,WAAO,QAAQ,QAAQ,EAAE;AAAA,MACvB,CAAC,CAAC,SAAS,EAAE,kBAAkB,gBAAgB,CAAC,MAAM;AACpD,wBAAgB,QAAQ,CAAC,UAAU;AACjC,cAAI,CAAC,YAAY,OAAO,IAAI,KAAK,GAAG;AAClC,wBAAY,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,UACjC;AAEA,sBAAY,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI;AAAA,YACtC,GAAG;AAAA;AAAA,YACH,GAAG;AAAA;AAAA,UACL;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAYO,SAAS,4BAGd,aACA,SACkB;AAClB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AAS,WAAW;AACnD,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,KAAK,OAAO;AACzC,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,6BAA6B,SAAS,MAAM,EAAE;AAAA,MAChE;AACA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,MAAM,WAAW,OAAO,sBAAsB,KAAK;AACvD,UAAI,UAAU,SAAS;AACrB,cAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,UAAU,CAAC;AAAA,MAChE,OAAO;AACL,cAAM,IAAI;AAAA,UACR,yBAAyB,OAAO,yBAC9B,iBAAiB,QAAQ,MAAM,UAAU,eAC3C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAaA,eAAsB,YACpB,aACA,UACA,QACA,MACA,UAAU,GACV,aAAa,KACM;AACnB,QAAM,UAAuB;AAAA,IAC3B;AAAA,IACA,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,eAAe,UAAU,WAAW;AAAA,IACtC;AAAA,IACA,MAAM,KAAK,UAAU,IAAI;AAAA,EAC3B;AAEA,SAAO,eAAe,UAAU,SAAS,SAAS,UAAU;AAC9D","sourcesContent":["import log from 'loglevel';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from '../constants/constants';\nimport type { TRIGGER_TYPES } from '../constants/notification-schema';\nimport { TRIGGERS } from '../constants/notification-schema';\nimport type { UserStorage } from '../types/user-storage/user-storage';\n\nexport type NotificationTrigger = {\n id: string;\n chainId: string;\n kind: string;\n address: string;\n enabled: boolean;\n};\n\ntype MapTriggerFn<Result> = (\n trigger: NotificationTrigger,\n) => Result | undefined;\n\ntype TraverseTriggerOpts<Result> = {\n address?: string;\n mapTrigger?: MapTriggerFn<Result>;\n};\n\n/**\n * Extracts and returns the ID from a notification trigger.\n * This utility function is primarily used as a mapping function in `traverseUserStorageTriggers`\n * to convert a full trigger object into its ID string.\n *\n * @param trigger - The notification trigger from which the ID is extracted.\n * @returns The ID of the provided notification trigger.\n */\nconst triggerToId = (trigger: NotificationTrigger): string => trigger.id;\n\n/**\n * A utility function that returns the input trigger without any transformation.\n * This function is used as the default mapping function in `traverseUserStorageTriggers`\n * when no custom mapping function is provided.\n *\n * @param trigger - The notification trigger to be returned as is.\n * @returns The same notification trigger that was passed in.\n */\nconst triggerIdentity = (trigger: NotificationTrigger): NotificationTrigger =>\n trigger;\n\n/**\n * Create a completely new user storage object with the given accounts and state.\n * This method initializes the user storage with a version key and iterates over each account to populate it with triggers.\n * Each trigger is associated with supported chains, and for each chain, a unique identifier (UUID) is generated.\n * The trigger object contains a kind (`k`) indicating the type of trigger and an enabled state (`e`).\n * The kind and enabled state are stored with abbreviated keys to reduce the JSON size.\n *\n * This is used primarily for creating a new user storage (e.g. when first signing in/enabling notification profile syncing),\n * caution is needed in case you need to remove triggers that you don't want (due to notification setting filters)\n *\n * @param accounts - An array of account objects, each optionally containing an address.\n * @param state - A boolean indicating the initial enabled state for all triggers in the user storage.\n * @returns A `UserStorage` object populated with triggers for each account and chain.\n */\nexport function initializeUserStorage(\n accounts: { address?: string }[],\n state: boolean,\n): UserStorage {\n const userStorage: UserStorage = {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n };\n\n accounts.forEach((account) => {\n const address = account.address?.toLowerCase();\n if (!address) {\n return;\n }\n if (!userStorage[address]) {\n userStorage[address] = {};\n }\n\n Object.entries(TRIGGERS).forEach(\n ([trigger, { supported_chains: supportedChains }]) => {\n supportedChains.forEach((chain) => {\n if (!userStorage[address]?.[chain]) {\n userStorage[address][chain] = {};\n }\n\n userStorage[address][chain][uuidv4()] = {\n k: trigger as TRIGGER_TYPES, // use 'k' instead of 'kind' to reduce the json weight\n e: state, // use 'e' instead of 'enabled' to reduce the json weight\n };\n });\n },\n );\n });\n\n return userStorage;\n}\n\n/**\n * Iterates over user storage to find and optionally transform notification triggers.\n * This method allows for flexible retrieval and transformation of triggers based on provided options.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param options - Optional parameters to filter and map triggers:\n * - `address`: If provided, only triggers for this address are considered.\n * - `mapTrigger`: A function to transform each trigger. If not provided, triggers are returned as is.\n * @returns An array of triggers, potentially transformed by the `mapTrigger` function.\n */\nexport function traverseUserStorageTriggers<\n ResultTriggers = NotificationTrigger,\n>(\n userStorage: UserStorage,\n options?: TraverseTriggerOpts<ResultTriggers>,\n): ResultTriggers[] {\n const triggers: ResultTriggers[] = [];\n const mapTrigger =\n options?.mapTrigger ?? (triggerIdentity as MapTriggerFn<ResultTriggers>);\n\n for (const address in userStorage) {\n if (address === (USER_STORAGE_VERSION_KEY as unknown as string)) {\n continue;\n }\n if (options?.address && address !== options.address) {\n continue;\n }\n\n for (const chainId in userStorage[address]) {\n if (chainId in userStorage[address]) {\n for (const uuid in userStorage[address][chainId]) {\n if (uuid) {\n const mappedTrigger = mapTrigger({\n id: uuid,\n kind: userStorage[address]?.[chainId]?.[uuid]?.k,\n chainId,\n address,\n enabled: userStorage[address]?.[chainId]?.[uuid]?.e ?? false,\n });\n if (mappedTrigger) {\n triggers.push(mappedTrigger);\n }\n }\n }\n }\n }\n }\n\n return triggers;\n}\n\n/**\n * Verifies the presence of specified accounts and their chains in the user storage.\n * This method checks if each provided account exists in the user storage and if all its supported chains are present.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param accounts - An array of account addresses to check for presence.\n * @returns A record where each key is an account address and each value is a boolean indicating whether the account and all its supported chains are present in the user storage.\n */\nexport function checkAccountsPresence(\n userStorage: UserStorage,\n accounts: string[],\n): Record<string, boolean> {\n const presenceRecord: Record<string, boolean> = {};\n\n // Initialize presence record for all accounts as false\n accounts.forEach((account) => {\n presenceRecord[account.toLowerCase()] = isAccountEnabled(\n account,\n userStorage,\n );\n });\n\n return presenceRecord;\n}\n\n/**\n * Internal method to check if a given account should be marked as enabled by introspecting user storage\n * Introspection: check if account exists; and also see if has all triggers in schema enabled\n *\n * @param accountAddress - address to check in user storage\n * @param userStorage - user storage object to traverse/introspect\n * @returns boolean if the account is enabled or disabled\n */\nfunction isAccountEnabled(\n accountAddress: string,\n userStorage: UserStorage,\n): boolean {\n const accountObject = userStorage[accountAddress?.toLowerCase()];\n\n // If the account address is not present in the userStorage, return true\n if (!accountObject) {\n return false;\n }\n\n // Check if all available chains are present\n for (const [triggerKind, triggerConfig] of Object.entries(TRIGGERS)) {\n for (const chain of triggerConfig.supported_chains) {\n if (!accountObject[chain]) {\n return false;\n }\n\n const triggerExists = Object.values(accountObject[chain]).some(\n (obj) => obj.k === triggerKind,\n );\n if (!triggerExists) {\n return false;\n }\n\n // Check if any trigger is disabled\n for (const uuid in accountObject[chain]) {\n if (!accountObject[chain][uuid].e) {\n return false;\n }\n }\n }\n }\n\n return true;\n}\n\n/**\n * Infers and returns an array of enabled notification trigger kinds from the user storage.\n * This method counts the occurrences of each kind of trigger and returns the kinds that are present.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @returns An array of trigger kinds (`TRIGGER_TYPES`) that are enabled in the user storage.\n */\nexport function inferEnabledKinds(userStorage: UserStorage): TRIGGER_TYPES[] {\n const allSupportedKinds = new Set<TRIGGER_TYPES>();\n\n traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => {\n allSupportedKinds.add(t.kind as TRIGGER_TYPES);\n },\n });\n\n return Array.from(allSupportedKinds);\n}\n\n/**\n * Retrieves all UUIDs associated with a specific account address from the user storage.\n * This function utilizes `traverseUserStorageTriggers` with a mapping function to extract\n * just the UUIDs of the notification triggers for the given address.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param address - The specific account address to retrieve UUIDs for.\n * @returns An array of UUID strings associated with the given account address.\n */\nexport function getUUIDsForAccount(\n userStorage: UserStorage,\n address: string,\n): string[] {\n return traverseUserStorageTriggers(userStorage, {\n address,\n mapTrigger: triggerToId,\n });\n}\n\n/**\n * Retrieves all UUIDs from the user storage, regardless of the account address or chain ID.\n * This method leverages `traverseUserStorageTriggers` with a specific mapping function (`triggerToId`)\n * to extract only the UUIDs from all notification triggers present in the user storage.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @returns An array of UUID strings from all notification triggers in the user storage.\n */\nexport function getAllUUIDs(userStorage: UserStorage): string[] {\n return traverseUserStorageTriggers(userStorage, {\n mapTrigger: triggerToId,\n });\n}\n\n/**\n * Retrieves UUIDs for notification triggers that match any of the specified kinds.\n * This method filters triggers based on their kind and returns an array of UUIDs for those that match the allowed kinds.\n * It utilizes `traverseUserStorageTriggers` with a custom mapping function that checks if a trigger's kind is in the allowed list.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param allowedKinds - An array of kinds (as strings) to filter the triggers by.\n * @returns An array of UUID strings for triggers that match the allowed kinds.\n */\nexport function getUUIDsForKinds(\n userStorage: UserStorage,\n allowedKinds: string[],\n): string[] {\n const kindsSet = new Set(allowedKinds);\n\n return traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => (kindsSet.has(t.kind) ? t.id : undefined),\n });\n}\n\n/**\n * Retrieves notification triggers for a specific account address that match any of the specified kinds.\n * This method filters triggers both by the account address and their kind, returning triggers that match the allowed kinds for the specified address.\n * It leverages `traverseUserStorageTriggers` with a custom mapping function to filter and return only the relevant triggers.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param address - The specific account address for which to retrieve triggers.\n * @param allowedKinds - An array of trigger kinds (`TRIGGER_TYPES`) to filter the triggers by.\n * @returns An array of `NotificationTrigger` objects that match the allowed kinds for the specified account address.\n */\nexport function getUUIDsForAccountByKinds(\n userStorage: UserStorage,\n address: string,\n allowedKinds: TRIGGER_TYPES[],\n): NotificationTrigger[] {\n const allowedKindsSet = new Set(allowedKinds);\n return traverseUserStorageTriggers(userStorage, {\n address,\n mapTrigger: (trigger) => {\n if (allowedKindsSet.has(trigger.kind as TRIGGER_TYPES)) {\n return trigger;\n }\n return undefined;\n },\n });\n}\n\n/**\n * Upserts (updates or inserts) notification triggers for a given account across all supported chains.\n * This method ensures that each supported trigger type exists for each chain associated with the account.\n * If a trigger type does not exist for a chain, it creates a new trigger with a unique UUID.\n *\n * @param _account - The account address for which to upsert triggers. The address is normalized to lowercase.\n * @param userStorage - The user storage object to be updated with new or existing triggers.\n * @returns The updated user storage object with upserted triggers for the specified account.\n */\nexport function upsertAddressTriggers(\n _account: string,\n userStorage: UserStorage,\n): UserStorage {\n // Ensure the account exists in userStorage\n const account = _account.toLowerCase();\n userStorage[account] = userStorage[account] || {};\n\n // Iterate over each trigger and its supported chains\n for (const [trigger, { supported_chains: supportedChains }] of Object.entries(\n TRIGGERS,\n )) {\n for (const chain of supportedChains) {\n // Ensure the chain exists for the account\n userStorage[account][chain] = userStorage[account][chain] || {};\n\n // Check if the trigger exists for the chain\n const existingTrigger = Object.values(userStorage[account][chain]).find(\n (obj) => obj.k === trigger,\n );\n\n if (!existingTrigger) {\n // If the trigger doesn't exist, create a new one with a new UUID\n const uuid = uuidv4();\n userStorage[account][chain][uuid] = {\n k: trigger as TRIGGER_TYPES,\n e: false,\n };\n }\n }\n }\n\n return userStorage;\n}\n\n/**\n * Upserts (updates or inserts) notification triggers of a specific type across all accounts and chains in user storage.\n * This method ensures that a trigger of the specified type exists for each account and chain. If a trigger of the specified type\n * does not exist for an account and chain, it creates a new trigger with a unique UUID.\n *\n * @param triggerType - The type of trigger to upsert across all accounts and chains.\n * @param userStorage - The user storage object to be updated with new or existing triggers of the specified type.\n * @returns The updated user storage object with upserted triggers of the specified type for all accounts and chains.\n */\nexport function upsertTriggerTypeTriggers(\n triggerType: TRIGGER_TYPES,\n userStorage: UserStorage,\n): UserStorage {\n // Iterate over each account in userStorage\n Object.entries(userStorage).forEach(([account, chains]) => {\n if (account === (USER_STORAGE_VERSION_KEY as unknown as string)) {\n return;\n }\n\n // Iterate over each chain for the account\n Object.entries(chains).forEach(([chain, triggers]) => {\n // Check if the trigger type exists for the chain\n const existingTrigger = Object.values(triggers).find(\n (obj) => obj.k === triggerType,\n );\n\n if (!existingTrigger) {\n // If the trigger type doesn't exist, create a new one with a new UUID\n const uuid = uuidv4();\n userStorage[account][chain][uuid] = {\n k: triggerType,\n e: false,\n };\n }\n });\n });\n\n return userStorage;\n}\n\n/**\n * Toggles the enabled status of a user storage trigger.\n *\n * @param userStorage - The user storage object.\n * @param address - The user's address.\n * @param chainId - The chain ID.\n * @param uuid - The unique identifier for the trigger.\n * @param enabled - The new enabled status.\n * @returns The updated user storage object.\n */\nexport function toggleUserStorageTriggerStatus(\n userStorage: UserStorage,\n address: string,\n chainId: string,\n uuid: string,\n enabled: boolean,\n): UserStorage {\n if (userStorage?.[address]?.[chainId]?.[uuid]) {\n userStorage[address][chainId][uuid].e = enabled;\n }\n\n return userStorage;\n}\n\n/**\n * Attempts to fetch a resource from the network, retrying the request up to a specified number of times\n * in case of failure, with a delay between attempts.\n *\n * @param url - The resource URL.\n * @param options - The options for the fetch request.\n * @param retries - Maximum number of retry attempts. Defaults to 3.\n * @param retryDelay - Delay between retry attempts in milliseconds. Defaults to 1000.\n * @returns A Promise resolving to the Response object.\n * @throws Will throw an error if the request fails after the specified number of retries.\n */\nasync function fetchWithRetry(\n url: string,\n options: RequestInit,\n retries = 3,\n retryDelay = 1000,\n): Promise<Response> {\n for (let attempt = 1; attempt <= retries; attempt++) {\n try {\n const response = await fetch(url, options);\n if (!response.ok) {\n throw new Error(`Fetch failed with status: ${response.status}`);\n }\n return response;\n } catch (error) {\n log.error(`Attempt ${attempt} failed for fetch:`, error);\n if (attempt < retries) {\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n } else {\n throw new Error(\n `Fetching failed after ${retries} retries. Last error: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n }\n }\n }\n\n throw new Error('Unexpected error in fetchWithRetry');\n}\n\n/**\n * Performs an API call with automatic retries on failure.\n *\n * @param bearerToken - The JSON Web Token for authorization.\n * @param endpoint - The URL of the API endpoint to call.\n * @param method - The HTTP method ('POST' or 'DELETE').\n * @param body - The body of the request. It should be an object that can be serialized to JSON.\n * @param retries - The number of retry attempts in case of failure (default is 3).\n * @param retryDelay - The delay between retries in milliseconds (default is 1000).\n * @returns A Promise that resolves to the response of the fetch request.\n */\nexport async function makeApiCall<Body>(\n bearerToken: string,\n endpoint: string,\n method: 'POST' | 'DELETE',\n body: Body,\n retries = 3,\n retryDelay = 1000,\n): Promise<Response> {\n const options: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify(body),\n };\n\n return fetchWithRetry(endpoint, options, retries, retryDelay);\n}\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-PNCS6GEX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=chunk-PROWNV4M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-QB5IFRLA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,29 @@
1
+ import {
2
+ processNotification,
3
+ safeProcessNotification
4
+ } from "./chunk-RQWUD2FB.mjs";
5
+ import {
6
+ processOnChainNotification
7
+ } from "./chunk-BONB66A2.mjs";
8
+ import {
9
+ isFeatureAnnouncementRead,
10
+ processFeatureAnnouncement
11
+ } from "./chunk-D42BBXBM.mjs";
12
+ import {
13
+ __export
14
+ } from "./chunk-26CCETCM.mjs";
15
+
16
+ // src/NotificationServicesController/processors/index.ts
17
+ var processors_exports = {};
18
+ __export(processors_exports, {
19
+ isFeatureAnnouncementRead: () => isFeatureAnnouncementRead,
20
+ processFeatureAnnouncement: () => processFeatureAnnouncement,
21
+ processNotification: () => processNotification,
22
+ processOnChainNotification: () => processOnChainNotification,
23
+ safeProcessNotification: () => safeProcessNotification
24
+ });
25
+
26
+ export {
27
+ processors_exports
28
+ };
29
+ //# sourceMappingURL=chunk-QTK2RMF7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/processors/index.ts"],"sourcesContent":["export * from './process-feature-announcement';\nexport * from './process-notifications';\nexport * from './process-onchain-notifications';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-RAUV5UV4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,48 @@
1
+ import {
2
+ processOnChainNotification
3
+ } from "./chunk-BONB66A2.mjs";
4
+ import {
5
+ isFeatureAnnouncementRead,
6
+ processFeatureAnnouncement
7
+ } from "./chunk-D42BBXBM.mjs";
8
+ import {
9
+ TRIGGER_TYPES
10
+ } from "./chunk-VC6J62JI.mjs";
11
+
12
+ // src/NotificationServicesController/processors/process-notifications.ts
13
+ var isOnChainNotification = (n) => Object.values(TRIGGER_TYPES).includes(n.type);
14
+ var isFeatureAnnouncement = (n) => n.type === "features_announcement" /* FEATURES_ANNOUNCEMENT */;
15
+ function processNotification(notification, readNotifications = []) {
16
+ const exhaustedAllCases = (_) => {
17
+ const type = notification?.type;
18
+ throw new Error(`No processor found for notification kind ${type}`);
19
+ };
20
+ if (isFeatureAnnouncement(notification)) {
21
+ const n = processFeatureAnnouncement(
22
+ notification
23
+ );
24
+ n.isRead = isFeatureAnnouncementRead(n, readNotifications);
25
+ return n;
26
+ }
27
+ if (isOnChainNotification(notification)) {
28
+ return processOnChainNotification(notification);
29
+ }
30
+ return exhaustedAllCases(notification);
31
+ }
32
+ function safeProcessNotification(notification, readNotifications = []) {
33
+ try {
34
+ const processedNotification = processNotification(
35
+ notification,
36
+ readNotifications
37
+ );
38
+ return processedNotification;
39
+ } catch {
40
+ return void 0;
41
+ }
42
+ }
43
+
44
+ export {
45
+ processNotification,
46
+ safeProcessNotification
47
+ };
48
+ //# sourceMappingURL=chunk-RQWUD2FB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/processors/process-notifications.ts"],"sourcesContent":["import { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n NotificationUnion,\n} from '../types/notification/notification';\nimport type { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\n\nconst isOnChainNotification = (\n n: NotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(n.type);\n\nconst isFeatureAnnouncement = (\n n: NotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: NotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isOnChainNotification(notification)) {\n return processOnChainNotification(notification as OnChainRawNotification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: NotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAM,wBAAwB,CAC5B,MACgC,OAAO,OAAO,aAAa,EAAE,SAAS,EAAE,IAAI;AAE9E,IAAM,wBAAwB,CAC5B,MAEA,EAAE;AAUG,SAAS,oBACd,cACA,oBAA8B,CAAC,GAChB;AACf,QAAM,oBAAoB,CAAC,MAAa;AACtC,UAAM,OAAe,cAAc;AACnC,UAAM,IAAI,MAAM,4CAA4C,IAAI,EAAE;AAAA,EACpE;AAEA,MAAI,sBAAsB,YAAY,GAAG;AACvC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACA,MAAE,SAAS,0BAA0B,GAAG,iBAAiB;AACzD,WAAO;AAAA,EACT;AAEA,MAAI,sBAAsB,YAAY,GAAG;AACvC,WAAO,2BAA2B,YAAsC;AAAA,EAC1E;AAEA,SAAO,kBAAkB,YAAqB;AAChD;AASO,SAAS,wBACd,cACA,oBAA8B,CAAC,GACJ;AAC3B,MAAI;AACF,UAAM,wBAAwB;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}