@metamask-previews/notification-services-controller 0.5.0-preview-367cb1da → 0.5.0-preview-cf09c0a

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 (714) hide show
  1. package/dist/NotificationServicesController/NotificationServicesController.cjs +803 -0
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -0
  3. package/dist/{types/NotificationServicesController/NotificationServicesController.d.ts → NotificationServicesController/NotificationServicesController.d.cts} +7 -7
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -0
  5. package/dist/NotificationServicesController/NotificationServicesController.d.mts +238 -0
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -0
  7. package/dist/NotificationServicesController/NotificationServicesController.mjs +779 -17
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  9. package/dist/NotificationServicesController/__fixtures__/index.cjs +22 -0
  10. package/dist/NotificationServicesController/__fixtures__/index.cjs.map +1 -0
  11. package/dist/NotificationServicesController/__fixtures__/index.d.cts +6 -0
  12. package/dist/NotificationServicesController/__fixtures__/index.d.cts.map +1 -0
  13. package/dist/NotificationServicesController/__fixtures__/index.d.mts +6 -0
  14. package/dist/NotificationServicesController/__fixtures__/index.d.mts.map +1 -0
  15. package/dist/NotificationServicesController/__fixtures__/index.mjs +6 -0
  16. package/dist/NotificationServicesController/__fixtures__/index.mjs.map +1 -0
  17. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.cjs +210 -0
  18. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.cjs.map +1 -0
  19. package/dist/{types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts → NotificationServicesController/__fixtures__/mock-feature-announcements.d.cts} +3 -3
  20. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.cts.map +1 -0
  21. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.mts +15 -0
  22. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.mts.map +1 -0
  23. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.mjs +205 -0
  24. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.mjs.map +1 -0
  25. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.cjs +22 -0
  26. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.cjs.map +1 -0
  27. package/dist/{types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts → NotificationServicesController/__fixtures__/mock-notification-trigger.d.cts} +2 -2
  28. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.cts.map +1 -0
  29. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.mts +9 -0
  30. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.mts.map +1 -0
  31. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.mjs +18 -0
  32. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.mjs.map +1 -0
  33. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.cjs +82 -0
  34. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.cjs.map +1 -0
  35. package/dist/{types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts → NotificationServicesController/__fixtures__/mock-notification-user-storage.d.cts} +3 -3
  36. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.cts.map +1 -0
  37. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.mts +35 -0
  38. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.mts.map +1 -0
  39. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.mjs +76 -0
  40. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.mjs.map +1 -0
  41. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.cjs +624 -0
  42. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.cjs.map +1 -0
  43. package/dist/{types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts → NotificationServicesController/__fixtures__/mock-raw-notifications.d.cts} +2 -2
  44. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.cts.map +1 -0
  45. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.mts +82 -0
  46. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.mts.map +1 -0
  47. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.mjs +605 -0
  48. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.mjs.map +1 -0
  49. package/dist/NotificationServicesController/__fixtures__/mockResponses.cjs +50 -0
  50. package/dist/NotificationServicesController/__fixtures__/mockResponses.cjs.map +1 -0
  51. package/dist/{types/NotificationServicesController/__fixtures__/mockResponses.d.ts → NotificationServicesController/__fixtures__/mockResponses.d.cts} +5 -5
  52. package/dist/NotificationServicesController/__fixtures__/mockResponses.d.cts.map +1 -0
  53. package/dist/NotificationServicesController/__fixtures__/mockResponses.d.mts +28 -0
  54. package/dist/NotificationServicesController/__fixtures__/mockResponses.d.mts.map +1 -0
  55. package/dist/NotificationServicesController/__fixtures__/mockResponses.mjs +42 -0
  56. package/dist/NotificationServicesController/__fixtures__/mockResponses.mjs.map +1 -0
  57. package/dist/NotificationServicesController/__fixtures__/mockServices.cjs +56 -0
  58. package/dist/NotificationServicesController/__fixtures__/mockServices.cjs.map +1 -0
  59. package/dist/{types/NotificationServicesController/__fixtures__/mockServices.d.ts → NotificationServicesController/__fixtures__/mockServices.d.cts} +2 -2
  60. package/dist/NotificationServicesController/__fixtures__/mockServices.d.cts.map +1 -0
  61. package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts +12 -0
  62. package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts.map +1 -0
  63. package/dist/NotificationServicesController/__fixtures__/mockServices.mjs +52 -0
  64. package/dist/NotificationServicesController/__fixtures__/mockServices.mjs.map +1 -0
  65. package/dist/NotificationServicesController/__fixtures__/test-utils.cjs +31 -0
  66. package/dist/NotificationServicesController/__fixtures__/test-utils.cjs.map +1 -0
  67. package/dist/{types/NotificationServicesController/__fixtures__/test-utils.d.ts → NotificationServicesController/__fixtures__/test-utils.d.cts} +1 -1
  68. package/dist/NotificationServicesController/__fixtures__/test-utils.d.cts.map +1 -0
  69. package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts +14 -0
  70. package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts.map +1 -0
  71. package/dist/NotificationServicesController/__fixtures__/test-utils.mjs +27 -0
  72. package/dist/NotificationServicesController/__fixtures__/test-utils.mjs.map +1 -0
  73. package/dist/NotificationServicesController/constants/constants.cjs +7 -0
  74. package/dist/NotificationServicesController/constants/constants.cjs.map +1 -0
  75. package/dist/{types/NotificationServicesController/constants/constants.d.ts → NotificationServicesController/constants/constants.d.cts} +1 -1
  76. package/dist/NotificationServicesController/constants/constants.d.cts.map +1 -0
  77. package/dist/NotificationServicesController/constants/constants.d.mts +3 -0
  78. package/dist/NotificationServicesController/constants/constants.d.mts.map +1 -0
  79. package/dist/NotificationServicesController/constants/constants.mjs +3 -9
  80. package/dist/NotificationServicesController/constants/constants.mjs.map +1 -1
  81. package/dist/NotificationServicesController/constants/index.cjs +19 -0
  82. package/dist/NotificationServicesController/constants/index.cjs.map +1 -0
  83. package/dist/NotificationServicesController/constants/index.d.cts +3 -0
  84. package/dist/NotificationServicesController/constants/index.d.cts.map +1 -0
  85. package/dist/NotificationServicesController/constants/index.d.mts +3 -0
  86. package/dist/NotificationServicesController/constants/index.d.mts.map +1 -0
  87. package/dist/NotificationServicesController/constants/index.mjs +2 -28
  88. package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
  89. package/dist/NotificationServicesController/constants/notification-schema.cjs +170 -0
  90. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -0
  91. package/dist/{types/NotificationServicesController/constants/notification-schema.d.ts → NotificationServicesController/constants/notification-schema.d.cts} +2 -2
  92. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -0
  93. package/dist/NotificationServicesController/constants/notification-schema.d.mts +48 -0
  94. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -0
  95. package/dist/NotificationServicesController/constants/notification-schema.mjs +165 -20
  96. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  97. package/dist/NotificationServicesController/index.cjs +46 -0
  98. package/dist/NotificationServicesController/index.cjs.map +1 -0
  99. package/dist/NotificationServicesController/index.d.cts +14 -0
  100. package/dist/NotificationServicesController/index.d.cts.map +1 -0
  101. package/dist/NotificationServicesController/index.d.mts +14 -0
  102. package/dist/NotificationServicesController/index.d.mts.map +1 -0
  103. package/dist/NotificationServicesController/index.mjs +13 -86
  104. package/dist/NotificationServicesController/index.mjs.map +1 -1
  105. package/dist/NotificationServicesController/processors/index.cjs +20 -0
  106. package/dist/NotificationServicesController/processors/index.cjs.map +1 -0
  107. package/dist/NotificationServicesController/processors/index.d.cts +4 -0
  108. package/dist/NotificationServicesController/processors/index.d.cts.map +1 -0
  109. package/dist/NotificationServicesController/processors/index.d.mts +4 -0
  110. package/dist/NotificationServicesController/processors/index.d.mts.map +1 -0
  111. package/dist/NotificationServicesController/processors/index.mjs +3 -21
  112. package/dist/NotificationServicesController/processors/index.mjs.map +1 -1
  113. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs +41 -0
  114. package/dist/{chunk-52CALMRA.js.map → NotificationServicesController/processors/process-feature-announcement.cjs.map} +1 -1
  115. package/dist/{types/NotificationServicesController/processors/process-feature-announcement.d.ts → NotificationServicesController/processors/process-feature-announcement.d.cts} +3 -3
  116. package/dist/NotificationServicesController/processors/process-feature-announcement.d.cts.map +1 -0
  117. package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts +19 -0
  118. package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts.map +1 -0
  119. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +34 -8
  120. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -1
  121. package/dist/NotificationServicesController/processors/process-notifications.cjs +50 -0
  122. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -0
  123. package/dist/{types/NotificationServicesController/processors/process-notifications.d.ts → NotificationServicesController/processors/process-notifications.d.cts} +2 -2
  124. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -0
  125. package/dist/NotificationServicesController/processors/process-notifications.d.mts +19 -0
  126. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -0
  127. package/dist/NotificationServicesController/processors/process-notifications.mjs +44 -12
  128. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  129. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs +19 -0
  130. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs.map +1 -0
  131. package/dist/{types/NotificationServicesController/processors/process-onchain-notifications.d.ts → NotificationServicesController/processors/process-onchain-notifications.d.cts} +3 -3
  132. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts.map +1 -0
  133. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts +10 -0
  134. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts.map +1 -0
  135. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +14 -7
  136. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +1 -1
  137. package/dist/NotificationServicesController/services/feature-announcements.cjs +97 -0
  138. package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -0
  139. package/dist/{types/NotificationServicesController/services/feature-announcements.d.ts → NotificationServicesController/services/feature-announcements.d.cts} +4 -4
  140. package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -0
  141. package/dist/NotificationServicesController/services/feature-announcements.d.mts +28 -0
  142. package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -0
  143. package/dist/NotificationServicesController/services/feature-announcements.mjs +91 -12
  144. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
  145. package/dist/NotificationServicesController/services/onchain-notifications.cjs +195 -0
  146. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -0
  147. package/dist/{types/NotificationServicesController/services/onchain-notifications.d.ts → NotificationServicesController/services/onchain-notifications.d.cts} +3 -3
  148. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -0
  149. package/dist/NotificationServicesController/services/onchain-notifications.d.mts +62 -0
  150. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -0
  151. package/dist/NotificationServicesController/services/onchain-notifications.mjs +190 -29
  152. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
  153. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs +3 -0
  154. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs.map +1 -0
  155. package/dist/{types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts → NotificationServicesController/types/feature-announcement/feature-announcement.d.cts} +3 -3
  156. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.cts.map +1 -0
  157. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts +32 -0
  158. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts.map +1 -0
  159. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs +1 -1
  160. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs.map +1 -1
  161. package/dist/NotificationServicesController/types/feature-announcement/index.cjs +20 -0
  162. package/dist/NotificationServicesController/types/feature-announcement/index.cjs.map +1 -0
  163. package/dist/NotificationServicesController/types/feature-announcement/index.d.cts +4 -0
  164. package/dist/NotificationServicesController/types/feature-announcement/index.d.cts.map +1 -0
  165. package/dist/NotificationServicesController/types/feature-announcement/index.d.mts +4 -0
  166. package/dist/NotificationServicesController/types/feature-announcement/index.d.mts.map +1 -0
  167. package/dist/NotificationServicesController/types/feature-announcement/index.mjs +3 -4
  168. package/dist/NotificationServicesController/types/feature-announcement/index.mjs.map +1 -1
  169. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.cjs +3 -0
  170. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.cjs.map +1 -0
  171. package/dist/{types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts → NotificationServicesController/types/feature-announcement/type-feature-announcement.d.cts} +3 -3
  172. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.cts.map +1 -0
  173. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.mts +39 -0
  174. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.mts.map +1 -0
  175. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs +1 -1
  176. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs.map +1 -1
  177. package/dist/NotificationServicesController/types/feature-announcement/type-links.cjs +3 -0
  178. package/dist/NotificationServicesController/types/feature-announcement/type-links.cjs.map +1 -0
  179. package/dist/{types/NotificationServicesController/types/feature-announcement/type-links.d.ts → NotificationServicesController/types/feature-announcement/type-links.d.cts} +1 -1
  180. package/dist/NotificationServicesController/types/feature-announcement/type-links.d.cts.map +1 -0
  181. package/dist/NotificationServicesController/types/feature-announcement/type-links.d.mts +29 -0
  182. package/dist/NotificationServicesController/types/feature-announcement/type-links.d.mts.map +1 -0
  183. package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs +1 -1
  184. package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs.map +1 -1
  185. package/dist/NotificationServicesController/types/index.cjs +21 -0
  186. package/dist/NotificationServicesController/types/index.cjs.map +1 -0
  187. package/dist/NotificationServicesController/types/index.d.cts +5 -0
  188. package/dist/NotificationServicesController/types/index.d.cts.map +1 -0
  189. package/dist/NotificationServicesController/types/index.d.mts +5 -0
  190. package/dist/NotificationServicesController/types/index.d.mts.map +1 -0
  191. package/dist/NotificationServicesController/types/index.mjs +4 -11
  192. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  193. package/dist/NotificationServicesController/types/notification/index.cjs +18 -0
  194. package/dist/NotificationServicesController/types/notification/index.cjs.map +1 -0
  195. package/dist/NotificationServicesController/types/notification/index.d.cts +2 -0
  196. package/dist/NotificationServicesController/types/notification/index.d.cts.map +1 -0
  197. package/dist/NotificationServicesController/types/notification/index.d.mts +2 -0
  198. package/dist/NotificationServicesController/types/notification/index.d.mts.map +1 -0
  199. package/dist/NotificationServicesController/types/notification/index.mjs +1 -2
  200. package/dist/NotificationServicesController/types/notification/index.mjs.map +1 -1
  201. package/dist/NotificationServicesController/types/notification/notification.cjs +3 -0
  202. package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -0
  203. package/dist/{types/NotificationServicesController/types/notification/notification.d.ts → NotificationServicesController/types/notification/notification.d.cts} +4 -4
  204. package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -0
  205. package/dist/NotificationServicesController/types/notification/notification.d.mts +25 -0
  206. package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -0
  207. package/dist/NotificationServicesController/types/notification/notification.mjs +1 -1
  208. package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -1
  209. package/dist/NotificationServicesController/types/on-chain-notification/index.cjs +18 -0
  210. package/dist/NotificationServicesController/types/on-chain-notification/index.cjs.map +1 -0
  211. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts +2 -0
  212. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts.map +1 -0
  213. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts +2 -0
  214. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts.map +1 -0
  215. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs +1 -2
  216. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +1 -1
  217. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs +3 -0
  218. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs.map +1 -0
  219. package/dist/{types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts → NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts} +4 -4
  220. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts.map +1 -0
  221. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts +43 -0
  222. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts.map +1 -0
  223. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +1 -1
  224. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +1 -1
  225. package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs +9 -0
  226. package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs.map +1 -0
  227. package/dist/{types/NotificationServicesController/types/on-chain-notification/schema.d.ts → NotificationServicesController/types/on-chain-notification/schema.d.cts} +1 -1
  228. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts.map +1 -0
  229. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts +283 -0
  230. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts.map +1 -0
  231. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs +7 -0
  232. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +1 -1
  233. package/dist/NotificationServicesController/types/type-utils.cjs +3 -0
  234. package/dist/NotificationServicesController/types/type-utils.cjs.map +1 -0
  235. package/dist/{types/NotificationServicesController/types/type-utils.d.ts → NotificationServicesController/types/type-utils.d.cts} +1 -1
  236. package/dist/NotificationServicesController/types/type-utils.d.cts.map +1 -0
  237. package/dist/NotificationServicesController/types/type-utils.d.mts +7 -0
  238. package/dist/NotificationServicesController/types/type-utils.d.mts.map +1 -0
  239. package/dist/NotificationServicesController/types/type-utils.mjs +1 -0
  240. package/dist/NotificationServicesController/types/type-utils.mjs.map +1 -1
  241. package/dist/NotificationServicesController/types/user-storage/index.cjs +18 -0
  242. package/dist/NotificationServicesController/types/user-storage/index.cjs.map +1 -0
  243. package/dist/NotificationServicesController/types/user-storage/index.d.cts +2 -0
  244. package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +1 -0
  245. package/dist/NotificationServicesController/types/user-storage/index.d.mts +2 -0
  246. package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +1 -0
  247. package/dist/NotificationServicesController/types/user-storage/index.mjs +1 -2
  248. package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -1
  249. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +3 -0
  250. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +1 -0
  251. package/dist/{types/NotificationServicesController/types/user-storage/user-storage.d.ts → NotificationServicesController/types/user-storage/user-storage.d.cts} +3 -3
  252. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +1 -0
  253. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +26 -0
  254. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +1 -0
  255. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +1 -1
  256. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -1
  257. package/dist/NotificationServicesController/ui/constants.cjs +62 -0
  258. package/dist/NotificationServicesController/ui/constants.cjs.map +1 -0
  259. package/dist/{types/NotificationServicesController/ui/constants.d.ts → NotificationServicesController/ui/constants.d.cts} +2 -2
  260. package/dist/NotificationServicesController/ui/constants.d.cts.map +1 -0
  261. package/dist/NotificationServicesController/ui/constants.d.mts +54 -0
  262. package/dist/NotificationServicesController/ui/constants.d.mts.map +1 -0
  263. package/dist/NotificationServicesController/ui/constants.mjs +56 -14
  264. package/dist/NotificationServicesController/ui/constants.mjs.map +1 -1
  265. package/dist/NotificationServicesController/ui/index.cjs +18 -0
  266. package/dist/NotificationServicesController/ui/index.cjs.map +1 -0
  267. package/dist/NotificationServicesController/ui/index.d.cts +2 -0
  268. package/dist/NotificationServicesController/ui/index.d.cts.map +1 -0
  269. package/dist/NotificationServicesController/ui/index.d.mts +2 -0
  270. package/dist/NotificationServicesController/ui/index.d.mts.map +1 -0
  271. package/dist/NotificationServicesController/ui/index.mjs +1 -16
  272. package/dist/NotificationServicesController/ui/index.mjs.map +1 -1
  273. package/dist/NotificationServicesController/utils/utils.cjs +348 -0
  274. package/dist/NotificationServicesController/utils/utils.cjs.map +1 -0
  275. package/dist/{types/NotificationServicesController/utils/utils.d.ts → NotificationServicesController/utils/utils.d.cts} +3 -3
  276. package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -0
  277. package/dist/NotificationServicesController/utils/utils.d.mts +142 -0
  278. package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -0
  279. package/dist/NotificationServicesController/utils/utils.mjs +332 -31
  280. package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
  281. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +215 -0
  282. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -0
  283. package/dist/{types/NotificationServicesPushController/NotificationServicesPushController.d.ts → NotificationServicesPushController/NotificationServicesPushController.d.cts} +6 -6
  284. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -0
  285. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +112 -0
  286. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -0
  287. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +214 -37
  288. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  289. package/dist/NotificationServicesPushController/__fixtures__/index.cjs +18 -0
  290. package/dist/NotificationServicesPushController/__fixtures__/index.cjs.map +1 -0
  291. package/dist/NotificationServicesPushController/__fixtures__/index.d.cts +2 -0
  292. package/dist/NotificationServicesPushController/__fixtures__/index.d.cts.map +1 -0
  293. package/dist/NotificationServicesPushController/__fixtures__/index.d.mts +2 -0
  294. package/dist/NotificationServicesPushController/__fixtures__/index.d.mts.map +1 -0
  295. package/dist/NotificationServicesPushController/__fixtures__/index.mjs +2 -0
  296. package/dist/NotificationServicesPushController/__fixtures__/index.mjs.map +1 -0
  297. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.cjs +57 -0
  298. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.cjs.map +1 -0
  299. package/dist/{types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts → NotificationServicesPushController/__fixtures__/mockResponse.d.cts} +2 -2
  300. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.cts.map +1 -0
  301. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.mts +43 -0
  302. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.mts.map +1 -0
  303. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.mjs +50 -0
  304. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.mjs.map +1 -0
  305. package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs +31 -0
  306. package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs.map +1 -0
  307. package/dist/{types/NotificationServicesPushController/__fixtures__/mockServices.d.ts → NotificationServicesPushController/__fixtures__/mockServices.d.cts} +2 -2
  308. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts.map +1 -0
  309. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts +9 -0
  310. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts.map +1 -0
  311. package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs +30 -0
  312. package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs.map +1 -0
  313. package/dist/NotificationServicesPushController/constants.cjs +14 -0
  314. package/dist/NotificationServicesPushController/constants.cjs.map +1 -0
  315. package/dist/{types/NotificationServicesPushController/constants.d.ts → NotificationServicesPushController/constants.d.cts} +1 -1
  316. package/dist/NotificationServicesPushController/constants.d.cts.map +1 -0
  317. package/dist/NotificationServicesPushController/constants.d.mts +11 -0
  318. package/dist/NotificationServicesPushController/constants.d.mts.map +1 -0
  319. package/dist/NotificationServicesPushController/constants.mjs +10 -25
  320. package/dist/NotificationServicesPushController/constants.mjs.map +1 -1
  321. package/dist/NotificationServicesPushController/index.cjs +43 -0
  322. package/dist/NotificationServicesPushController/index.cjs.map +1 -0
  323. package/dist/NotificationServicesPushController/index.d.cts +11 -0
  324. package/dist/NotificationServicesPushController/index.d.cts.map +1 -0
  325. package/dist/NotificationServicesPushController/index.d.mts +11 -0
  326. package/dist/NotificationServicesPushController/index.d.mts.map +1 -0
  327. package/dist/NotificationServicesPushController/index.mjs +10 -71
  328. package/dist/NotificationServicesPushController/index.mjs.map +1 -1
  329. package/dist/NotificationServicesPushController/services/endpoints.cjs +6 -0
  330. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -0
  331. package/dist/{types/NotificationServicesPushController/services/endpoints.d.ts → NotificationServicesPushController/services/endpoints.d.cts} +1 -1
  332. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -0
  333. package/dist/NotificationServicesPushController/services/endpoints.d.mts +2 -0
  334. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -0
  335. package/dist/NotificationServicesPushController/services/endpoints.mjs +2 -7
  336. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  337. package/dist/NotificationServicesPushController/services/push/index.cjs +3 -0
  338. package/dist/NotificationServicesPushController/services/push/index.cjs.map +1 -0
  339. package/dist/{types/NotificationServicesPushController/services/push/index.d.ts → NotificationServicesPushController/services/push/index.d.cts} +2 -2
  340. package/dist/NotificationServicesPushController/services/push/index.d.cts.map +1 -0
  341. package/dist/NotificationServicesPushController/services/push/index.d.mts +6 -0
  342. package/dist/NotificationServicesPushController/services/push/index.d.mts.map +1 -0
  343. package/dist/NotificationServicesPushController/services/push/index.mjs +1 -0
  344. package/dist/NotificationServicesPushController/services/push/index.mjs.map +1 -1
  345. package/dist/NotificationServicesPushController/services/push/push-web.cjs +121 -0
  346. package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +1 -0
  347. package/dist/{types/NotificationServicesPushController/services/push/push-web.d.ts → NotificationServicesPushController/services/push/push-web.d.cts} +3 -3
  348. package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +1 -0
  349. package/dist/NotificationServicesPushController/services/push/push-web.d.mts +32 -0
  350. package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +1 -0
  351. package/dist/NotificationServicesPushController/services/push/push-web.mjs +116 -38
  352. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -1
  353. package/dist/NotificationServicesPushController/services/services.cjs +197 -0
  354. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -0
  355. package/dist/{types/NotificationServicesPushController/services/services.d.ts → NotificationServicesPushController/services/services.d.cts} +4 -4
  356. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -0
  357. package/dist/NotificationServicesPushController/services/services.d.mts +95 -0
  358. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -0
  359. package/dist/NotificationServicesPushController/services/services.mjs +168 -45
  360. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  361. package/dist/NotificationServicesPushController/types/firebase.cjs +3 -0
  362. package/dist/NotificationServicesPushController/types/firebase.cjs.map +1 -0
  363. package/dist/{types/NotificationServicesPushController/types/firebase.d.ts → NotificationServicesPushController/types/firebase.d.cts} +1 -1
  364. package/dist/NotificationServicesPushController/types/firebase.d.cts.map +1 -0
  365. package/dist/NotificationServicesPushController/types/firebase.d.mts +53 -0
  366. package/dist/NotificationServicesPushController/types/firebase.d.mts.map +1 -0
  367. package/dist/NotificationServicesPushController/types/firebase.mjs +1 -1
  368. package/dist/NotificationServicesPushController/types/firebase.mjs.map +1 -1
  369. package/dist/NotificationServicesPushController/types/index.cjs +18 -0
  370. package/dist/NotificationServicesPushController/types/index.cjs.map +1 -0
  371. package/dist/NotificationServicesPushController/types/index.d.cts +2 -0
  372. package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -0
  373. package/dist/NotificationServicesPushController/types/index.d.mts +2 -0
  374. package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -0
  375. package/dist/NotificationServicesPushController/types/index.mjs +1 -2
  376. package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
  377. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +84 -0
  378. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -0
  379. package/dist/{types/NotificationServicesPushController/utils/get-notification-data.d.ts → NotificationServicesPushController/utils/get-notification-data.d.cts} +2 -2
  380. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -0
  381. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +42 -0
  382. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -0
  383. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +76 -12
  384. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
  385. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +190 -0
  386. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -0
  387. package/dist/{types/NotificationServicesPushController/utils/get-notification-message.d.ts → NotificationServicesPushController/utils/get-notification-message.d.cts} +3 -3
  388. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -0
  389. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +67 -0
  390. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -0
  391. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +182 -37
  392. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  393. package/dist/NotificationServicesPushController/utils/index.cjs +19 -0
  394. package/dist/NotificationServicesPushController/utils/index.cjs.map +1 -0
  395. package/dist/NotificationServicesPushController/utils/index.d.cts +3 -0
  396. package/dist/NotificationServicesPushController/utils/index.d.cts.map +1 -0
  397. package/dist/NotificationServicesPushController/utils/index.d.mts +3 -0
  398. package/dist/NotificationServicesPushController/utils/index.d.mts.map +1 -0
  399. package/dist/NotificationServicesPushController/utils/index.mjs +2 -48
  400. package/dist/NotificationServicesPushController/utils/index.mjs.map +1 -1
  401. package/dist/index.cjs +29 -0
  402. package/dist/index.cjs.map +1 -0
  403. package/dist/index.d.cts +3 -0
  404. package/dist/index.d.cts.map +1 -0
  405. package/dist/index.d.mts +3 -0
  406. package/dist/index.d.mts.map +1 -0
  407. package/dist/index.mjs +2 -45
  408. package/dist/index.mjs.map +1 -1
  409. package/dist/shared/to-raw-notification.cjs +19 -0
  410. package/dist/shared/to-raw-notification.cjs.map +1 -0
  411. package/dist/{types/shared/to-raw-notification.d.ts → shared/to-raw-notification.d.cts} +2 -2
  412. package/dist/shared/to-raw-notification.d.cts.map +1 -0
  413. package/dist/shared/to-raw-notification.d.mts +11 -0
  414. package/dist/shared/to-raw-notification.d.mts.map +1 -0
  415. package/dist/shared/to-raw-notification.mjs +14 -7
  416. package/dist/shared/to-raw-notification.mjs.map +1 -1
  417. package/package.json +12 -7
  418. package/dist/NotificationServicesController/NotificationServicesController.js +0 -19
  419. package/dist/NotificationServicesController/NotificationServicesController.js.map +0 -1
  420. package/dist/NotificationServicesController/constants/constants.js +0 -10
  421. package/dist/NotificationServicesController/constants/constants.js.map +0 -1
  422. package/dist/NotificationServicesController/constants/index.js +0 -29
  423. package/dist/NotificationServicesController/constants/index.js.map +0 -1
  424. package/dist/NotificationServicesController/constants/notification-schema.js +0 -22
  425. package/dist/NotificationServicesController/constants/notification-schema.js.map +0 -1
  426. package/dist/NotificationServicesController/index.js +0 -87
  427. package/dist/NotificationServicesController/index.js.map +0 -1
  428. package/dist/NotificationServicesController/processors/index.js +0 -22
  429. package/dist/NotificationServicesController/processors/index.js.map +0 -1
  430. package/dist/NotificationServicesController/processors/process-feature-announcement.js +0 -10
  431. package/dist/NotificationServicesController/processors/process-feature-announcement.js.map +0 -1
  432. package/dist/NotificationServicesController/processors/process-notifications.js +0 -13
  433. package/dist/NotificationServicesController/processors/process-notifications.js.map +0 -1
  434. package/dist/NotificationServicesController/processors/process-onchain-notifications.js +0 -8
  435. package/dist/NotificationServicesController/processors/process-onchain-notifications.js.map +0 -1
  436. package/dist/NotificationServicesController/services/feature-announcements.js +0 -14
  437. package/dist/NotificationServicesController/services/feature-announcements.js.map +0 -1
  438. package/dist/NotificationServicesController/services/onchain-notifications.js +0 -30
  439. package/dist/NotificationServicesController/services/onchain-notifications.js.map +0 -1
  440. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js +0 -2
  441. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js.map +0 -1
  442. package/dist/NotificationServicesController/types/feature-announcement/index.js +0 -5
  443. package/dist/NotificationServicesController/types/feature-announcement/index.js.map +0 -1
  444. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js +0 -2
  445. package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js.map +0 -1
  446. package/dist/NotificationServicesController/types/feature-announcement/type-links.js +0 -2
  447. package/dist/NotificationServicesController/types/feature-announcement/type-links.js.map +0 -1
  448. package/dist/NotificationServicesController/types/index.js +0 -12
  449. package/dist/NotificationServicesController/types/index.js.map +0 -1
  450. package/dist/NotificationServicesController/types/notification/index.js +0 -3
  451. package/dist/NotificationServicesController/types/notification/index.js.map +0 -1
  452. package/dist/NotificationServicesController/types/notification/notification.js +0 -2
  453. package/dist/NotificationServicesController/types/notification/notification.js.map +0 -1
  454. package/dist/NotificationServicesController/types/on-chain-notification/index.js +0 -3
  455. package/dist/NotificationServicesController/types/on-chain-notification/index.js.map +0 -1
  456. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js +0 -2
  457. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js.map +0 -1
  458. package/dist/NotificationServicesController/types/on-chain-notification/schema.js +0 -1
  459. package/dist/NotificationServicesController/types/on-chain-notification/schema.js.map +0 -1
  460. package/dist/NotificationServicesController/types/type-utils.js +0 -1
  461. package/dist/NotificationServicesController/types/type-utils.js.map +0 -1
  462. package/dist/NotificationServicesController/types/user-storage/index.js +0 -3
  463. package/dist/NotificationServicesController/types/user-storage/index.js.map +0 -1
  464. package/dist/NotificationServicesController/types/user-storage/user-storage.js +0 -2
  465. package/dist/NotificationServicesController/types/user-storage/user-storage.js.map +0 -1
  466. package/dist/NotificationServicesController/ui/constants.js +0 -16
  467. package/dist/NotificationServicesController/ui/constants.js.map +0 -1
  468. package/dist/NotificationServicesController/ui/index.js +0 -17
  469. package/dist/NotificationServicesController/ui/index.js.map +0 -1
  470. package/dist/NotificationServicesController/utils/utils.js +0 -32
  471. package/dist/NotificationServicesController/utils/utils.js.map +0 -1
  472. package/dist/NotificationServicesPushController/NotificationServicesPushController.js +0 -39
  473. package/dist/NotificationServicesPushController/NotificationServicesPushController.js.map +0 -1
  474. package/dist/NotificationServicesPushController/constants.js +0 -26
  475. package/dist/NotificationServicesPushController/constants.js.map +0 -1
  476. package/dist/NotificationServicesPushController/index.js +0 -72
  477. package/dist/NotificationServicesPushController/index.js.map +0 -1
  478. package/dist/NotificationServicesPushController/services/endpoints.js +0 -8
  479. package/dist/NotificationServicesPushController/services/endpoints.js.map +0 -1
  480. package/dist/NotificationServicesPushController/services/push/index.js +0 -1
  481. package/dist/NotificationServicesPushController/services/push/index.js.map +0 -1
  482. package/dist/NotificationServicesPushController/services/push/push-web.js +0 -40
  483. package/dist/NotificationServicesPushController/services/push/push-web.js.map +0 -1
  484. package/dist/NotificationServicesPushController/services/services.js +0 -46
  485. package/dist/NotificationServicesPushController/services/services.js.map +0 -1
  486. package/dist/NotificationServicesPushController/types/firebase.js +0 -2
  487. package/dist/NotificationServicesPushController/types/firebase.js.map +0 -1
  488. package/dist/NotificationServicesPushController/types/index.js +0 -3
  489. package/dist/NotificationServicesPushController/types/index.js.map +0 -1
  490. package/dist/NotificationServicesPushController/utils/get-notification-data.js +0 -14
  491. package/dist/NotificationServicesPushController/utils/get-notification-data.js.map +0 -1
  492. package/dist/NotificationServicesPushController/utils/get-notification-message.js +0 -39
  493. package/dist/NotificationServicesPushController/utils/get-notification-message.js.map +0 -1
  494. package/dist/NotificationServicesPushController/utils/index.js +0 -49
  495. package/dist/NotificationServicesPushController/utils/index.js.map +0 -1
  496. package/dist/chunk-232HZSEV.js +0 -7
  497. package/dist/chunk-232HZSEV.js.map +0 -1
  498. package/dist/chunk-2P5WP5NT.mjs +0 -37
  499. package/dist/chunk-2P5WP5NT.mjs.map +0 -1
  500. package/dist/chunk-3ZS2HAEG.js +0 -1
  501. package/dist/chunk-3ZS2HAEG.js.map +0 -1
  502. package/dist/chunk-4BTNTREI.mjs +0 -1
  503. package/dist/chunk-4BTNTREI.mjs.map +0 -1
  504. package/dist/chunk-4QXAPVW3.mjs +0 -1
  505. package/dist/chunk-4QXAPVW3.mjs.map +0 -1
  506. package/dist/chunk-52CALMRA.js +0 -28
  507. package/dist/chunk-53F3SYYM.mjs +0 -178
  508. package/dist/chunk-53F3SYYM.mjs.map +0 -1
  509. package/dist/chunk-5FAAZCBK.mjs +0 -29
  510. package/dist/chunk-5FAAZCBK.mjs.map +0 -1
  511. package/dist/chunk-6FLC6CJD.js +0 -149
  512. package/dist/chunk-6FLC6CJD.js.map +0 -1
  513. package/dist/chunk-6ZDVTRRT.mjs +0 -9
  514. package/dist/chunk-6ZDVTRRT.mjs.map +0 -1
  515. package/dist/chunk-77QIITUL.mjs +0 -67
  516. package/dist/chunk-77QIITUL.mjs.map +0 -1
  517. package/dist/chunk-7LWR54U7.js +0 -7
  518. package/dist/chunk-7LWR54U7.js.map +0 -1
  519. package/dist/chunk-7PWKQSM2.mjs +0 -972
  520. package/dist/chunk-7PWKQSM2.mjs.map +0 -1
  521. package/dist/chunk-7RM3YNTD.mjs +0 -1
  522. package/dist/chunk-7RM3YNTD.mjs.map +0 -1
  523. package/dist/chunk-A2RPVX47.mjs +0 -1
  524. package/dist/chunk-A2RPVX47.mjs.map +0 -1
  525. package/dist/chunk-B25TJ7KS.js +0 -8
  526. package/dist/chunk-B25TJ7KS.js.map +0 -1
  527. package/dist/chunk-B4ECJJ5C.mjs +0 -7
  528. package/dist/chunk-B4ECJJ5C.mjs.map +0 -1
  529. package/dist/chunk-BONB66A2.mjs +0 -14
  530. package/dist/chunk-BONB66A2.mjs.map +0 -1
  531. package/dist/chunk-C62SK2KY.mjs +0 -92
  532. package/dist/chunk-C62SK2KY.mjs.map +0 -1
  533. package/dist/chunk-CGPMMFUQ.mjs +0 -96
  534. package/dist/chunk-CGPMMFUQ.mjs.map +0 -1
  535. package/dist/chunk-CWZQMK63.mjs +0 -118
  536. package/dist/chunk-CWZQMK63.mjs.map +0 -1
  537. package/dist/chunk-D42BBXBM.mjs +0 -28
  538. package/dist/chunk-D42BBXBM.mjs.map +0 -1
  539. package/dist/chunk-DINCLRZT.mjs +0 -12
  540. package/dist/chunk-DINCLRZT.mjs.map +0 -1
  541. package/dist/chunk-DMH4NSLF.js +0 -1
  542. package/dist/chunk-DMH4NSLF.js.map +0 -1
  543. package/dist/chunk-DT6SLUWJ.js +0 -12
  544. package/dist/chunk-DT6SLUWJ.js.map +0 -1
  545. package/dist/chunk-EJ52BDLB.js +0 -55
  546. package/dist/chunk-EJ52BDLB.js.map +0 -1
  547. package/dist/chunk-ER475D6V.mjs +0 -231
  548. package/dist/chunk-ER475D6V.mjs.map +0 -1
  549. package/dist/chunk-G52DNXFH.mjs +0 -1
  550. package/dist/chunk-G52DNXFH.mjs.map +0 -1
  551. package/dist/chunk-GETQWOTI.js +0 -1
  552. package/dist/chunk-GETQWOTI.js.map +0 -1
  553. package/dist/chunk-HCDICNYK.js +0 -207
  554. package/dist/chunk-HCDICNYK.js.map +0 -1
  555. package/dist/chunk-HE3P5RM7.js +0 -178
  556. package/dist/chunk-HE3P5RM7.js.map +0 -1
  557. package/dist/chunk-HPUQYDVC.js +0 -1
  558. package/dist/chunk-HPUQYDVC.js.map +0 -1
  559. package/dist/chunk-HT6T5R4U.js +0 -96
  560. package/dist/chunk-HT6T5R4U.js.map +0 -1
  561. package/dist/chunk-IDO4JFV5.mjs +0 -1
  562. package/dist/chunk-IDO4JFV5.mjs.map +0 -1
  563. package/dist/chunk-IGY2S5BC.js +0 -36
  564. package/dist/chunk-IGY2S5BC.js.map +0 -1
  565. package/dist/chunk-IKWNHNJQ.mjs +0 -8
  566. package/dist/chunk-IKWNHNJQ.mjs.map +0 -1
  567. package/dist/chunk-IOMDG67D.mjs +0 -7
  568. package/dist/chunk-IOMDG67D.mjs.map +0 -1
  569. package/dist/chunk-IPI7BAW3.js +0 -1
  570. package/dist/chunk-IPI7BAW3.js.map +0 -1
  571. package/dist/chunk-JIJXHO5V.js +0 -885
  572. package/dist/chunk-JIJXHO5V.js.map +0 -1
  573. package/dist/chunk-JQ7WKFCI.mjs +0 -1
  574. package/dist/chunk-JQ7WKFCI.mjs.map +0 -1
  575. package/dist/chunk-JW3TK3NU.js +0 -221
  576. package/dist/chunk-JW3TK3NU.js.map +0 -1
  577. package/dist/chunk-KGLHGLER.js +0 -231
  578. package/dist/chunk-KGLHGLER.js.map +0 -1
  579. package/dist/chunk-LGXHJ24K.js +0 -92
  580. package/dist/chunk-LGXHJ24K.js.map +0 -1
  581. package/dist/chunk-LYEXYTOI.js +0 -14
  582. package/dist/chunk-LYEXYTOI.js.map +0 -1
  583. package/dist/chunk-LZMC2QML.mjs +0 -25
  584. package/dist/chunk-LZMC2QML.mjs.map +0 -1
  585. package/dist/chunk-MG5QDUDI.mjs +0 -48
  586. package/dist/chunk-MG5QDUDI.mjs.map +0 -1
  587. package/dist/chunk-MNBV5FJI.mjs +0 -31
  588. package/dist/chunk-MNBV5FJI.mjs.map +0 -1
  589. package/dist/chunk-NIPCK74T.js +0 -185
  590. package/dist/chunk-NIPCK74T.js.map +0 -1
  591. package/dist/chunk-O45HYLIV.js +0 -67
  592. package/dist/chunk-O45HYLIV.js.map +0 -1
  593. package/dist/chunk-ODI2BTKS.mjs +0 -55
  594. package/dist/chunk-ODI2BTKS.mjs.map +0 -1
  595. package/dist/chunk-OHFX4S6R.mjs +0 -185
  596. package/dist/chunk-OHFX4S6R.mjs.map +0 -1
  597. package/dist/chunk-OMBFVTP2.js +0 -37
  598. package/dist/chunk-OMBFVTP2.js.map +0 -1
  599. package/dist/chunk-PJMQ2XEG.js +0 -29
  600. package/dist/chunk-PJMQ2XEG.js.map +0 -1
  601. package/dist/chunk-PNCS6GEX.mjs +0 -1
  602. package/dist/chunk-PNCS6GEX.mjs.map +0 -1
  603. package/dist/chunk-PROWNV4M.js +0 -1
  604. package/dist/chunk-PROWNV4M.js.map +0 -1
  605. package/dist/chunk-QAOZN4AX.js +0 -25
  606. package/dist/chunk-QAOZN4AX.js.map +0 -1
  607. package/dist/chunk-QB5IFRLA.mjs +0 -1
  608. package/dist/chunk-QB5IFRLA.mjs.map +0 -1
  609. package/dist/chunk-RAUV5UV4.mjs +0 -1
  610. package/dist/chunk-RAUV5UV4.mjs.map +0 -1
  611. package/dist/chunk-SGLVWM4N.js +0 -48
  612. package/dist/chunk-SGLVWM4N.js.map +0 -1
  613. package/dist/chunk-TLX5QQK5.js +0 -9
  614. package/dist/chunk-TLX5QQK5.js.map +0 -1
  615. package/dist/chunk-U5UIDVOO.mjs +0 -36
  616. package/dist/chunk-U5UIDVOO.mjs.map +0 -1
  617. package/dist/chunk-U74Q3BRP.mjs +0 -1
  618. package/dist/chunk-U74Q3BRP.mjs.map +0 -1
  619. package/dist/chunk-UQ6MTYIR.js +0 -972
  620. package/dist/chunk-UQ6MTYIR.js.map +0 -1
  621. package/dist/chunk-UZHUVXRM.js +0 -31
  622. package/dist/chunk-UZHUVXRM.js.map +0 -1
  623. package/dist/chunk-V5HMYDWE.js +0 -1
  624. package/dist/chunk-V5HMYDWE.js.map +0 -1
  625. package/dist/chunk-VZMQIJMK.mjs +0 -149
  626. package/dist/chunk-VZMQIJMK.mjs.map +0 -1
  627. package/dist/chunk-W7IP4LDB.js +0 -118
  628. package/dist/chunk-W7IP4LDB.js.map +0 -1
  629. package/dist/chunk-WE4RFGT7.mjs +0 -885
  630. package/dist/chunk-WE4RFGT7.mjs.map +0 -1
  631. package/dist/chunk-WGBEAP2F.mjs +0 -207
  632. package/dist/chunk-WGBEAP2F.mjs.map +0 -1
  633. package/dist/chunk-WRYFIWNK.js +0 -1
  634. package/dist/chunk-WRYFIWNK.js.map +0 -1
  635. package/dist/chunk-XZEVRYUE.js +0 -1
  636. package/dist/chunk-XZEVRYUE.js.map +0 -1
  637. package/dist/chunk-YUMIJSUD.mjs +0 -221
  638. package/dist/chunk-YUMIJSUD.mjs.map +0 -1
  639. package/dist/chunk-ZBNBZN5H.js +0 -1
  640. package/dist/chunk-ZBNBZN5H.js.map +0 -1
  641. package/dist/chunk-ZV3DFBO4.js +0 -1
  642. package/dist/chunk-ZV3DFBO4.js.map +0 -1
  643. package/dist/index.js +0 -46
  644. package/dist/index.js.map +0 -1
  645. package/dist/shared/to-raw-notification.js +0 -8
  646. package/dist/shared/to-raw-notification.js.map +0 -1
  647. package/dist/tsconfig.build.tsbuildinfo +0 -1
  648. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +0 -1
  649. package/dist/types/NotificationServicesController/__fixtures__/index.d.ts +0 -6
  650. package/dist/types/NotificationServicesController/__fixtures__/index.d.ts.map +0 -1
  651. package/dist/types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts.map +0 -1
  652. package/dist/types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts.map +0 -1
  653. package/dist/types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts.map +0 -1
  654. package/dist/types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts.map +0 -1
  655. package/dist/types/NotificationServicesController/__fixtures__/mockResponses.d.ts.map +0 -1
  656. package/dist/types/NotificationServicesController/__fixtures__/mockServices.d.ts.map +0 -1
  657. package/dist/types/NotificationServicesController/__fixtures__/test-utils.d.ts.map +0 -1
  658. package/dist/types/NotificationServicesController/constants/constants.d.ts.map +0 -1
  659. package/dist/types/NotificationServicesController/constants/index.d.ts +0 -3
  660. package/dist/types/NotificationServicesController/constants/index.d.ts.map +0 -1
  661. package/dist/types/NotificationServicesController/constants/notification-schema.d.ts.map +0 -1
  662. package/dist/types/NotificationServicesController/index.d.ts +0 -14
  663. package/dist/types/NotificationServicesController/index.d.ts.map +0 -1
  664. package/dist/types/NotificationServicesController/processors/index.d.ts +0 -4
  665. package/dist/types/NotificationServicesController/processors/index.d.ts.map +0 -1
  666. package/dist/types/NotificationServicesController/processors/process-feature-announcement.d.ts.map +0 -1
  667. package/dist/types/NotificationServicesController/processors/process-notifications.d.ts.map +0 -1
  668. package/dist/types/NotificationServicesController/processors/process-onchain-notifications.d.ts.map +0 -1
  669. package/dist/types/NotificationServicesController/services/feature-announcements.d.ts.map +0 -1
  670. package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts.map +0 -1
  671. package/dist/types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts.map +0 -1
  672. package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts +0 -4
  673. package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts.map +0 -1
  674. package/dist/types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts.map +0 -1
  675. package/dist/types/NotificationServicesController/types/feature-announcement/type-links.d.ts.map +0 -1
  676. package/dist/types/NotificationServicesController/types/index.d.ts +0 -5
  677. package/dist/types/NotificationServicesController/types/index.d.ts.map +0 -1
  678. package/dist/types/NotificationServicesController/types/notification/index.d.ts +0 -2
  679. package/dist/types/NotificationServicesController/types/notification/index.d.ts.map +0 -1
  680. package/dist/types/NotificationServicesController/types/notification/notification.d.ts.map +0 -1
  681. package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts +0 -2
  682. package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts.map +0 -1
  683. package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts.map +0 -1
  684. package/dist/types/NotificationServicesController/types/on-chain-notification/schema.d.ts.map +0 -1
  685. package/dist/types/NotificationServicesController/types/type-utils.d.ts.map +0 -1
  686. package/dist/types/NotificationServicesController/types/user-storage/index.d.ts +0 -2
  687. package/dist/types/NotificationServicesController/types/user-storage/index.d.ts.map +0 -1
  688. package/dist/types/NotificationServicesController/types/user-storage/user-storage.d.ts.map +0 -1
  689. package/dist/types/NotificationServicesController/ui/constants.d.ts.map +0 -1
  690. package/dist/types/NotificationServicesController/ui/index.d.ts +0 -2
  691. package/dist/types/NotificationServicesController/ui/index.d.ts.map +0 -1
  692. package/dist/types/NotificationServicesController/utils/utils.d.ts.map +0 -1
  693. package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts.map +0 -1
  694. package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts +0 -2
  695. package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts.map +0 -1
  696. package/dist/types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts.map +0 -1
  697. package/dist/types/NotificationServicesPushController/__fixtures__/mockServices.d.ts.map +0 -1
  698. package/dist/types/NotificationServicesPushController/constants.d.ts.map +0 -1
  699. package/dist/types/NotificationServicesPushController/index.d.ts +0 -11
  700. package/dist/types/NotificationServicesPushController/index.d.ts.map +0 -1
  701. package/dist/types/NotificationServicesPushController/services/endpoints.d.ts.map +0 -1
  702. package/dist/types/NotificationServicesPushController/services/push/index.d.ts.map +0 -1
  703. package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts.map +0 -1
  704. package/dist/types/NotificationServicesPushController/services/services.d.ts.map +0 -1
  705. package/dist/types/NotificationServicesPushController/types/firebase.d.ts.map +0 -1
  706. package/dist/types/NotificationServicesPushController/types/index.d.ts +0 -2
  707. package/dist/types/NotificationServicesPushController/types/index.d.ts.map +0 -1
  708. package/dist/types/NotificationServicesPushController/utils/get-notification-data.d.ts.map +0 -1
  709. package/dist/types/NotificationServicesPushController/utils/get-notification-message.d.ts.map +0 -1
  710. package/dist/types/NotificationServicesPushController/utils/index.d.ts +0 -3
  711. package/dist/types/NotificationServicesPushController/utils/index.d.ts.map +0 -1
  712. package/dist/types/index.d.ts +0 -3
  713. package/dist/types/index.d.ts.map +0 -1
  714. package/dist/types/shared/to-raw-notification.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/NotificationServicesController/NotificationServicesController.ts"],"sourcesContent":["import type {\n RestrictedControllerMessenger,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerGetAccountsAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type {\n AuthenticationController,\n UserStorageController,\n} from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport { USER_STORAGE_VERSION_KEY } from './constants/constants';\nimport { TRIGGER_TYPES } from './constants/notification-schema';\nimport { safeProcessNotification } from './processors/process-notifications';\nimport * as FeatureNotifications from './services/feature-announcements';\nimport * as OnChainNotifications from './services/onchain-notifications';\nimport type {\n INotification,\n MarkAsReadNotificationsParam,\n NotificationUnion,\n} from './types/notification/notification';\nimport type { OnChainRawNotification } from './types/on-chain-notification/on-chain-notification';\nimport type { UserStorage } from './types/user-storage/user-storage';\nimport * as Utils from './utils/utils';\n\n// TODO: Fix Circular Type Dependencies\n// This indicates that control flow of messages is everywhere, lets orchestrate these better\nexport type NotificationServicesPushControllerEnablePushNotifications = {\n type: `NotificationServicesPushController:enablePushNotifications`;\n handler: (UUIDs: string[]) => Promise<void>;\n};\n\nexport type NotificationServicesPushControllerDisablePushNotifications = {\n type: `NotificationServicesPushController:disablePushNotifications`;\n handler: (UUIDs: string[]) => Promise<void>;\n};\n\nexport type NotificationServicesPushControllerUpdateTriggerPushNotifications = {\n type: `NotificationServicesPushController:updateTriggerPushNotifications`;\n handler: (UUIDs: string[]) => Promise<void>;\n};\n\nexport type NotificationServicesPushControllerSubscribeToNotifications = {\n type: `NotificationServicesPushController:subscribeToPushNotifications`;\n handler: () => Promise<void>;\n};\n\nexport type NotificationServicesPushControllerOnNewNotification = {\n type: `NotificationServicesPushController:onNewNotifications`;\n payload: [INotification];\n};\n\n// Unique name for the controller\nconst controllerName = 'NotificationServicesController';\n\n/**\n * State shape for NotificationServicesController\n */\nexport type NotificationServicesControllerState = {\n /**\n * We store and manage accounts that have been seen/visted through the\n * account subscription. This allows us to track and add notifications for new accounts and not previous accounts added.\n */\n subscriptionAccountsSeen: string[];\n\n /**\n * Flag that indicates if the metamask notifications feature has been seen\n */\n isMetamaskNotificationsFeatureSeen: boolean;\n\n /**\n * Flag that indicates if the metamask notifications are enabled\n */\n isNotificationServicesEnabled: boolean;\n\n /**\n * Flag that indicates if the feature announcements are enabled\n */\n isFeatureAnnouncementsEnabled: boolean;\n\n /**\n * List of metamask notifications\n */\n metamaskNotificationsList: INotification[];\n\n /**\n * List of read metamask notifications\n */\n metamaskNotificationsReadList: string[];\n /**\n * Flag that indicates that the creating notifications is in progress\n */\n isUpdatingMetamaskNotifications: boolean;\n /**\n * Flag that indicates that the fetching notifications is in progress\n * This is used to show a loading spinner in the UI\n * when fetching notifications\n */\n isFetchingMetamaskNotifications: boolean;\n /**\n * Flag that indicates that the updating notifications for a specific address is in progress\n */\n isUpdatingMetamaskNotificationsAccount: string[];\n /**\n * Flag that indicates that the checking accounts presence is in progress\n */\n isCheckingAccountsPresence: boolean;\n};\n\nconst metadata: StateMetadata<NotificationServicesControllerState> = {\n subscriptionAccountsSeen: {\n persist: true,\n anonymous: true,\n },\n\n isMetamaskNotificationsFeatureSeen: {\n persist: true,\n anonymous: false,\n },\n isNotificationServicesEnabled: {\n persist: true,\n anonymous: false,\n },\n isFeatureAnnouncementsEnabled: {\n persist: true,\n anonymous: false,\n },\n metamaskNotificationsList: {\n persist: true,\n anonymous: true,\n },\n metamaskNotificationsReadList: {\n persist: true,\n anonymous: true,\n },\n isUpdatingMetamaskNotifications: {\n persist: false,\n anonymous: false,\n },\n isFetchingMetamaskNotifications: {\n persist: false,\n anonymous: false,\n },\n isUpdatingMetamaskNotificationsAccount: {\n persist: false,\n anonymous: false,\n },\n isCheckingAccountsPresence: {\n persist: false,\n anonymous: false,\n },\n};\nexport const defaultState: NotificationServicesControllerState = {\n subscriptionAccountsSeen: [],\n isMetamaskNotificationsFeatureSeen: false,\n isNotificationServicesEnabled: false,\n isFeatureAnnouncementsEnabled: false,\n metamaskNotificationsList: [],\n metamaskNotificationsReadList: [],\n isUpdatingMetamaskNotifications: false,\n isFetchingMetamaskNotifications: false,\n isUpdatingMetamaskNotificationsAccount: [],\n isCheckingAccountsPresence: false,\n};\n\nexport type NotificationServicesControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NotificationServicesControllerState\n >;\n\nexport type NotificationServicesControllerUpdateMetamaskNotificationsList = {\n type: `${typeof controllerName}:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n};\n\nexport type NotificationServicesControllerDisableNotificationServices = {\n type: `${typeof controllerName}:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\nexport type NotificationServicesControllerSelectIsNotificationServicesEnabled =\n {\n type: `${typeof controllerName}:selectIsNotificationServicesEnabled`;\n handler: NotificationServicesController['selectIsNotificationServicesEnabled'];\n };\n\n// Messenger Actions\nexport type Actions =\n | NotificationServicesControllerGetStateAction\n | NotificationServicesControllerUpdateMetamaskNotificationsList\n | NotificationServicesControllerDisableNotificationServices\n | NotificationServicesControllerSelectIsNotificationServicesEnabled;\n\n// Allowed Actions\nexport type AllowedActions =\n // Keyring Controller Requests\n | KeyringControllerGetAccountsAction\n | KeyringControllerGetStateAction\n // Auth Controller Requests\n | AuthenticationController.AuthenticationControllerGetBearerToken\n | AuthenticationController.AuthenticationControllerIsSignedIn\n // User Storage Controller Requests\n | UserStorageController.UserStorageControllerEnableProfileSyncing\n | UserStorageController.UserStorageControllerGetStorageKey\n | UserStorageController.UserStorageControllerPerformGetStorage\n | UserStorageController.UserStorageControllerPerformSetStorage\n // Push Notifications Controller Requests\n | NotificationServicesPushControllerEnablePushNotifications\n | NotificationServicesPushControllerDisablePushNotifications\n | NotificationServicesPushControllerUpdateTriggerPushNotifications\n | NotificationServicesPushControllerSubscribeToNotifications;\n\n// Events\nexport type NotificationServicesControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NotificationServicesControllerState\n >;\n\nexport type NotificationListUpdatedEvent = {\n type: `${typeof controllerName}:notificationsListUpdated`;\n payload: [INotification[]];\n};\n\nexport type MarkNotificationsAsReadEvent = {\n type: `${typeof controllerName}:markNotificationsAsRead`;\n payload: [INotification[]];\n};\n\n// Events\nexport type Events =\n | NotificationServicesControllerStateChangeEvent\n | NotificationListUpdatedEvent\n | MarkNotificationsAsReadEvent;\n\n// Allowed Events\nexport type AllowedEvents =\n // Keyring Events\n | KeyringControllerStateChangeEvent\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n // Push Notification Events\n | NotificationServicesPushControllerOnNewNotification;\n\n// Type for the messenger of NotificationServicesController\nexport type NotificationServicesControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\ntype FeatureAnnouncementEnv = {\n spaceId: string;\n accessToken: string;\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Controller that enables wallet notifications and feature announcements\n */\nexport default class NotificationServicesController extends BaseController<\n typeof controllerName,\n NotificationServicesControllerState,\n NotificationServicesControllerMessenger\n> {\n // Temporary boolean as push notifications are not yet enabled on mobile\n #isPushIntegrated = true;\n\n // Flag to check is notifications have been setup when the browser/extension is initialized.\n // We want to re-initialize push notifications when the browser/extension is refreshed\n // To ensure we subscribe to the most up-to-date notifications\n #isPushNotificationsSetup = false;\n\n #isUnlocked = false;\n\n #keyringController = {\n setupLockedStateSubscriptions: (onUnlock: () => Promise<void>) => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n // messaging system cannot await promises\n // we don't need to wait for a result on this.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n onUnlock();\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n #auth = {\n getBearerToken: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n },\n isSignedIn: () => {\n return this.messagingSystem.call('AuthenticationController:isSignedIn');\n },\n };\n\n #storage = {\n enableProfileSyncing: async () => {\n return await this.messagingSystem.call(\n 'UserStorageController:enableProfileSyncing',\n );\n },\n getStorageKey: () => {\n return this.messagingSystem.call('UserStorageController:getStorageKey');\n },\n getNotificationStorage: async () => {\n return await this.messagingSystem.call(\n 'UserStorageController:performGetStorage',\n 'notifications.notificationSettings',\n );\n },\n setNotificationStorage: async (state: string) => {\n return await this.messagingSystem.call(\n 'UserStorageController:performSetStorage',\n 'notifications.notificationSettings',\n state,\n );\n },\n };\n\n #pushNotifications = {\n subscribeToPushNotifications: async () => {\n await this.messagingSystem.call(\n 'NotificationServicesPushController:subscribeToPushNotifications',\n );\n },\n enablePushNotifications: async (UUIDs: string[]) => {\n if (!this.#isPushIntegrated) {\n return;\n }\n try {\n await this.messagingSystem.call(\n 'NotificationServicesPushController:enablePushNotifications',\n UUIDs,\n );\n } catch (e) {\n log.error('Silently failed to enable push notifications', e);\n }\n },\n disablePushNotifications: async (UUIDs: string[]) => {\n if (!this.#isPushIntegrated) {\n return;\n }\n try {\n await this.messagingSystem.call(\n 'NotificationServicesPushController:disablePushNotifications',\n UUIDs,\n );\n } catch (e) {\n log.error('Silently failed to disable push notifications', e);\n }\n },\n updatePushNotifications: async (UUIDs: string[]) => {\n if (!this.#isPushIntegrated) {\n return;\n }\n try {\n await this.messagingSystem.call(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n UUIDs,\n );\n } catch (e) {\n log.error('Silently failed to update push notifications', e);\n }\n },\n subscribe: () => {\n if (!this.#isPushIntegrated) {\n return;\n }\n this.messagingSystem.subscribe(\n 'NotificationServicesPushController:onNewNotifications',\n (notification) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.updateMetamaskNotificationsList(notification);\n },\n );\n },\n initializePushNotifications: async () => {\n if (!this.#isPushIntegrated) {\n return;\n }\n if (!this.state.isNotificationServicesEnabled) {\n return;\n }\n if (this.#isPushNotificationsSetup) {\n return;\n }\n\n // If wallet is unlocked, we can create a fresh push subscription\n // Otherwise we can subscribe to original subscription\n if (this.#isUnlocked) {\n const storage = await this.#getUserStorage();\n if (!storage) {\n return;\n }\n\n const uuids = Utils.getAllUUIDs(storage);\n await this.#pushNotifications.enablePushNotifications(uuids);\n this.#isPushNotificationsSetup = true;\n } else {\n await this.#pushNotifications.subscribeToPushNotifications();\n }\n },\n };\n\n #accounts = {\n /**\n * Used to get list of addresses from keyring (wallet addresses)\n *\n * @returns addresses removed, added, and latest list of addresses\n */\n listAccounts: async () => {\n // Get previous and current account sets\n const nonChecksumAccounts = await this.messagingSystem.call(\n 'KeyringController:getAccounts',\n );\n const accounts = nonChecksumAccounts.map((a) => toChecksumHexAddress(a));\n const currentAccountsSet = new Set(accounts);\n const prevAccountsSet = new Set(this.state.subscriptionAccountsSeen);\n\n // Invalid value you cannot have zero accounts\n // Only occurs when the Accounts controller is initializing.\n if (accounts.length === 0) {\n return {\n accountsAdded: [],\n accountsRemoved: [],\n accounts: [],\n };\n }\n\n // Calculate added and removed addresses\n const accountsAdded = accounts.filter((a) => !prevAccountsSet.has(a));\n const accountsRemoved = [...prevAccountsSet.values()].filter(\n (a) => !currentAccountsSet.has(a),\n );\n\n // Update accounts seen\n this.update((state) => {\n state.subscriptionAccountsSeen = [...prevAccountsSet, ...accountsAdded];\n });\n\n return {\n accountsAdded,\n accountsRemoved,\n accounts,\n };\n },\n\n /**\n * Initializes the cache/previous list. This is handy so we have an accurate in-mem state of the previous list of accounts.\n *\n * @returns result from list accounts\n */\n initialize: () => {\n return this.#accounts.listAccounts();\n },\n\n /**\n * Subscription to any state change in the keyring controller (aka wallet accounts).\n * We can call the `listAccounts` defined above to find out about any accounts added, removed\n * And call effects to subscribe/unsubscribe to notifications.\n */\n subscribe: () => {\n this.messagingSystem.subscribe(\n 'KeyringController:stateChange',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async () => {\n if (!this.state.isNotificationServicesEnabled) {\n return;\n }\n\n const { accountsAdded, accountsRemoved } =\n await this.#accounts.listAccounts();\n\n const promises: Promise<unknown>[] = [];\n if (accountsAdded.length > 0) {\n promises.push(this.updateOnChainTriggersByAccount(accountsAdded));\n }\n if (accountsRemoved.length > 0) {\n promises.push(this.deleteOnChainTriggersByAccount(accountsRemoved));\n }\n await Promise.all(promises);\n },\n );\n },\n };\n\n #featureAnnouncementEnv: FeatureAnnouncementEnv;\n\n /**\n * Creates a NotificationServicesController instance.\n *\n * @param args - The arguments to this function.\n * @param args.messenger - Messenger used to communicate with BaseV2 controller.\n * @param args.state - Initial state to set on this controller.\n * @param args.env - environment variables for a given controller.\n * @param args.env.featureAnnouncements - env variables for feature announcements.\n * @param args.env.isPushIntegrated - toggle push notifications on/off if client has integrated them.\n */\n constructor({\n messenger,\n state,\n env,\n }: {\n messenger: NotificationServicesControllerMessenger;\n state?: Partial<NotificationServicesControllerState>;\n env: {\n featureAnnouncements: FeatureAnnouncementEnv;\n isPushIntegrated?: boolean;\n };\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#isPushIntegrated = env.isPushIntegrated ?? true;\n this.#featureAnnouncementEnv = env.featureAnnouncements;\n this.#registerMessageHandlers();\n this.#clearLoadingStates();\n\n this.#keyringController.setupLockedStateSubscriptions(\n this.#pushNotifications.initializePushNotifications,\n );\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#accounts.initialize();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#pushNotifications.initializePushNotifications();\n this.#accounts.subscribe();\n this.#pushNotifications.subscribe();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n `${controllerName}:updateMetamaskNotificationsList`,\n this.updateMetamaskNotificationsList.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:disableNotificationServices`,\n this.disableNotificationServices.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:selectIsNotificationServicesEnabled`,\n this.selectIsNotificationServicesEnabled.bind(this),\n );\n }\n\n #clearLoadingStates(): void {\n this.update((state) => {\n state.isUpdatingMetamaskNotifications = false;\n state.isCheckingAccountsPresence = false;\n state.isFetchingMetamaskNotifications = false;\n state.isUpdatingMetamaskNotificationsAccount = [];\n });\n }\n\n #assertAuthEnabled() {\n if (!this.#auth.isSignedIn()) {\n this.update((state) => {\n state.isNotificationServicesEnabled = false;\n });\n throw new Error('User is not signed in.');\n }\n }\n\n async #getValidStorageKeyAndBearerToken() {\n this.#assertAuthEnabled();\n\n const bearerToken = await this.#auth.getBearerToken();\n const storageKey = await this.#storage.getStorageKey();\n\n if (!bearerToken || !storageKey) {\n throw new Error('Missing BearerToken or storage key');\n }\n\n return { bearerToken, storageKey };\n }\n\n #performEnableProfileSyncing = async () => {\n try {\n await this.#storage.enableProfileSyncing();\n } catch (e) {\n log.error('Failed to enable profile syncing', e);\n throw new Error('Failed to enable profile syncing');\n }\n };\n\n #assertUserStorage(\n storage: UserStorage | null,\n ): asserts storage is UserStorage {\n if (!storage) {\n throw new Error('User Storage does not exist');\n }\n }\n\n /**\n * Retrieves and parses the user storage from the storage key.\n *\n * This method attempts to retrieve the user storage using the specified storage key,\n * then parses the JSON string to an object. If the storage is not found or cannot be parsed,\n * it throws an error.\n *\n * @returns The parsed user storage object or null\n */\n async #getUserStorage(): Promise<UserStorage | null> {\n const userStorageString: string | null =\n await this.#storage.getNotificationStorage();\n\n if (!userStorageString) {\n return null;\n }\n\n try {\n const userStorage: UserStorage = JSON.parse(userStorageString);\n return userStorage;\n } catch (error) {\n log.error('Unable to parse User Storage');\n return null;\n }\n }\n\n /**\n * Retrieves the current enabled state of MetaMask notifications.\n *\n * This method directly returns the boolean value of `isMetamaskNotificationsEnabled`\n * from the controller's state, indicating whether MetaMask notifications are currently enabled.\n *\n * @returns The enabled state of MetaMask notifications.\n */\n public selectIsNotificationServicesEnabled(): boolean {\n return this.state.isNotificationServicesEnabled;\n }\n\n /**\n * Sets the state of notification creation process.\n *\n * This method updates the `isUpdatingMetamaskNotifications` state, which can be used to indicate\n * whether the notification creation process is currently active or not. This is useful\n * for UI elements that need to reflect the state of ongoing operations, such as loading\n * indicators or disabled buttons during processing.\n *\n * @param isUpdatingMetamaskNotifications - A boolean value representing the new state of the notification creation process.\n */\n #setIsUpdatingMetamaskNotifications(\n isUpdatingMetamaskNotifications: boolean,\n ) {\n this.update((state) => {\n state.isUpdatingMetamaskNotifications = isUpdatingMetamaskNotifications;\n });\n }\n\n /**\n * Updates the state to indicate whether fetching of MetaMask notifications is in progress.\n *\n * This method is used to set the `isFetchingMetamaskNotifications` state, which can be utilized\n * to show or hide loading indicators in the UI when notifications are being fetched.\n *\n * @param isFetchingMetamaskNotifications - A boolean value representing the fetching state.\n */\n #setIsFetchingMetamaskNotifications(\n isFetchingMetamaskNotifications: boolean,\n ) {\n this.update((state) => {\n state.isFetchingMetamaskNotifications = isFetchingMetamaskNotifications;\n });\n }\n\n /**\n * Updates the state to indicate that the checking of accounts presence is in progress.\n *\n * This method modifies the `isCheckingAccountsPresence` state, which can be used to manage UI elements\n * that depend on the status of account presence checks, such as displaying loading indicators or disabling\n * buttons while the check is ongoing.\n *\n * @param isCheckingAccountsPresence - A boolean value indicating whether the account presence check is currently active.\n */\n #setIsCheckingAccountsPresence(isCheckingAccountsPresence: boolean) {\n this.update((state) => {\n state.isCheckingAccountsPresence = isCheckingAccountsPresence;\n });\n }\n\n /**\n * Updates the state to indicate that account updates are in progress.\n * Removes duplicate accounts before updating the state.\n *\n * @param accounts - The accounts being updated.\n */\n #updateUpdatingAccountsState(accounts: string[]) {\n this.update((state) => {\n const uniqueAccounts = new Set([\n ...state.isUpdatingMetamaskNotificationsAccount,\n ...accounts,\n ]);\n state.isUpdatingMetamaskNotificationsAccount = Array.from(uniqueAccounts);\n });\n }\n\n /**\n * Clears the state indicating that account updates are complete.\n *\n * @param accounts - The accounts that have finished updating.\n */\n #clearUpdatingAccountsState(accounts: string[]) {\n this.update((state) => {\n state.isUpdatingMetamaskNotificationsAccount =\n state.isUpdatingMetamaskNotificationsAccount.filter(\n (existingAccount) => !accounts.includes(existingAccount),\n );\n });\n }\n\n public async checkAccountsPresence(\n accounts: string[],\n ): Promise<Record<string, boolean>> {\n try {\n this.#setIsCheckingAccountsPresence(true);\n\n // Retrieve user storage\n const userStorage = await this.#getUserStorage();\n this.#assertUserStorage(userStorage);\n\n const presence = Utils.checkAccountsPresence(userStorage, accounts);\n return presence;\n } catch (error) {\n log.error('Failed to check accounts presence', error);\n throw error;\n } finally {\n this.#setIsCheckingAccountsPresence(false);\n }\n }\n\n /**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\n public async setFeatureAnnouncementsEnabled(\n featureAnnouncementsEnabled: boolean,\n ) {\n try {\n this.update((s) => {\n s.isFeatureAnnouncementsEnabled = featureAnnouncementsEnabled;\n });\n } catch (e) {\n log.error('Unable to toggle feature announcements', e);\n throw new Error('Unable to toggle feature announcements');\n }\n }\n\n /**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\n public async createOnChainTriggers(): Promise<UserStorage> {\n try {\n this.#setIsUpdatingMetamaskNotifications(true);\n\n await this.#performEnableProfileSyncing();\n\n const { bearerToken, storageKey } =\n await this.#getValidStorageKeyAndBearerToken();\n\n const { accounts } = await this.#accounts.listAccounts();\n\n let userStorage = await this.#getUserStorage();\n\n // If userStorage does not exist, create a new one\n // All the triggers created are set as: \"disabled\"\n if (userStorage?.[USER_STORAGE_VERSION_KEY] === undefined) {\n userStorage = Utils.initializeUserStorage(\n accounts.map((account) => ({ address: account })),\n false,\n );\n\n // Write the userStorage\n await this.#storage.setNotificationStorage(JSON.stringify(userStorage));\n }\n\n // Create the triggers\n const triggers = Utils.traverseUserStorageTriggers(userStorage);\n await OnChainNotifications.createOnChainTriggers(\n userStorage,\n storageKey,\n bearerToken,\n triggers,\n );\n\n // Create push notifications triggers\n const allUUIDS = Utils.getAllUUIDs(userStorage);\n await this.#pushNotifications.enablePushNotifications(allUUIDS);\n\n // Write the new userStorage (triggers are now \"enabled\")\n await this.#storage.setNotificationStorage(JSON.stringify(userStorage));\n\n // Update the state of the controller\n this.update((state) => {\n state.isNotificationServicesEnabled = true;\n state.isFeatureAnnouncementsEnabled = true;\n state.isMetamaskNotificationsFeatureSeen = true;\n });\n\n return userStorage;\n } catch (err) {\n log.error('Failed to create On Chain triggers', err);\n throw new Error('Failed to create On Chain triggers');\n } finally {\n this.#setIsUpdatingMetamaskNotifications(false);\n }\n }\n\n /**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n * 1. Enable Profile Syncing\n * 2. Get or Create Notification User Storage\n * 3. Upsert Triggers\n * 4. Update Push notifications\n *\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\n public async enableMetamaskNotifications() {\n try {\n this.#setIsUpdatingMetamaskNotifications(true);\n await this.createOnChainTriggers();\n } catch (e) {\n log.error('Unable to enable notifications', e);\n throw new Error('Unable to enable notifications');\n } finally {\n this.#setIsUpdatingMetamaskNotifications(false);\n }\n }\n\n /**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\n public async disableNotificationServices() {\n try {\n this.#setIsUpdatingMetamaskNotifications(true);\n\n // Disable Push Notifications\n const userStorage = await this.#getUserStorage();\n this.#assertUserStorage(userStorage);\n const UUIDs = Utils.getAllUUIDs(userStorage);\n await this.#pushNotifications.disablePushNotifications(UUIDs);\n\n // Clear Notification States (toggles and list)\n this.update((state) => {\n state.isNotificationServicesEnabled = false;\n state.isFeatureAnnouncementsEnabled = false;\n state.metamaskNotificationsList = [];\n });\n } catch (e) {\n log.error('Unable to disable notifications', e);\n throw new Error('Unable to disable notifications');\n } finally {\n this.#setIsUpdatingMetamaskNotifications(false);\n }\n }\n\n /**\n * Deletes on-chain triggers associated with a specific account.\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and deletes all triggers associated with the account\n * 3. Disables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\n public async deleteOnChainTriggersByAccount(\n accounts: string[],\n ): Promise<UserStorage> {\n try {\n this.#updateUpdatingAccountsState(accounts);\n // Get and Validate BearerToken and User Storage Key\n const { bearerToken, storageKey } =\n await this.#getValidStorageKeyAndBearerToken();\n\n // Get & Validate User Storage\n const userStorage = await this.#getUserStorage();\n this.#assertUserStorage(userStorage);\n\n // Get the UUIDs to delete\n const UUIDs = accounts\n .map((a) => Utils.getUUIDsForAccount(userStorage, a.toLowerCase()))\n .flat();\n\n if (UUIDs.length === 0) {\n return userStorage;\n }\n\n // Delete these UUIDs (Mutates User Storage)\n await OnChainNotifications.deleteOnChainTriggers(\n userStorage,\n storageKey,\n bearerToken,\n UUIDs,\n );\n\n // Delete these UUIDs from the push notifications\n await this.#pushNotifications.disablePushNotifications(UUIDs);\n\n // Update User Storage\n await this.#storage.setNotificationStorage(JSON.stringify(userStorage));\n return userStorage;\n } catch (err) {\n log.error('Failed to delete OnChain triggers', err);\n throw new Error('Failed to delete OnChain triggers');\n } finally {\n this.#clearUpdatingAccountsState(accounts);\n }\n }\n\n /**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\n public async updateOnChainTriggersByAccount(\n accounts: string[],\n ): Promise<UserStorage> {\n try {\n this.#updateUpdatingAccountsState(accounts);\n // Get and Validate BearerToken and User Storage Key\n const { bearerToken, storageKey } =\n await this.#getValidStorageKeyAndBearerToken();\n\n // Get & Validate User Storage\n const userStorage = await this.#getUserStorage();\n this.#assertUserStorage(userStorage);\n\n // Add any missing triggers\n accounts.forEach((a) => Utils.upsertAddressTriggers(a, userStorage));\n\n const newTriggers = Utils.traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => {\n if (!t.enabled) {\n return t;\n }\n return undefined;\n },\n });\n\n // Create any missing triggers.\n if (newTriggers.length > 0) {\n // Write te updated userStorage (where triggers are disabled)\n await this.#storage.setNotificationStorage(JSON.stringify(userStorage));\n\n // Create the triggers\n const triggers = Utils.traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => {\n if (\n accounts.some((a) => a.toLowerCase() === t.address.toLowerCase())\n ) {\n return t;\n }\n return undefined;\n },\n });\n await OnChainNotifications.createOnChainTriggers(\n userStorage,\n storageKey,\n bearerToken,\n triggers,\n );\n }\n\n // Update Push Notifications Triggers\n const UUIDs = Utils.getAllUUIDs(userStorage);\n await this.#pushNotifications.updatePushNotifications(UUIDs);\n\n // Update the userStorage (where triggers are enabled)\n await this.#storage.setNotificationStorage(JSON.stringify(userStorage));\n return userStorage;\n } catch (err) {\n log.error('Failed to update OnChain triggers', err);\n throw new Error('Failed to update OnChain triggers');\n } finally {\n this.#clearUpdatingAccountsState(accounts);\n }\n }\n\n /**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications and Feature Announcements.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\n public async fetchAndUpdateMetamaskNotifications(): Promise<INotification[]> {\n try {\n this.#setIsFetchingMetamaskNotifications(true);\n\n // Raw Feature Notifications\n const rawFeatureAnnouncementNotifications = this.state\n .isFeatureAnnouncementsEnabled\n ? await FeatureNotifications.getFeatureAnnouncementNotifications(\n this.#featureAnnouncementEnv,\n ).catch(() => [])\n : [];\n\n // Raw On Chain Notifications\n const rawOnChainNotifications: OnChainRawNotification[] = [];\n const userStorage = await this.#storage\n .getNotificationStorage()\n .then((s) => s && (JSON.parse(s) as UserStorage))\n .catch(() => null);\n const bearerToken = await this.#auth.getBearerToken().catch(() => null);\n if (userStorage && bearerToken) {\n const notifications =\n await OnChainNotifications.getOnChainNotifications(\n userStorage,\n bearerToken,\n ).catch(() => []);\n\n rawOnChainNotifications.push(...notifications);\n }\n\n const readIds = this.state.metamaskNotificationsReadList;\n\n // Combined Notifications\n const isNotUndefined = <Item>(t?: Item): t is Item => Boolean(t);\n const processAndFilter = (ns: NotificationUnion[]) =>\n ns\n .map((n) => safeProcessNotification(n, readIds))\n .filter(isNotUndefined);\n\n const featureAnnouncementNotifications = processAndFilter(\n rawFeatureAnnouncementNotifications,\n );\n const onChainNotifications = processAndFilter(rawOnChainNotifications);\n\n const metamaskNotifications: INotification[] = [\n ...featureAnnouncementNotifications,\n ...onChainNotifications,\n ];\n metamaskNotifications.sort(\n (a, b) =>\n new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),\n );\n\n // Update State\n this.update((state) => {\n state.metamaskNotificationsList = metamaskNotifications;\n });\n\n this.messagingSystem.publish(\n `${controllerName}:notificationsListUpdated`,\n this.state.metamaskNotificationsList,\n );\n\n this.#setIsFetchingMetamaskNotifications(false);\n return metamaskNotifications;\n } catch (err) {\n this.#setIsFetchingMetamaskNotifications(false);\n log.error('Failed to fetch notifications', err);\n throw new Error('Failed to fetch notifications');\n }\n }\n\n /**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\n public async markMetamaskNotificationsAsRead(\n notifications: MarkAsReadNotificationsParam,\n ): Promise<void> {\n let onchainNotificationIds: string[] = [];\n let featureAnnouncementNotificationIds: string[] = [];\n\n try {\n // Filter unread on/off chain notifications\n const onChainNotifications = notifications.filter(\n (notification) =>\n notification.type !== TRIGGER_TYPES.FEATURES_ANNOUNCEMENT &&\n !notification.isRead,\n );\n\n const featureAnnouncementNotifications = notifications.filter(\n (notification) =>\n notification.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT &&\n !notification.isRead,\n );\n\n // Mark On-Chain Notifications as Read\n if (onChainNotifications.length > 0) {\n const bearerToken = await this.#auth.getBearerToken();\n\n if (bearerToken) {\n onchainNotificationIds = onChainNotifications.map(\n (notification) => notification.id,\n );\n await OnChainNotifications.markNotificationsAsRead(\n bearerToken,\n onchainNotificationIds,\n ).catch(() => {\n onchainNotificationIds = [];\n log.warn('Unable to mark onchain notifications as read');\n });\n }\n }\n\n // Mark Off-Chain notifications as Read\n if (featureAnnouncementNotifications.length > 0) {\n featureAnnouncementNotificationIds =\n featureAnnouncementNotifications.map(\n (notification) => notification.id,\n );\n }\n } catch (err) {\n log.warn('Something failed when marking notifications as read', err);\n }\n\n // Update the state (state is also used on counter & badge)\n this.update((state) => {\n const currentReadList = state.metamaskNotificationsReadList;\n const newReadIds = [...featureAnnouncementNotificationIds];\n state.metamaskNotificationsReadList = [\n ...new Set([...currentReadList, ...newReadIds]),\n ];\n\n state.metamaskNotificationsList = state.metamaskNotificationsList.map(\n (notification: INotification) => {\n if (\n newReadIds.includes(notification.id) ||\n onchainNotificationIds.includes(notification.id)\n ) {\n return { ...notification, isRead: true };\n }\n return notification;\n },\n );\n });\n\n this.messagingSystem.publish(\n `${controllerName}:markNotificationsAsRead`,\n this.state.metamaskNotificationsList,\n );\n }\n\n /**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\n public async updateMetamaskNotificationsList(\n notification: INotification,\n ): Promise<void> {\n if (\n this.state.metamaskNotificationsList.some((n) => n.id === notification.id)\n ) {\n return;\n }\n\n const processedNotification = safeProcessNotification(notification);\n\n if (processedNotification) {\n this.update((state) => {\n const existingNotificationIds = new Set(\n state.metamaskNotificationsList.map((n) => n.id),\n );\n // Add the new notification only if its ID is not already present in the list\n if (!existingNotificationIds.has(notification.id)) {\n state.metamaskNotificationsList = [\n notification,\n ...state.metamaskNotificationsList,\n ];\n this.messagingSystem.publish(\n `${controllerName}:notificationsListUpdated`,\n state.metamaskNotificationsList,\n );\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAYrC,OAAO,SAAS;AA4ChB,IAAM,iBAAiB;AAwDvB,IAAM,WAA+D;AAAA,EACnE,0BAA0B;AAAA,IACxB,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EAEA,oCAAoC;AAAA,IAClC,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,+BAA+B;AAAA,IAC7B,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,+BAA+B;AAAA,IAC7B,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,2BAA2B;AAAA,IACzB,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,+BAA+B;AAAA,IAC7B,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,iCAAiC;AAAA,IAC/B,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,iCAAiC;AAAA,IAC/B,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,wCAAwC;AAAA,IACtC,SAAS;AAAA,IACT,W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C,4BAAqC;AAClE,OAAK,OAAO,CAAC,UAAU;AACrB,UAAM,6BAA6B;AAAA,EACrC,CAAC;AACH;AAQA;AAAA,iCAA4B,SAAC,UAAoB;AAC/C,OAAK,OAAO,CAAC,UAAU;AACrB,UAAM,iBAAiB,oBAAI,IAAI;AAAA,MAC7B,GAAG,MAAM;AAAA,MACT,GAAG;AAAA,IACL,CAAC;AACD,UAAM,yCAAyC,MAAM,KAAK,cAAc;AAAA,EAC1E,CAAC;AACH;AAOA;AAAA,gCAA2B,SAAC,UAAoB;AAC9C,OAAK,OAAO,CAAC,UAAU;AACrB,UAAM,yCACJ,MAAM,uCAAuC;AAAA,MAC3C,CAAC,oBAAoB,CAAC,SAAS,SAAS,eAAe;AAAA,IACzD;AAAA,EACJ,CAAC;AACH;","names":[]}
@@ -1,207 +0,0 @@
1
- import {
2
- formatAmount,
3
- getAmount
4
- } from "./chunk-ODI2BTKS.mjs";
5
- import {
6
- constants_exports
7
- } from "./chunk-2P5WP5NT.mjs";
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 = getAmount(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 = formatAmount(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 = getAmount(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 = formatAmount(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 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
- export {
203
- createOnChainPushNotificationMessages,
204
- isOnChainNotification,
205
- createOnChainPushNotificationMessage
206
- };
207
- //# sourceMappingURL=chunk-WGBEAP2F.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/NotificationServicesPushController/utils/get-notification-message.ts"],"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"],"mappings":";;;;;;;;;AA4DO,IAAM,wCAAwC,CACnD,oBAC4B;AAI5B,QAAM,IAAmB,IAAI,SAAS;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AAAA;AAAA,EAC9B;AACF;","names":[]}
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-WRYFIWNK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-XZEVRYUE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,221 +0,0 @@
1
- import {
2
- TRIGGERS
3
- } from "./chunk-53F3SYYM.mjs";
4
- import {
5
- USER_STORAGE_VERSION,
6
- USER_STORAGE_VERSION_KEY
7
- } from "./chunk-6ZDVTRRT.mjs";
8
-
9
- // src/NotificationServicesController/utils/utils.ts
10
- import { v4 as uuidv4 } from "uuid";
11
- var triggerToId = (trigger) => trigger.id;
12
- var triggerIdentity = (trigger) => trigger;
13
- function initializeUserStorage(accounts, state) {
14
- const userStorage = {
15
- [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION
16
- };
17
- accounts.forEach((account) => {
18
- const address = account.address?.toLowerCase();
19
- if (!address) {
20
- return;
21
- }
22
- if (!userStorage[address]) {
23
- userStorage[address] = {};
24
- }
25
- Object.entries(TRIGGERS).forEach(
26
- ([trigger, { supported_chains: supportedChains }]) => {
27
- supportedChains.forEach((chain) => {
28
- if (!userStorage[address]?.[chain]) {
29
- userStorage[address][chain] = {};
30
- }
31
- userStorage[address][chain][uuidv4()] = {
32
- k: trigger,
33
- // use 'k' instead of 'kind' to reduce the json weight
34
- e: state
35
- // use 'e' instead of 'enabled' to reduce the json weight
36
- };
37
- });
38
- }
39
- );
40
- });
41
- return userStorage;
42
- }
43
- function traverseUserStorageTriggers(userStorage, options) {
44
- const triggers = [];
45
- const mapTrigger = options?.mapTrigger ?? triggerIdentity;
46
- for (const address in userStorage) {
47
- if (address === USER_STORAGE_VERSION_KEY) {
48
- continue;
49
- }
50
- if (options?.address && address !== options.address) {
51
- continue;
52
- }
53
- for (const chainId in userStorage[address]) {
54
- if (chainId in userStorage[address]) {
55
- for (const uuid in userStorage[address][chainId]) {
56
- if (uuid) {
57
- const mappedTrigger = mapTrigger({
58
- id: uuid,
59
- kind: userStorage[address]?.[chainId]?.[uuid]?.k,
60
- chainId,
61
- address,
62
- enabled: userStorage[address]?.[chainId]?.[uuid]?.e ?? false
63
- });
64
- if (mappedTrigger) {
65
- triggers.push(mappedTrigger);
66
- }
67
- }
68
- }
69
- }
70
- }
71
- }
72
- return triggers;
73
- }
74
- function checkAccountsPresence(userStorage, accounts) {
75
- const presenceRecord = {};
76
- accounts.forEach((account) => {
77
- presenceRecord[account.toLowerCase()] = isAccountEnabled(
78
- account,
79
- userStorage
80
- );
81
- });
82
- return presenceRecord;
83
- }
84
- function isAccountEnabled(accountAddress, userStorage) {
85
- const accountObject = userStorage[accountAddress?.toLowerCase()];
86
- if (!accountObject) {
87
- return false;
88
- }
89
- for (const [triggerKind, triggerConfig] of Object.entries(TRIGGERS)) {
90
- for (const chain of triggerConfig.supported_chains) {
91
- if (!accountObject[chain]) {
92
- return false;
93
- }
94
- const triggerExists = Object.values(accountObject[chain]).some(
95
- (obj) => obj.k === triggerKind
96
- );
97
- if (!triggerExists) {
98
- return false;
99
- }
100
- for (const uuid in accountObject[chain]) {
101
- if (!accountObject[chain][uuid].e) {
102
- return false;
103
- }
104
- }
105
- }
106
- }
107
- return true;
108
- }
109
- function inferEnabledKinds(userStorage) {
110
- const allSupportedKinds = /* @__PURE__ */ new Set();
111
- traverseUserStorageTriggers(userStorage, {
112
- mapTrigger: (t) => {
113
- allSupportedKinds.add(t.kind);
114
- }
115
- });
116
- return Array.from(allSupportedKinds);
117
- }
118
- function getUUIDsForAccount(userStorage, address) {
119
- return traverseUserStorageTriggers(userStorage, {
120
- address,
121
- mapTrigger: triggerToId
122
- });
123
- }
124
- function getAllUUIDs(userStorage) {
125
- return traverseUserStorageTriggers(userStorage, {
126
- mapTrigger: triggerToId
127
- });
128
- }
129
- function getUUIDsForKinds(userStorage, allowedKinds) {
130
- const kindsSet = new Set(allowedKinds);
131
- return traverseUserStorageTriggers(userStorage, {
132
- mapTrigger: (t) => kindsSet.has(t.kind) ? t.id : void 0
133
- });
134
- }
135
- function getUUIDsForAccountByKinds(userStorage, address, allowedKinds) {
136
- const allowedKindsSet = new Set(allowedKinds);
137
- return traverseUserStorageTriggers(userStorage, {
138
- address,
139
- mapTrigger: (trigger) => {
140
- if (allowedKindsSet.has(trigger.kind)) {
141
- return trigger;
142
- }
143
- return void 0;
144
- }
145
- });
146
- }
147
- function upsertAddressTriggers(_account, userStorage) {
148
- const account = _account.toLowerCase();
149
- userStorage[account] = userStorage[account] || {};
150
- for (const [trigger, { supported_chains: supportedChains }] of Object.entries(
151
- TRIGGERS
152
- )) {
153
- for (const chain of supportedChains) {
154
- userStorage[account][chain] = userStorage[account][chain] || {};
155
- const existingTrigger = Object.values(userStorage[account][chain]).find(
156
- (obj) => obj.k === trigger
157
- );
158
- if (!existingTrigger) {
159
- const uuid = uuidv4();
160
- userStorage[account][chain][uuid] = {
161
- k: trigger,
162
- e: false
163
- };
164
- }
165
- }
166
- }
167
- return userStorage;
168
- }
169
- function upsertTriggerTypeTriggers(triggerType, userStorage) {
170
- Object.entries(userStorage).forEach(([account, chains]) => {
171
- if (account === USER_STORAGE_VERSION_KEY) {
172
- return;
173
- }
174
- Object.entries(chains).forEach(([chain, triggers]) => {
175
- const existingTrigger = Object.values(triggers).find(
176
- (obj) => obj.k === triggerType
177
- );
178
- if (!existingTrigger) {
179
- const uuid = uuidv4();
180
- userStorage[account][chain][uuid] = {
181
- k: triggerType,
182
- e: false
183
- };
184
- }
185
- });
186
- });
187
- return userStorage;
188
- }
189
- function toggleUserStorageTriggerStatus(userStorage, address, chainId, uuid, enabled) {
190
- if (userStorage?.[address]?.[chainId]?.[uuid]) {
191
- userStorage[address][chainId][uuid].e = enabled;
192
- }
193
- return userStorage;
194
- }
195
- async function makeApiCall(bearerToken, endpoint, method, body) {
196
- const options = {
197
- method,
198
- headers: {
199
- "Content-Type": "application/json",
200
- Authorization: `Bearer ${bearerToken}`
201
- },
202
- body: JSON.stringify(body)
203
- };
204
- return await fetch(endpoint, options);
205
- }
206
-
207
- export {
208
- initializeUserStorage,
209
- traverseUserStorageTriggers,
210
- checkAccountsPresence,
211
- inferEnabledKinds,
212
- getUUIDsForAccount,
213
- getAllUUIDs,
214
- getUUIDsForKinds,
215
- getUUIDsForAccountByKinds,
216
- upsertAddressTriggers,
217
- upsertTriggerTypeTriggers,
218
- toggleUserStorageTriggerStatus,
219
- makeApiCall
220
- };
221
- //# sourceMappingURL=chunk-YUMIJSUD.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/NotificationServicesController/utils/utils.ts"],"sourcesContent":["import { 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 * 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 * @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): 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 await fetch(endpoint, options);\n}\n"],"mappings":";;;;;;;;;AAAA,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,YACt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