@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,14 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/NotificationServicesController/processors/process-onchain-notifications.ts
2
+ function processOnChainNotification(notification) {
3
+ return {
4
+ ...notification,
5
+ id: notification.id,
6
+ createdAt: new Date(notification.created_at).toISOString(),
7
+ isRead: !notification.unread
8
+ };
9
+ }
10
+
11
+
12
+
13
+ exports.processOnChainNotification = processOnChainNotification;
14
+ //# sourceMappingURL=chunk-LYEXYTOI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/processors/process-onchain-notifications.ts"],"names":[],"mappings":";AASO,SAAS,2BACd,cACe;AACf,SAAO;AAAA,IACL,GAAG;AAAA,IACH,IAAI,aAAa;AAAA,IACjB,WAAW,IAAI,KAAK,aAAa,UAAU,EAAE,YAAY;AAAA,IACzD,QAAQ,CAAC,aAAa;AAAA,EACxB;AACF","sourcesContent":["import type { INotification } from '../types/notification/notification';\nimport type { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\n\n/**\n * Processes On-Chain notifications to a normalized notification\n *\n * @param notification - On-Chain Notification\n * @returns Normalized Notification\n */\nexport function processOnChainNotification(\n notification: OnChainRawNotification,\n): INotification {\n return {\n ...notification,\n id: notification.id,\n createdAt: new Date(notification.created_at).toISOString(),\n isRead: !notification.unread,\n };\n}\n"]}
@@ -0,0 +1,93 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunkUPVIT75Fjs = require('./chunk-UPVIT75F.js');
4
+
5
+ // src/NotificationServicesPushController/services/push/push-web.ts
6
+ var _app = require('firebase/app');
7
+ var _messaging = require('firebase/messaging');
8
+ var _sw = require('firebase/messaging/sw');
9
+ var _loglevel = require('loglevel'); var _loglevel2 = _interopRequireDefault(_loglevel);
10
+ var sw = self;
11
+ var createFirebaseApp = async (env) => {
12
+ try {
13
+ return _app.getApp.call(void 0, );
14
+ } catch {
15
+ const firebaseConfig = {
16
+ apiKey: env.apiKey,
17
+ authDomain: env.authDomain,
18
+ storageBucket: env.storageBucket,
19
+ projectId: env.projectId,
20
+ messagingSenderId: env.messagingSenderId,
21
+ appId: env.appId,
22
+ measurementId: env.measurementId
23
+ };
24
+ return _app.initializeApp.call(void 0, firebaseConfig);
25
+ }
26
+ };
27
+ var getFirebaseMessaging = async (env) => {
28
+ const app = await createFirebaseApp(env);
29
+ return _sw.getMessaging.call(void 0, app);
30
+ };
31
+ async function createRegToken(env) {
32
+ try {
33
+ const messaging = await getFirebaseMessaging(env);
34
+ const token = await _messaging.getToken.call(void 0, messaging, {
35
+ serviceWorkerRegistration: sw.registration,
36
+ vapidKey: env.vapidKey
37
+ });
38
+ return token;
39
+ } catch {
40
+ return null;
41
+ }
42
+ }
43
+ async function deleteRegToken(env) {
44
+ try {
45
+ const messaging = await getFirebaseMessaging(env);
46
+ await _messaging.deleteToken.call(void 0, messaging);
47
+ return true;
48
+ } catch (error) {
49
+ return false;
50
+ }
51
+ }
52
+ async function listenToPushNotificationsReceived(env, handler) {
53
+ const messaging = await getFirebaseMessaging(env);
54
+ const unsubscribePushNotifications = _sw.onBackgroundMessage.call(void 0,
55
+ messaging,
56
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
57
+ async (payload) => {
58
+ try {
59
+ const notificationData = payload?.data?.data ? JSON.parse(payload?.data?.data) : void 0;
60
+ if (!notificationData) {
61
+ return;
62
+ }
63
+ const notification = _chunkUPVIT75Fjs.processors_exports.processNotification(notificationData);
64
+ await handler(notification);
65
+ } catch (error) {
66
+ _loglevel2.default.error("Unable to send push notification:", {
67
+ notification: payload?.data?.data,
68
+ error
69
+ });
70
+ throw new Error("Unable to send push notification");
71
+ }
72
+ }
73
+ );
74
+ const unsubscribe = () => unsubscribePushNotifications();
75
+ return unsubscribe;
76
+ }
77
+ function listenToPushNotificationsClicked(handler) {
78
+ const clickHandler = (event) => {
79
+ const data = event?.notification?.data;
80
+ handler(event, data);
81
+ };
82
+ sw.addEventListener("notificationclick", clickHandler);
83
+ const unsubscribe = () => sw.removeEventListener("notificationclick", clickHandler);
84
+ return unsubscribe;
85
+ }
86
+
87
+
88
+
89
+
90
+
91
+
92
+ exports.createRegToken = createRegToken; exports.deleteRegToken = deleteRegToken; exports.listenToPushNotificationsReceived = listenToPushNotificationsReceived; exports.listenToPushNotificationsClicked = listenToPushNotificationsClicked;
93
+ //# sourceMappingURL=chunk-NJBJIZLR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/services/push/push-web.ts"],"names":[],"mappings":";;;;;AAIA,SAAS,QAAQ,qBAAqB;AACtC,SAAS,UAAU,mBAAmB;AACtC,SAAS,cAAc,2BAA2B;AAElD,OAAO,SAAS;AAMhB,IAAM,KAAK;AAEX,IAAM,oBAAoB,OACxB,QACyB;AACzB,MAAI;AACF,WAAO,OAAO;AAAA,EAChB,QAAQ;AACN,UAAM,iBAAiB;AAAA,MACrB,QAAQ,IAAI;AAAA,MACZ,YAAY,IAAI;AAAA,MAChB,eAAe,IAAI;AAAA,MACnB,WAAW,IAAI;AAAA,MACf,mBAAmB,IAAI;AAAA,MACvB,OAAO,IAAI;AAAA,MACX,eAAe,IAAI;AAAA,IACrB;AACA,WAAO,cAAc,cAAc;AAAA,EACrC;AACF;AAEA,IAAM,uBAAuB,OAC3B,QACuB;AACvB,QAAM,MAAM,MAAM,kBAAkB,GAAG;AACvC,SAAO,aAAa,GAAG;AACzB;AAQA,eAAsB,eACpB,KACwB;AACxB,MAAI;AACF,UAAM,YAAY,MAAM,qBAAqB,GAAG;AAChD,UAAM,QAAQ,MAAM,SAAS,WAAW;AAAA,MACtC,2BAA2B,GAAG;AAAA,MAC9B,UAAU,IAAI;AAAA,IAChB,CAAC;AACD,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAQA,eAAsB,eACpB,KACkB;AAClB,MAAI;AACF,UAAM,YAAY,MAAM,qBAAqB,GAAG;AAChD,UAAM,YAAY,SAAS;AAC3B,WAAO;AAAA,EACT,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAQA,eAAsB,kCACpB,KACA,SACA;AACA,QAAM,YAAY,MAAM,qBAAqB,GAAG;AAChD,QAAM,+BAA+B;AAAA,IACnC;AAAA;AAAA,IAEA,OAAO,YAA4B;AACjC,UAAI;AACF,cAAM,mBAA4C,SAAS,MAAM,OAC7D,KAAK,MAAM,SAAS,MAAM,IAAI,IAC9B;AAEJ,YAAI,CAAC,kBAAkB;AACrB;AAAA,QACF;AAEA,cAAM,eAAe,mBAAW,oBAAoB,gBAAgB;AACpE,cAAM,QAAQ,YAAY;AAAA,MAC5B,SAAS,OAAO;AAEd,YAAI,MAAM,qCAAqC;AAAA,UAC7C,cAAc,SAAS,MAAM;AAAA,UAC7B;AAAA,QACF,CAAC;AACD,cAAM,IAAI,MAAM,kCAAkC;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,6BAA6B;AACvD,SAAO;AACT;AAQO,SAAS,iCACd,SACA;AACA,QAAM,eAAe,CAAC,UAA6B;AAEjD,UAAM,OAA4B,OAAO,cAAc;AACvD,YAAQ,OAAO,IAAI;AAAA,EACrB;AAEA,KAAG,iBAAiB,qBAAqB,YAAY;AACrD,QAAM,cAAc,MAClB,GAAG,oBAAoB,qBAAqB,YAAY;AAC1D,SAAO;AACT","sourcesContent":["// We are defining that this file uses a webworker global scope.\n// eslint-disable-next-line spaced-comment\n/// <reference lib=\"webworker\" />\nimport type { FirebaseApp } from 'firebase/app';\nimport { getApp, initializeApp } from 'firebase/app';\nimport { getToken, deleteToken } from 'firebase/messaging';\nimport { getMessaging, onBackgroundMessage } from 'firebase/messaging/sw';\nimport type { Messaging, MessagePayload } from 'firebase/messaging/sw';\nimport log from 'loglevel';\n\nimport type { Types } from '../../../NotificationServicesController';\nimport { Processors } from '../../../NotificationServicesController';\nimport type { PushNotificationEnv } from '../../types/firebase';\n\nconst sw = self as unknown as ServiceWorkerGlobalScope;\n\nconst createFirebaseApp = async (\n env: PushNotificationEnv,\n): Promise<FirebaseApp> => {\n try {\n return getApp();\n } catch {\n const firebaseConfig = {\n apiKey: env.apiKey,\n authDomain: env.authDomain,\n storageBucket: env.storageBucket,\n projectId: env.projectId,\n messagingSenderId: env.messagingSenderId,\n appId: env.appId,\n measurementId: env.measurementId,\n };\n return initializeApp(firebaseConfig);\n }\n};\n\nconst getFirebaseMessaging = async (\n env: PushNotificationEnv,\n): Promise<Messaging> => {\n const app = await createFirebaseApp(env);\n return getMessaging(app);\n};\n\n/**\n * Creates a registration token for Firebase Cloud Messaging.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with the registration token or null if an error occurs.\n */\nexport async function createRegToken(\n env: PushNotificationEnv,\n): Promise<string | null> {\n try {\n const messaging = await getFirebaseMessaging(env);\n const token = await getToken(messaging, {\n serviceWorkerRegistration: sw.registration,\n vapidKey: env.vapidKey,\n });\n return token;\n } catch {\n return null;\n }\n}\n\n/**\n * Deletes the Firebase Cloud Messaging registration token.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with true if the token was successfully deleted, false otherwise.\n */\nexport async function deleteRegToken(\n env: PushNotificationEnv,\n): Promise<boolean> {\n try {\n const messaging = await getFirebaseMessaging(env);\n await deleteToken(messaging);\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Service Worker Listener for when push notifications are received.\n * @param env - push notification environment\n * @param handler - handler to actually showing notification, MUST BE PROVEDED\n * @returns unsubscribe handler\n */\nexport async function listenToPushNotificationsReceived(\n env: PushNotificationEnv,\n handler: (notification: Types.INotification) => void | Promise<void>,\n) {\n const messaging = await getFirebaseMessaging(env);\n const unsubscribePushNotifications = onBackgroundMessage(\n messaging,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (payload: MessagePayload) => {\n try {\n const notificationData: Types.NotificationUnion = payload?.data?.data\n ? JSON.parse(payload?.data?.data)\n : undefined;\n\n if (!notificationData) {\n return;\n }\n\n const notification = Processors.processNotification(notificationData);\n await handler(notification);\n } catch (error) {\n // Do Nothing, cannot parse a bad notification\n log.error('Unable to send push notification:', {\n notification: payload?.data?.data,\n error,\n });\n throw new Error('Unable to send push notification');\n }\n },\n );\n\n const unsubscribe = () => unsubscribePushNotifications();\n return unsubscribe;\n}\n\n/**\n * Service Worker Listener for when a notification is clicked\n *\n * @param handler - listen to NotificationEvent from the service worker\n * @returns unsubscribe handler\n */\nexport function listenToPushNotificationsClicked(\n handler: (e: NotificationEvent, notification?: Types.INotification) => void,\n) {\n const clickHandler = (event: NotificationEvent) => {\n // Get Data\n const data: Types.INotification = event?.notification?.data;\n handler(event, data);\n };\n\n sw.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n sw.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n"]}
@@ -0,0 +1,149 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+
4
+ var _chunkNJBJIZLRjs = require('./chunk-NJBJIZLR.js');
5
+
6
+
7
+ var _chunkB25TJ7KSjs = require('./chunk-B25TJ7KS.js');
8
+
9
+ // src/NotificationServicesPushController/services/services.ts
10
+ var _loglevel = require('loglevel'); var _loglevel2 = _interopRequireDefault(_loglevel);
11
+ async function getPushNotificationLinks(bearerToken) {
12
+ try {
13
+ const response = await fetch(_chunkB25TJ7KSjs.REGISTRATION_TOKENS_ENDPOINT, {
14
+ headers: { Authorization: `Bearer ${bearerToken}` }
15
+ });
16
+ if (!response.ok) {
17
+ _loglevel2.default.error("Failed to fetch the push notification links");
18
+ throw new Error("Failed to fetch the push notification links");
19
+ }
20
+ return response.json();
21
+ } catch (error) {
22
+ _loglevel2.default.error("Failed to fetch the push notification links", error);
23
+ return null;
24
+ }
25
+ }
26
+ async function updateLinksAPI(bearerToken, triggers, regTokens) {
27
+ try {
28
+ const body = {
29
+ // eslint-disable-next-line @typescript-eslint/naming-convention
30
+ trigger_ids: triggers,
31
+ // eslint-disable-next-line @typescript-eslint/naming-convention
32
+ registration_tokens: regTokens
33
+ };
34
+ const response = await fetch(_chunkB25TJ7KSjs.REGISTRATION_TOKENS_ENDPOINT, {
35
+ method: "POST",
36
+ headers: {
37
+ Authorization: `Bearer ${bearerToken}`,
38
+ "Content-Type": "application/json"
39
+ },
40
+ body: JSON.stringify(body)
41
+ });
42
+ return response.status === 200;
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ async function activatePushNotifications(params) {
48
+ const { bearerToken, triggers, env, createRegToken, platform } = params;
49
+ const notificationLinks = await getPushNotificationLinks(bearerToken);
50
+ if (!notificationLinks) {
51
+ return null;
52
+ }
53
+ const regToken = await createRegToken(env).catch(() => null);
54
+ if (!regToken) {
55
+ return null;
56
+ }
57
+ const newRegTokens = new Set(notificationLinks.registration_tokens);
58
+ newRegTokens.add({ token: regToken, platform });
59
+ await updateLinksAPI(bearerToken, triggers, Array.from(newRegTokens));
60
+ return regToken;
61
+ }
62
+ async function deactivatePushNotifications(params) {
63
+ const { regToken, bearerToken, triggers, env, deleteRegToken } = params;
64
+ if (!regToken) {
65
+ return true;
66
+ }
67
+ const notificationLinks = await getPushNotificationLinks(bearerToken);
68
+ if (!notificationLinks) {
69
+ return false;
70
+ }
71
+ const filteredRegTokens = notificationLinks.registration_tokens.filter(
72
+ (r) => r.token !== regToken
73
+ );
74
+ const isTokenRemovedFromAPI = await updateLinksAPI(
75
+ bearerToken,
76
+ triggers,
77
+ filteredRegTokens
78
+ );
79
+ if (!isTokenRemovedFromAPI) {
80
+ return false;
81
+ }
82
+ const isTokenRemovedFromFCM = await deleteRegToken(env);
83
+ if (!isTokenRemovedFromFCM) {
84
+ return false;
85
+ }
86
+ return true;
87
+ }
88
+ async function updateTriggerPushNotifications(params) {
89
+ const {
90
+ bearerToken,
91
+ regToken,
92
+ triggers,
93
+ createRegToken,
94
+ platform,
95
+ deleteRegToken,
96
+ env
97
+ } = params;
98
+ const notificationLinks = await getPushNotificationLinks(bearerToken);
99
+ if (!notificationLinks) {
100
+ return { isTriggersLinkedToPushNotifications: false };
101
+ }
102
+ const hasRegToken = Boolean(
103
+ regToken && notificationLinks.registration_tokens.some((r) => r.token === regToken)
104
+ );
105
+ let newRegToken = null;
106
+ if (!hasRegToken) {
107
+ await deleteRegToken(env);
108
+ newRegToken = await createRegToken(env);
109
+ if (!newRegToken) {
110
+ throw new Error("Failed to create a new registration token");
111
+ }
112
+ notificationLinks.registration_tokens.push({
113
+ token: newRegToken,
114
+ platform
115
+ });
116
+ }
117
+ const isTriggersLinkedToPushNotifications = await updateLinksAPI(
118
+ bearerToken,
119
+ triggers,
120
+ notificationLinks.registration_tokens
121
+ );
122
+ return {
123
+ isTriggersLinkedToPushNotifications,
124
+ fcmToken: newRegToken ?? null
125
+ };
126
+ }
127
+ async function listenToPushNotifications(params) {
128
+ const { env, listenToPushReceived, listenToPushClicked } = params;
129
+ const unsubscribePushNotifications = await _chunkNJBJIZLRjs.listenToPushNotificationsReceived.call(void 0,
130
+ env,
131
+ listenToPushReceived
132
+ );
133
+ const unsubscribeNotificationClicks = _chunkNJBJIZLRjs.listenToPushNotificationsClicked.call(void 0, listenToPushClicked);
134
+ const unsubscribe = () => {
135
+ unsubscribePushNotifications();
136
+ unsubscribeNotificationClicks();
137
+ };
138
+ return unsubscribe;
139
+ }
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+ exports.getPushNotificationLinks = getPushNotificationLinks; exports.updateLinksAPI = updateLinksAPI; exports.activatePushNotifications = activatePushNotifications; exports.deactivatePushNotifications = deactivatePushNotifications; exports.updateTriggerPushNotifications = updateTriggerPushNotifications; exports.listenToPushNotifications = listenToPushNotifications;
149
+ //# sourceMappingURL=chunk-NMLYB3XT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"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","sourcesContent":["import log from 'loglevel';\n\nimport type { Types } from '../../NotificationServicesController';\nimport type { PushNotificationEnv } from '../types';\nimport * as endpoints from './endpoints';\nimport type { CreateRegToken, DeleteRegToken } from './push';\nimport {\n listenToPushNotificationsClicked,\n listenToPushNotificationsReceived,\n} from './push/push-web';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n trigger_ids: string[];\n // eslint-disable-next-line @typescript-eslint/naming-convention\n registration_tokens: RegToken[];\n};\n\n/**\n * Fetches push notification links from a remote endpoint using a BearerToken for authorization.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @returns A promise that resolves with the links result or null if an error occurs.\n */\nexport async function getPushNotificationLinks(\n bearerToken: string,\n): Promise<LinksResult | null> {\n try {\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n headers: { Authorization: `Bearer ${bearerToken}` },\n });\n if (!response.ok) {\n log.error('Failed to fetch the push notification links');\n throw new Error('Failed to fetch the push notification links');\n }\n return response.json() as Promise<LinksResult>;\n } catch (error) {\n log.error('Failed to fetch the push notification links', error);\n return null;\n }\n}\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n trigger_ids: triggers,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform } = params;\n\n const notificationLinks = await getPushNotificationLinks(bearerToken);\n\n if (!notificationLinks) {\n return null;\n }\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n const newRegTokens = new Set(notificationLinks.registration_tokens);\n newRegTokens.add({ token: regToken, platform });\n\n await updateLinksAPI(bearerToken, triggers, Array.from(newRegTokens));\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n bearerToken: string;\n triggers: string[];\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token and unlinking triggers.\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, bearerToken, triggers, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const notificationLinks = await getPushNotificationLinks(bearerToken);\n if (!notificationLinks) {\n return false;\n }\n\n const filteredRegTokens = notificationLinks.registration_tokens.filter(\n (r) => r.token !== regToken,\n );\n\n const isTokenRemovedFromAPI = await updateLinksAPI(\n bearerToken,\n triggers,\n filteredRegTokens,\n );\n if (!isTokenRemovedFromAPI) {\n return false;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n regToken: string;\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n isTriggersLinkedToPushNotifications: boolean;\n fcmToken?: string | null;\n}> {\n const {\n bearerToken,\n regToken,\n triggers,\n createRegToken,\n platform,\n deleteRegToken,\n env,\n } = params;\n\n const notificationLinks = await getPushNotificationLinks(bearerToken);\n if (!notificationLinks) {\n return { isTriggersLinkedToPushNotifications: false };\n }\n // Create new registration token if doesn't exist\n const hasRegToken = Boolean(\n regToken &&\n notificationLinks.registration_tokens.some((r) => r.token === regToken),\n );\n\n let newRegToken: string | null = null;\n if (!hasRegToken) {\n await deleteRegToken(env);\n newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n notificationLinks.registration_tokens.push({\n token: newRegToken,\n platform,\n });\n }\n\n const isTriggersLinkedToPushNotifications = await updateLinksAPI(\n bearerToken,\n triggers,\n notificationLinks.registration_tokens,\n );\n\n return {\n isTriggersLinkedToPushNotifications,\n fcmToken: newRegToken ?? null,\n };\n}\n\ntype ListenToPushNotificationsParams = {\n env: PushNotificationEnv;\n listenToPushReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n listenToPushClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n};\n\n/**\n * Listens to push notifications and invokes the provided callback function with the received notification data.\n *\n * @param params - listen params\n * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.\n */\nexport async function listenToPushNotifications(\n params: ListenToPushNotificationsParams,\n): Promise<() => void> {\n const { env, listenToPushReceived, listenToPushClicked } = params;\n\n /*\n Push notifications require 2 listeners that need tracking (when creating and for tearing down):\n 1. handling receiving a push notification (and the content we want to display)\n 2. handling when a user clicks on a push notification\n */\n const unsubscribePushNotifications = await listenToPushNotificationsReceived(\n env,\n listenToPushReceived,\n );\n const unsubscribeNotificationClicks =\n listenToPushNotificationsClicked(listenToPushClicked);\n\n const unsubscribe = () => {\n unsubscribePushNotifications();\n unsubscribeNotificationClicks();\n };\n\n return unsubscribe;\n}\n"]}
@@ -0,0 +1,55 @@
1
+ // src/NotificationServicesPushController/utils/get-notification-data.ts
2
+ import { BigNumber } from "bignumber.js";
3
+ var defaultFormatOptions = {
4
+ decimalPlaces: 4
5
+ };
6
+ function calcTokenAmount(value, decimals) {
7
+ const multiplier = Math.pow(10, Number(decimals || 0));
8
+ return new BigNumber(String(value)).div(multiplier);
9
+ }
10
+ var getLeadingZeroCount = (num) => {
11
+ const numToString = new BigNumber(num, 10).toString(10);
12
+ const fractionalPart = numToString.split(".")[1] ?? "";
13
+ return fractionalPart.match(/^0*/u)?.[0]?.length || 0;
14
+ };
15
+ var formatAmount = (numericAmount, opts) => {
16
+ const options = { ...defaultFormatOptions, ...opts };
17
+ const leadingZeros = getLeadingZeroCount(numericAmount);
18
+ const isDecimal = numericAmount.toString().includes(".") || leadingZeros > 0;
19
+ const isLargeNumber = numericAmount > 999;
20
+ const handleShouldEllipse = (decimalPlaces) => Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;
21
+ if (isLargeNumber) {
22
+ return Intl.NumberFormat("en-US", {
23
+ notation: "compact",
24
+ compactDisplay: "short",
25
+ maximumFractionDigits: 2
26
+ }).format(numericAmount);
27
+ }
28
+ if (isDecimal) {
29
+ const ellipse = handleShouldEllipse(options.decimalPlaces);
30
+ const formattedValue = Intl.NumberFormat("en-US", {
31
+ minimumFractionDigits: ellipse ? options.decimalPlaces : void 0,
32
+ maximumFractionDigits: options.decimalPlaces
33
+ }).format(numericAmount);
34
+ return ellipse ? `${formattedValue}...` : formattedValue;
35
+ }
36
+ return numericAmount.toString();
37
+ };
38
+ var getAmount = (amount, decimals, options) => {
39
+ if (!amount || !decimals) {
40
+ return "";
41
+ }
42
+ const numericAmount = calcTokenAmount(
43
+ amount,
44
+ parseFloat(decimals)
45
+ ).toNumber();
46
+ return formatAmount(numericAmount, options);
47
+ };
48
+
49
+ export {
50
+ calcTokenAmount,
51
+ getLeadingZeroCount,
52
+ formatAmount,
53
+ getAmount
54
+ };
55
+ //# sourceMappingURL=chunk-ODI2BTKS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/utils/get-notification-data.ts"],"sourcesContent":["import { BigNumber } from 'bignumber.js';\n\ntype FormatOptions = {\n decimalPlaces?: number;\n shouldEllipse?: boolean;\n};\nconst defaultFormatOptions = {\n decimalPlaces: 4,\n};\n\n/**\n * Calculates the token amount based on the given value and decimals.\n *\n * @param value - The value to calculate the token amount from.\n * @param decimals - The number of decimals to use for the calculation.\n * @returns The calculated token amount.\n */\nexport function calcTokenAmount(value: string, decimals: number) {\n const multiplier = Math.pow(10, Number(decimals || 0));\n return new BigNumber(String(value)).div(multiplier);\n}\n\n/**\n * Calculates the number of leading zeros in the fractional part of a number.\n *\n * This function converts a number or a string representation of a number into\n * its decimal form and then counts the number of leading zeros present in the\n * fractional part of the number. This is useful for determining the precision\n * of very small numbers.\n *\n * @param num - The number to analyze, which can be in the form\n * of a number or a string.\n * @returns The count of leading zeros in the fractional part of the number.\n */\nexport const getLeadingZeroCount = (num: number | string) => {\n const numToString = new BigNumber(num, 10).toString(10);\n const fractionalPart = numToString.split('.')[1] ?? '';\n return fractionalPart.match(/^0*/u)?.[0]?.length || 0;\n};\n\n/**\n * This formats a number using Intl\n * It abbreviates large numbers (using K, M, B, T)\n * And abbreviates small numbers in 2 ways:\n * - Will format to the given number of decimal places\n * - Will format up to 4 decimal places\n * - Will ellipse the number if longer than given decimal places\n *\n * @param numericAmount - The number to format\n * @param opts - The options to use when formatting\n * @returns The formatted number\n */\nexport const formatAmount = (numericAmount: number, opts?: FormatOptions) => {\n // create options with defaults\n const options = { ...defaultFormatOptions, ...opts };\n\n const leadingZeros = getLeadingZeroCount(numericAmount);\n const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;\n const isLargeNumber = numericAmount > 999;\n\n const handleShouldEllipse = (decimalPlaces: number) =>\n Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;\n\n if (isLargeNumber) {\n return Intl.NumberFormat('en-US', {\n notation: 'compact',\n compactDisplay: 'short',\n maximumFractionDigits: 2,\n }).format(numericAmount);\n }\n\n if (isDecimal) {\n const ellipse = handleShouldEllipse(options.decimalPlaces);\n const formattedValue = Intl.NumberFormat('en-US', {\n minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,\n maximumFractionDigits: options.decimalPlaces,\n }).format(numericAmount);\n\n return ellipse ? `${formattedValue}...` : formattedValue;\n }\n\n // Default to showing the raw amount\n return numericAmount.toString();\n};\n\nexport const getAmount = (\n amount: string,\n decimals: string,\n options?: FormatOptions,\n) => {\n if (!amount || !decimals) {\n return '';\n }\n\n const numericAmount = calcTokenAmount(\n amount,\n parseFloat(decimals),\n ).toNumber();\n\n return formatAmount(numericAmount, options);\n};\n"],"mappings":";AAAA,SAAS,iBAAiB;AAM1B,IAAM,uBAAuB;AAAA,EAC3B,eAAe;AACjB;AASO,SAAS,gBAAgB,OAAe,UAAkB;AAC/D,QAAM,aAAa,KAAK,IAAI,IAAI,OAAO,YAAY,CAAC,CAAC;AACrD,SAAO,IAAI,UAAU,OAAO,KAAK,CAAC,EAAE,IAAI,UAAU;AACpD;AAcO,IAAM,sBAAsB,CAAC,QAAyB;AAC3D,QAAM,cAAc,IAAI,UAAU,KAAK,EAAE,EAAE,SAAS,EAAE;AACtD,QAAM,iBAAiB,YAAY,MAAM,GAAG,EAAE,CAAC,KAAK;AACpD,SAAO,eAAe,MAAM,MAAM,IAAI,CAAC,GAAG,UAAU;AACtD;AAcO,IAAM,eAAe,CAAC,eAAuB,SAAyB;AAE3E,QAAM,UAAU,EAAE,GAAG,sBAAsB,GAAG,KAAK;AAEnD,QAAM,eAAe,oBAAoB,aAAa;AACtD,QAAM,YAAY,cAAc,SAAS,EAAE,SAAS,GAAG,KAAK,eAAe;AAC3E,QAAM,gBAAgB,gBAAgB;AAEtC,QAAM,sBAAsB,CAAC,kBAC3B,QAAQ,SAAS,aAAa,KAAK,gBAAgB;AAErD,MAAI,eAAe;AACjB,WAAO,KAAK,aAAa,SAAS;AAAA,MAChC,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB,uBAAuB;AAAA,IACzB,CAAC,EAAE,OAAO,aAAa;AAAA,EACzB;AAEA,MAAI,WAAW;AACb,UAAM,UAAU,oBAAoB,QAAQ,aAAa;AACzD,UAAM,iBAAiB,KAAK,aAAa,SAAS;AAAA,MAChD,uBAAuB,UAAU,QAAQ,gBAAgB;AAAA,MACzD,uBAAuB,QAAQ;AAAA,IACjC,CAAC,EAAE,OAAO,aAAa;AAEvB,WAAO,UAAU,GAAG,cAAc,QAAQ;AAAA,EAC5C;AAGA,SAAO,cAAc,SAAS;AAChC;AAEO,IAAM,YAAY,CACvB,QACA,UACA,YACG;AACH,MAAI,CAAC,UAAU,CAAC,UAAU;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA,WAAW,QAAQ;AAAA,EACrB,EAAE,SAAS;AAEX,SAAO,aAAa,eAAe,OAAO;AAC5C;","names":[]}
@@ -0,0 +1,214 @@
1
+ import {
2
+ activatePushNotifications,
3
+ deactivatePushNotifications,
4
+ listenToPushNotifications,
5
+ updateTriggerPushNotifications
6
+ } from "./chunk-TT56I53C.mjs";
7
+ import {
8
+ createRegToken,
9
+ deleteRegToken
10
+ } from "./chunk-52NKJDI2.mjs";
11
+ import {
12
+ __privateAdd,
13
+ __privateGet,
14
+ __privateMethod,
15
+ __privateSet
16
+ } from "./chunk-26CCETCM.mjs";
17
+
18
+ // src/NotificationServicesPushController/NotificationServicesPushController.ts
19
+ import { BaseController } from "@metamask/base-controller";
20
+ import log from "loglevel";
21
+ var controllerName = "NotificationServicesPushController";
22
+ var metadata = {
23
+ fcmToken: {
24
+ persist: true,
25
+ anonymous: true
26
+ }
27
+ };
28
+ var _pushListenerUnsubscribe, _env, _config, _registerMessageHandlers, registerMessageHandlers_fn, _getAndAssertBearerToken, getAndAssertBearerToken_fn;
29
+ var NotificationServicesPushController = class extends BaseController {
30
+ constructor({
31
+ messenger,
32
+ state,
33
+ env,
34
+ config
35
+ }) {
36
+ super({
37
+ messenger,
38
+ metadata,
39
+ name: controllerName,
40
+ state: {
41
+ fcmToken: state?.fcmToken || ""
42
+ }
43
+ });
44
+ __privateAdd(this, _registerMessageHandlers);
45
+ __privateAdd(this, _getAndAssertBearerToken);
46
+ __privateAdd(this, _pushListenerUnsubscribe, void 0);
47
+ __privateAdd(this, _env, void 0);
48
+ __privateAdd(this, _config, void 0);
49
+ __privateSet(this, _env, env);
50
+ __privateSet(this, _config, config);
51
+ __privateMethod(this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
52
+ }
53
+ /**
54
+ * Enables push notifications for the application.
55
+ *
56
+ * This method sets up the necessary infrastructure for handling push notifications by:
57
+ * 1. Registering the service worker to listen for messages.
58
+ * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.
59
+ * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.
60
+ *
61
+ * @param UUIDs - An array of UUIDs to enable push notifications for.
62
+ */
63
+ async enablePushNotifications(UUIDs) {
64
+ if (!__privateGet(this, _config).isPushEnabled) {
65
+ return;
66
+ }
67
+ const bearerToken = await __privateMethod(this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
68
+ try {
69
+ const regToken = await activatePushNotifications({
70
+ bearerToken,
71
+ triggers: UUIDs,
72
+ env: __privateGet(this, _env),
73
+ createRegToken,
74
+ platform: __privateGet(this, _config).platform
75
+ });
76
+ if (!regToken) {
77
+ return;
78
+ }
79
+ __privateSet(this, _pushListenerUnsubscribe, await listenToPushNotifications({
80
+ env: __privateGet(this, _env),
81
+ listenToPushReceived: async (n) => {
82
+ this.messagingSystem.publish(
83
+ "NotificationServicesPushController:onNewNotifications",
84
+ n
85
+ );
86
+ await __privateGet(this, _config).onPushNotificationReceived(n);
87
+ },
88
+ listenToPushClicked: (e, n) => {
89
+ if (n) {
90
+ this.messagingSystem.publish(
91
+ "NotificationServicesPushController:pushNotificationClicked",
92
+ n
93
+ );
94
+ }
95
+ __privateGet(this, _config).onPushNotificationClicked(e);
96
+ }
97
+ }));
98
+ this.update((state) => {
99
+ state.fcmToken = regToken;
100
+ });
101
+ } catch (error) {
102
+ log.error("Failed to enable push notifications:", error);
103
+ throw new Error("Failed to enable push notifications");
104
+ }
105
+ }
106
+ /**
107
+ * Disables push notifications for the application.
108
+ * This method handles the process of disabling push notifications by:
109
+ * 1. Unregistering the service worker to stop listening for messages.
110
+ * 2. Sending a request to the server to unregister the device using the FCM token.
111
+ * 3. Removing the FCM token from the state to complete the process.
112
+ *
113
+ * @param UUIDs - An array of UUIDs for which push notifications should be disabled.
114
+ */
115
+ async disablePushNotifications(UUIDs) {
116
+ var _a;
117
+ if (!__privateGet(this, _config).isPushEnabled) {
118
+ return;
119
+ }
120
+ const bearerToken = await __privateMethod(this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
121
+ let isPushNotificationsDisabled;
122
+ try {
123
+ isPushNotificationsDisabled = await deactivatePushNotifications({
124
+ bearerToken,
125
+ triggers: UUIDs,
126
+ env: __privateGet(this, _env),
127
+ deleteRegToken,
128
+ regToken: this.state.fcmToken
129
+ });
130
+ } catch (error) {
131
+ const errorMessage = `Failed to disable push notifications: ${error}`;
132
+ log.error(errorMessage);
133
+ throw new Error(errorMessage);
134
+ }
135
+ if (!isPushNotificationsDisabled) {
136
+ return;
137
+ }
138
+ (_a = __privateGet(this, _pushListenerUnsubscribe)) == null ? void 0 : _a.call(this);
139
+ if (isPushNotificationsDisabled) {
140
+ this.update((state) => {
141
+ state.fcmToken = "";
142
+ });
143
+ }
144
+ }
145
+ /**
146
+ * Updates the triggers for push notifications.
147
+ * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.
148
+ * It uses the current FCM token and a BearerToken for authentication.
149
+ *
150
+ * @param UUIDs - An array of UUIDs that should trigger push notifications.
151
+ */
152
+ async updateTriggerPushNotifications(UUIDs) {
153
+ if (!__privateGet(this, _config).isPushEnabled) {
154
+ return;
155
+ }
156
+ const bearerToken = await __privateMethod(this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
157
+ try {
158
+ const { fcmToken } = await updateTriggerPushNotifications({
159
+ bearerToken,
160
+ triggers: UUIDs,
161
+ env: __privateGet(this, _env),
162
+ createRegToken,
163
+ deleteRegToken,
164
+ platform: __privateGet(this, _config).platform,
165
+ regToken: this.state.fcmToken
166
+ });
167
+ if (fcmToken) {
168
+ this.update((state) => {
169
+ state.fcmToken = fcmToken;
170
+ });
171
+ }
172
+ } catch (error) {
173
+ const errorMessage = `Failed to update triggers for push notifications: ${error}`;
174
+ log.error(errorMessage);
175
+ throw new Error(errorMessage);
176
+ }
177
+ }
178
+ };
179
+ _pushListenerUnsubscribe = new WeakMap();
180
+ _env = new WeakMap();
181
+ _config = new WeakMap();
182
+ _registerMessageHandlers = new WeakSet();
183
+ registerMessageHandlers_fn = function() {
184
+ this.messagingSystem.registerActionHandler(
185
+ "NotificationServicesPushController:enablePushNotifications",
186
+ this.enablePushNotifications.bind(this)
187
+ );
188
+ this.messagingSystem.registerActionHandler(
189
+ "NotificationServicesPushController:disablePushNotifications",
190
+ this.disablePushNotifications.bind(this)
191
+ );
192
+ this.messagingSystem.registerActionHandler(
193
+ "NotificationServicesPushController:updateTriggerPushNotifications",
194
+ this.updateTriggerPushNotifications.bind(this)
195
+ );
196
+ };
197
+ _getAndAssertBearerToken = new WeakSet();
198
+ getAndAssertBearerToken_fn = async function() {
199
+ const bearerToken = await this.messagingSystem.call(
200
+ "AuthenticationController:getBearerToken"
201
+ );
202
+ if (!bearerToken) {
203
+ log.error(
204
+ "Failed to enable push notifications: BearerToken token is missing."
205
+ );
206
+ throw new Error("BearerToken token is missing");
207
+ }
208
+ return bearerToken;
209
+ };
210
+
211
+ export {
212
+ NotificationServicesPushController
213
+ };
214
+ //# sourceMappingURL=chunk-OUPWMPLU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"sourcesContent":["import type {\n RestrictedControllerMessenger,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport type { Types } from '../NotificationServicesController';\nimport { createRegToken, deleteRegToken } from './services/push/push-web';\nimport {\n activatePushNotifications,\n deactivatePushNotifications,\n listenToPushNotifications,\n updateTriggerPushNotifications,\n} from './services/services';\nimport type { PushNotificationEnv } from './types';\n\nconst controllerName = 'NotificationServicesPushController';\n\nexport type NotificationServicesPushControllerState = {\n fcmToken: string;\n};\n\nexport type NotificationServicesPushControllerEnablePushNotificationsAction = {\n type: `${typeof controllerName}:enablePushNotifications`;\n handler: NotificationServicesPushController['enablePushNotifications'];\n};\n\nexport type NotificationServicesPushControllerDisablePushNotificationsAction = {\n type: `${typeof controllerName}:disablePushNotifications`;\n handler: NotificationServicesPushController['disablePushNotifications'];\n};\nexport type NotificationServicesPushControllerUpdateTriggerPushNotificationsAction =\n {\n type: `${typeof controllerName}:updateTriggerPushNotifications`;\n handler: NotificationServicesPushController['updateTriggerPushNotifications'];\n };\n\nexport type Actions =\n | NotificationServicesPushControllerEnablePushNotificationsAction\n | NotificationServicesPushControllerDisablePushNotificationsAction\n | NotificationServicesPushControllerUpdateTriggerPushNotificationsAction\n | ControllerGetStateAction<'state', NotificationServicesPushControllerState>;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type NotificationServicesPushControllerOnNewNotificationEvent = {\n type: `${typeof controllerName}:onNewNotifications`;\n payload: [Types.INotification];\n};\n\nexport type NotificationServicesPushControllerPushNotificationClicked = {\n type: `${typeof controllerName}:pushNotificationClicked`;\n payload: [Types.INotification];\n};\n\nexport type AllowedEvents =\n | NotificationServicesPushControllerOnNewNotificationEvent\n | NotificationServicesPushControllerPushNotificationClicked;\n\nexport type NotificationServicesPushControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\nconst metadata = {\n fcmToken: {\n persist: true,\n anonymous: true,\n },\n};\n\ntype ControllerConfig = {\n /**\n * Config to turn on/off push notifications.\n * This is currently linked to MV3 builds on extension.\n */\n isPushEnabled: boolean;\n\n /**\n * Must handle when a push notification is received.\n * You must call `registration.showNotification` or equivalent to show the notification on web/mobile\n */\n onPushNotificationReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n\n /**\n * Must handle when a push notification is clicked.\n * You must call `event.notification.close();` or equivalent for closing and opening notification in a new window.\n */\n onPushNotificationClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n\n /**\n * determine the config used for push notification services\n */\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Manages push notifications for the application, including enabling, disabling, and updating triggers for push notifications.\n * This controller integrates with Firebase Cloud Messaging (FCM) to handle the registration and management of push notifications.\n * It is responsible for registering and unregistering the service worker that listens for push notifications,\n * managing the FCM token, and communicating with the server to register or unregister the device for push notifications.\n * Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.\n *\n * @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}\n */\nexport class NotificationServicesPushController extends BaseController<\n typeof controllerName,\n NotificationServicesPushControllerState,\n NotificationServicesPushControllerMessenger\n> {\n #pushListenerUnsubscribe: (() => void) | undefined = undefined;\n\n #env: PushNotificationEnv;\n\n #config: ControllerConfig;\n\n constructor({\n messenger,\n state,\n env,\n config,\n }: {\n messenger: NotificationServicesPushControllerMessenger;\n state: NotificationServicesPushControllerState;\n env: PushNotificationEnv;\n config: ControllerConfig;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: {\n fcmToken: state?.fcmToken || '',\n },\n });\n\n this.#env = env;\n this.#config = config;\n\n this.#registerMessageHandlers();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:enablePushNotifications',\n this.enablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:disablePushNotifications',\n this.disablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n this.updateTriggerPushNotifications.bind(this),\n );\n }\n\n async #getAndAssertBearerToken() {\n const bearerToken = await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n if (!bearerToken) {\n log.error(\n 'Failed to enable push notifications: BearerToken token is missing.',\n );\n throw new Error('BearerToken token is missing');\n }\n\n return bearerToken;\n }\n\n /**\n * Enables push notifications for the application.\n *\n * This method sets up the necessary infrastructure for handling push notifications by:\n * 1. Registering the service worker to listen for messages.\n * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.\n * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.\n *\n * @param UUIDs - An array of UUIDs to enable push notifications for.\n */\n async enablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n // Activate Push Notifications\n const regToken = await activatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n platform: this.#config.platform,\n });\n\n if (!regToken) {\n return;\n }\n\n this.#pushListenerUnsubscribe = await listenToPushNotifications({\n env: this.#env,\n listenToPushReceived: async (n) => {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:onNewNotifications',\n n,\n );\n await this.#config.onPushNotificationReceived(n);\n },\n listenToPushClicked: (e, n) => {\n if (n) {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n n,\n );\n }\n\n this.#config.onPushNotificationClicked(e);\n },\n });\n\n // Update state\n this.update((state) => {\n state.fcmToken = regToken;\n });\n } catch (error) {\n log.error('Failed to enable push notifications:', error);\n throw new Error('Failed to enable push notifications');\n }\n }\n\n /**\n * Disables push notifications for the application.\n * This method handles the process of disabling push notifications by:\n * 1. Unregistering the service worker to stop listening for messages.\n * 2. Sending a request to the server to unregister the device using the FCM token.\n * 3. Removing the FCM token from the state to complete the process.\n *\n * @param UUIDs - An array of UUIDs for which push notifications should be disabled.\n */\n async disablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n let isPushNotificationsDisabled: boolean;\n\n try {\n // Send a request to the server to unregister the token/device\n isPushNotificationsDisabled = await deactivatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n deleteRegToken,\n regToken: this.state.fcmToken,\n });\n } catch (error) {\n const errorMessage = `Failed to disable push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Remove the FCM token from the state\n if (!isPushNotificationsDisabled) {\n return;\n }\n\n // Unsubscribe from push notifications\n this.#pushListenerUnsubscribe?.();\n\n // Update State\n if (isPushNotificationsDisabled) {\n this.update((state) => {\n state.fcmToken = '';\n });\n }\n }\n\n /**\n * Updates the triggers for push notifications.\n * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.\n * It uses the current FCM token and a BearerToken for authentication.\n *\n * @param UUIDs - An array of UUIDs that should trigger push notifications.\n */\n async updateTriggerPushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n const { fcmToken } = await updateTriggerPushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n deleteRegToken,\n platform: this.#config.platform,\n regToken: this.state.fcmToken,\n });\n\n // update the state with the new FCM token\n if (fcmToken) {\n this.update((state) => {\n state.fcmToken = fcmToken;\n });\n }\n } catch (error) {\n const errorMessage = `Failed to update triggers for push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIA,SAAS,sBAAsB;AAE/B,OAAO,SAAS;AAYhB,IAAM,iBAAiB;AAqDvB,IAAM,WAAW;AAAA,EACf,UAAU;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACF;AA5EA;AAqHO,IAAM,qCAAN,cAAiD,eAItD;AAAA,EAOA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKG;AACD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA,QACL,UAAU,OAAO,YAAY;AAAA,MAC/B;AAAA,IACF,CAAC;AAQH;AAeA,uBAAM;AA/CN,iDAAqD;AAErD;AAEA;AAsBE,uBAAK,MAAO;AACZ,uBAAK,SAAU;AAEf,0BAAK,sDAAL;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyCA,MAAM,wBAAwB,OAAiB;AAC7C,QAAI,CAAC,mBAAK,SAAQ,eAAe;AAC/B;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,sBAAK,sDAAL;AAE1B,QAAI;AAEF,YAAM,WAAW,MAAM,0BAA0B;AAAA,QAC/C;AAAA,QACA,UAAU;AAAA,QACV,KAAK,mBAAK;AAAA,QACV;AAAA,QACA,UAAU,mBAAK,SAAQ;AAAA,MACzB,CAAC;AAED,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AAEA,yBAAK,0BAA2B,MAAM,0BAA0B;AAAA,QAC9D,KAAK,mBAAK;AAAA,QACV,sBAAsB,OAAO,MAAM;AACjC,eAAK,gBAAgB;AAAA,YACnB;AAAA,YACA;AAAA,UACF;AACA,gBAAM,mBAAK,SAAQ,2BAA2B,CAAC;AAAA,QACjD;AAAA,QACA,qBAAqB,CAAC,GAAG,MAAM;AAC7B,cAAI,GAAG;AACL,iBAAK,gBAAgB;AAAA,cACnB;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAEA,6BAAK,SAAQ,0BAA0B,CAAC;AAAA,QAC1C;AAAA,MACF,CAAC;AAGD,WAAK,OAAO,CAAC,UAAU;AACrB,cAAM,WAAW;AAAA,MACnB,CAAC;AAAA,IACH,SAAS,OAAO;AACd,UAAI,MAAM,wCAAwC,KAAK;AACvD,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,yBAAyB,OAAiB;AA9PlD;AA+PI,QAAI,CAAC,mBAAK,SAAQ,eAAe;AAC/B;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,sBAAK,sDAAL;AAC1B,QAAI;AAEJ,QAAI;AAEF,oCAA8B,MAAM,4BAA4B;AAAA,QAC9D;AAAA,QACA,UAAU;AAAA,QACV,KAAK,mBAAK;AAAA,QACV;AAAA,QACA,UAAU,KAAK,MAAM;AAAA,MACvB,CAAC;AAAA,IACH,SAAS,OAAO;AACd,YAAM,eAAe,yCACnB,KACF;AACA,UAAI,MAAM,YAAY;AACtB,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAGA,QAAI,CAAC,6BAA6B;AAChC;AAAA,IACF;AAGA,6BAAK,8BAAL;AAGA,QAAI,6BAA6B;AAC/B,WAAK,OAAO,CAAC,UAAU;AACrB,cAAM,WAAW;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,+BAA+B,OAAiB;AACpD,QAAI,CAAC,mBAAK,SAAQ,eAAe;AAC/B;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,sBAAK,sDAAL;AAE1B,QAAI;AACF,YAAM,EAAE,SAAS,IAAI,MAAM,+BAA+B;AAAA,QACxD;AAAA,QACA,UAAU;AAAA,QACV,KAAK,mBAAK;AAAA,QACV;AAAA,QACA;AAAA,QACA,UAAU,mBAAK,SAAQ;AAAA,QACvB,UAAU,KAAK,MAAM;AAAA,MACvB,CAAC;AAGD,UAAI,UAAU;AACZ,aAAK,OAAO,CAAC,UAAU;AACrB,gBAAM,WAAW;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,qDACnB,KACF;AACA,UAAI,MAAM,YAAY;AACtB,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAAA,EACF;AACF;AApNE;AAEA;AAEA;AA4BA;AAAA,6BAAwB,WAAS;AAC/B,OAAK,gBAAgB;AAAA,IACnB;AAAA,IACA,KAAK,wBAAwB,KAAK,IAAI;AAAA,EACxC;AACA,OAAK,gBAAgB;AAAA,IACnB;AAAA,IACA,KAAK,yBAAyB,KAAK,IAAI;AAAA,EACzC;AACA,OAAK,gBAAgB;AAAA,IACnB;AAAA,IACA,KAAK,+BAA+B,KAAK,IAAI;AAAA,EAC/C;AACF;AAEM;AAAA,6BAAwB,iBAAG;AAC/B,QAAM,cAAc,MAAM,KAAK,gBAAgB;AAAA,IAC7C;AAAA,EACF;AACA,MAAI,CAAC,aAAa;AAChB,QAAI;AAAA,MACF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}