@metamask-previews/notification-services-controller 0.21.0-preview-1cc9329c → 1.0.0-preview-95a6811

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 (254) hide show
  1. package/CHANGELOG.md +22 -3
  2. package/README.md +35 -1
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs +66 -77
  4. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts +10 -34
  6. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts +10 -34
  8. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs +66 -77
  10. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  11. package/dist/NotificationServicesController/index.cjs +2 -1
  12. package/dist/NotificationServicesController/index.cjs.map +1 -1
  13. package/dist/NotificationServicesController/index.d.cts +2 -1
  14. package/dist/NotificationServicesController/index.d.cts.map +1 -1
  15. package/dist/NotificationServicesController/index.d.mts +2 -1
  16. package/dist/NotificationServicesController/index.d.mts.map +1 -1
  17. package/dist/NotificationServicesController/index.mjs +2 -1
  18. package/dist/NotificationServicesController/index.mjs.map +1 -1
  19. package/dist/NotificationServicesController/mocks/index.cjs.map +1 -0
  20. package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -0
  21. package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -0
  22. package/dist/NotificationServicesController/mocks/index.mjs.map +1 -0
  23. package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs.map +1 -0
  24. package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.cts.map +1 -0
  25. package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.mts.map +1 -0
  26. package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs.map +1 -0
  27. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +1 -0
  28. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +1 -0
  29. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +1 -0
  30. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +1 -0
  31. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +1 -0
  32. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +1 -0
  33. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +1 -0
  34. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +1 -0
  35. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -0
  36. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -0
  37. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -0
  38. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -0
  39. package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs.map +1 -0
  40. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts.map +1 -0
  41. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts.map +1 -0
  42. package/dist/NotificationServicesController/mocks/mock-snap-notification.mjs.map +1 -0
  43. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -0
  44. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -0
  45. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -0
  46. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -0
  47. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +95 -46
  48. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  49. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +17 -17
  50. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  51. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +17 -17
  52. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  53. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +96 -47
  54. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  55. package/dist/NotificationServicesPushController/index.cjs +1 -1
  56. package/dist/NotificationServicesPushController/index.cjs.map +1 -1
  57. package/dist/NotificationServicesPushController/index.d.cts +1 -1
  58. package/dist/NotificationServicesPushController/index.d.cts.map +1 -1
  59. package/dist/NotificationServicesPushController/index.d.mts +1 -1
  60. package/dist/NotificationServicesPushController/index.d.mts.map +1 -1
  61. package/dist/NotificationServicesPushController/index.mjs +1 -1
  62. package/dist/NotificationServicesPushController/index.mjs.map +1 -1
  63. package/dist/NotificationServicesPushController/mocks/index.cjs.map +1 -0
  64. package/dist/NotificationServicesPushController/mocks/index.d.cts.map +1 -0
  65. package/dist/NotificationServicesPushController/mocks/index.d.mts.map +1 -0
  66. package/dist/NotificationServicesPushController/mocks/index.mjs.map +1 -0
  67. package/dist/NotificationServicesPushController/{__fixtures__/mockResponse.mjs.map → mocks/mockResponse.cjs.map} +1 -1
  68. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -0
  69. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -0
  70. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -0
  71. package/dist/NotificationServicesPushController/services/services.cjs +9 -28
  72. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  73. package/dist/NotificationServicesPushController/services/services.d.cts +2 -17
  74. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  75. package/dist/NotificationServicesPushController/services/services.d.mts +2 -17
  76. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  77. package/dist/NotificationServicesPushController/services/services.mjs +8 -26
  78. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  79. package/dist/NotificationServicesPushController/types/index.cjs.map +1 -1
  80. package/dist/NotificationServicesPushController/types/index.d.cts +1 -0
  81. package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -1
  82. package/dist/NotificationServicesPushController/types/index.d.mts +1 -0
  83. package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -1
  84. package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
  85. package/dist/NotificationServicesPushController/{services/push/index.cjs → types/push-service-interface.cjs} +1 -1
  86. package/dist/NotificationServicesPushController/types/push-service-interface.cjs.map +1 -0
  87. package/dist/NotificationServicesPushController/types/push-service-interface.d.cts +30 -0
  88. package/dist/NotificationServicesPushController/types/push-service-interface.d.cts.map +1 -0
  89. package/dist/NotificationServicesPushController/types/push-service-interface.d.mts +30 -0
  90. package/dist/NotificationServicesPushController/types/push-service-interface.d.mts.map +1 -0
  91. package/dist/NotificationServicesPushController/types/push-service-interface.mjs +2 -0
  92. package/dist/NotificationServicesPushController/types/push-service-interface.mjs.map +1 -0
  93. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +1 -19
  94. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  95. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +0 -7
  96. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  97. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +0 -7
  98. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  99. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +0 -17
  100. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  101. package/dist/NotificationServicesPushController/web/index.cjs +8 -0
  102. package/dist/NotificationServicesPushController/web/index.cjs.map +1 -0
  103. package/dist/NotificationServicesPushController/web/index.d.cts +2 -0
  104. package/dist/NotificationServicesPushController/web/index.d.cts.map +1 -0
  105. package/dist/NotificationServicesPushController/web/index.d.mts +2 -0
  106. package/dist/NotificationServicesPushController/web/index.d.mts.map +1 -0
  107. package/dist/NotificationServicesPushController/web/index.mjs +2 -0
  108. package/dist/NotificationServicesPushController/web/index.mjs.map +1 -0
  109. package/dist/NotificationServicesPushController/web/push-utils.cjs +170 -0
  110. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -0
  111. package/dist/NotificationServicesPushController/web/push-utils.d.cts +37 -0
  112. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -0
  113. package/dist/NotificationServicesPushController/web/push-utils.d.mts +37 -0
  114. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -0
  115. package/dist/NotificationServicesPushController/web/push-utils.mjs +168 -0
  116. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -0
  117. package/dist/shared/index.cjs +19 -0
  118. package/dist/shared/index.cjs.map +1 -0
  119. package/dist/shared/index.d.cts +3 -0
  120. package/dist/shared/index.d.cts.map +1 -0
  121. package/dist/shared/index.d.mts +3 -0
  122. package/dist/shared/index.d.mts.map +1 -0
  123. package/dist/shared/index.mjs +3 -0
  124. package/dist/shared/index.mjs.map +1 -0
  125. package/dist/shared/is-onchain-notification.cjs +22 -0
  126. package/dist/shared/is-onchain-notification.cjs.map +1 -0
  127. package/dist/shared/is-onchain-notification.d.cts +9 -0
  128. package/dist/shared/is-onchain-notification.d.cts.map +1 -0
  129. package/dist/shared/is-onchain-notification.d.mts +9 -0
  130. package/dist/shared/is-onchain-notification.d.mts.map +1 -0
  131. package/dist/shared/is-onchain-notification.mjs +18 -0
  132. package/dist/shared/is-onchain-notification.mjs.map +1 -0
  133. package/notification-services/mocks/package.json +2 -2
  134. package/package.json +21 -11
  135. package/push-services/mocks/package.json +2 -2
  136. package/push-services/web/package.json +9 -0
  137. package/dist/NotificationServicesController/__fixtures__/index.cjs.map +0 -1
  138. package/dist/NotificationServicesController/__fixtures__/index.d.cts.map +0 -1
  139. package/dist/NotificationServicesController/__fixtures__/index.d.mts.map +0 -1
  140. package/dist/NotificationServicesController/__fixtures__/index.mjs.map +0 -1
  141. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.cjs.map +0 -1
  142. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.cts.map +0 -1
  143. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.mts.map +0 -1
  144. package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.mjs.map +0 -1
  145. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.cjs.map +0 -1
  146. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.cts.map +0 -1
  147. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.mts.map +0 -1
  148. package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.mjs.map +0 -1
  149. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.cjs.map +0 -1
  150. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.cts.map +0 -1
  151. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.mts.map +0 -1
  152. package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.mjs.map +0 -1
  153. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.cjs.map +0 -1
  154. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.cts.map +0 -1
  155. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.mts.map +0 -1
  156. package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.mjs.map +0 -1
  157. package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.cjs.map +0 -1
  158. package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.cts.map +0 -1
  159. package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.mts.map +0 -1
  160. package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.mjs.map +0 -1
  161. package/dist/NotificationServicesController/__fixtures__/mockAddresses.cjs +0 -6
  162. package/dist/NotificationServicesController/__fixtures__/mockAddresses.cjs.map +0 -1
  163. package/dist/NotificationServicesController/__fixtures__/mockAddresses.d.cts +0 -3
  164. package/dist/NotificationServicesController/__fixtures__/mockAddresses.d.cts.map +0 -1
  165. package/dist/NotificationServicesController/__fixtures__/mockAddresses.d.mts +0 -3
  166. package/dist/NotificationServicesController/__fixtures__/mockAddresses.d.mts.map +0 -1
  167. package/dist/NotificationServicesController/__fixtures__/mockAddresses.mjs +0 -3
  168. package/dist/NotificationServicesController/__fixtures__/mockAddresses.mjs.map +0 -1
  169. package/dist/NotificationServicesController/__fixtures__/mockResponses.cjs.map +0 -1
  170. package/dist/NotificationServicesController/__fixtures__/mockResponses.d.cts.map +0 -1
  171. package/dist/NotificationServicesController/__fixtures__/mockResponses.d.mts.map +0 -1
  172. package/dist/NotificationServicesController/__fixtures__/mockResponses.mjs.map +0 -1
  173. package/dist/NotificationServicesController/__fixtures__/mockServices.cjs +0 -56
  174. package/dist/NotificationServicesController/__fixtures__/mockServices.cjs.map +0 -1
  175. package/dist/NotificationServicesController/__fixtures__/mockServices.d.cts +0 -12
  176. package/dist/NotificationServicesController/__fixtures__/mockServices.d.cts.map +0 -1
  177. package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts +0 -12
  178. package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts.map +0 -1
  179. package/dist/NotificationServicesController/__fixtures__/mockServices.mjs +0 -52
  180. package/dist/NotificationServicesController/__fixtures__/mockServices.mjs.map +0 -1
  181. package/dist/NotificationServicesController/__fixtures__/test-utils.cjs +0 -31
  182. package/dist/NotificationServicesController/__fixtures__/test-utils.cjs.map +0 -1
  183. package/dist/NotificationServicesController/__fixtures__/test-utils.d.cts +0 -14
  184. package/dist/NotificationServicesController/__fixtures__/test-utils.d.cts.map +0 -1
  185. package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts +0 -14
  186. package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts.map +0 -1
  187. package/dist/NotificationServicesController/__fixtures__/test-utils.mjs +0 -27
  188. package/dist/NotificationServicesController/__fixtures__/test-utils.mjs.map +0 -1
  189. package/dist/NotificationServicesPushController/__fixtures__/index.cjs.map +0 -1
  190. package/dist/NotificationServicesPushController/__fixtures__/index.d.cts.map +0 -1
  191. package/dist/NotificationServicesPushController/__fixtures__/index.d.mts.map +0 -1
  192. package/dist/NotificationServicesPushController/__fixtures__/index.mjs.map +0 -1
  193. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.cjs.map +0 -1
  194. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.cts.map +0 -1
  195. package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.mts.map +0 -1
  196. package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs +0 -19
  197. package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs.map +0 -1
  198. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts +0 -8
  199. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts.map +0 -1
  200. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts +0 -8
  201. package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts.map +0 -1
  202. package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs +0 -19
  203. package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs.map +0 -1
  204. package/dist/NotificationServicesPushController/constants.cjs +0 -14
  205. package/dist/NotificationServicesPushController/constants.cjs.map +0 -1
  206. package/dist/NotificationServicesPushController/constants.d.cts +0 -11
  207. package/dist/NotificationServicesPushController/constants.d.cts.map +0 -1
  208. package/dist/NotificationServicesPushController/constants.d.mts +0 -11
  209. package/dist/NotificationServicesPushController/constants.d.mts.map +0 -1
  210. package/dist/NotificationServicesPushController/constants.mjs +0 -11
  211. package/dist/NotificationServicesPushController/constants.mjs.map +0 -1
  212. package/dist/NotificationServicesPushController/services/push/index.cjs.map +0 -1
  213. package/dist/NotificationServicesPushController/services/push/index.d.cts +0 -6
  214. package/dist/NotificationServicesPushController/services/push/index.d.cts.map +0 -1
  215. package/dist/NotificationServicesPushController/services/push/index.d.mts +0 -6
  216. package/dist/NotificationServicesPushController/services/push/index.d.mts.map +0 -1
  217. package/dist/NotificationServicesPushController/services/push/index.mjs +0 -2
  218. package/dist/NotificationServicesPushController/services/push/index.mjs.map +0 -1
  219. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.cjs +0 -0
  220. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.d.cts +0 -0
  221. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.d.mts +0 -0
  222. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.mjs +0 -0
  223. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.cjs +0 -0
  224. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.d.cts +0 -0
  225. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.d.mts +0 -0
  226. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.mjs +0 -0
  227. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.cjs +0 -0
  228. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.d.cts +0 -0
  229. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.d.mts +0 -0
  230. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.mjs +0 -0
  231. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.cjs +0 -0
  232. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.d.cts +0 -0
  233. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.d.mts +0 -0
  234. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.mjs +0 -0
  235. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.cjs +0 -0
  236. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.d.cts +0 -0
  237. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.d.mts +0 -0
  238. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.mjs +0 -0
  239. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.cjs +0 -0
  240. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.d.cts +0 -0
  241. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.d.mts +0 -0
  242. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.mjs +0 -0
  243. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.cjs +0 -0
  244. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.d.cts +0 -0
  245. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.d.mts +0 -0
  246. /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.mjs +0 -0
  247. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.cjs +0 -0
  248. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.d.cts +0 -0
  249. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.d.mts +0 -0
  250. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.mjs +0 -0
  251. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.cjs +0 -0
  252. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.d.cts +0 -0
  253. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.d.mts +0 -0
  254. /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.mjs +0 -0
@@ -0,0 +1,168 @@
1
+ function $importDefault(module) {
2
+ if (module?.__esModule) {
3
+ return module.default;
4
+ }
5
+ return module;
6
+ }
7
+ import { getApp, initializeApp } from "firebase/app";
8
+ import { getToken, deleteToken } from "firebase/messaging";
9
+ import { getMessaging, onBackgroundMessage, isSupported } from "firebase/messaging/sw";
10
+ import $log from "loglevel";
11
+ const log = $importDefault($log);
12
+ import { Processors } from "../../NotificationServicesController/index.mjs";
13
+ import { toRawOnChainNotification } from "../../shared/to-raw-notification.mjs";
14
+ // Exported to help testing
15
+ // eslint-disable-next-line import-x/no-mutable-exports
16
+ export let supportedCache = null;
17
+ const getPushAvailability = async () => {
18
+ supportedCache ?? (supportedCache = await isSupported());
19
+ return supportedCache;
20
+ };
21
+ const createFirebaseApp = async (env) => {
22
+ try {
23
+ return getApp();
24
+ }
25
+ catch {
26
+ const firebaseConfig = {
27
+ apiKey: env.apiKey,
28
+ authDomain: env.authDomain,
29
+ storageBucket: env.storageBucket,
30
+ projectId: env.projectId,
31
+ messagingSenderId: env.messagingSenderId,
32
+ appId: env.appId,
33
+ measurementId: env.measurementId,
34
+ };
35
+ return initializeApp(firebaseConfig);
36
+ }
37
+ };
38
+ const getFirebaseMessaging = async (env) => {
39
+ const supported = await getPushAvailability();
40
+ if (!supported) {
41
+ return null;
42
+ }
43
+ const app = await createFirebaseApp(env);
44
+ return getMessaging(app);
45
+ };
46
+ /**
47
+ * Creates a registration token for Firebase Cloud Messaging.
48
+ *
49
+ * @param env - env to configure push notifications
50
+ * @returns A promise that resolves with the registration token or null if an error occurs.
51
+ */
52
+ export async function createRegToken(env) {
53
+ try {
54
+ const messaging = await getFirebaseMessaging(env);
55
+ if (!messaging) {
56
+ return null;
57
+ }
58
+ const token = await getToken(messaging, {
59
+ serviceWorkerRegistration: self.registration,
60
+ vapidKey: env.vapidKey,
61
+ });
62
+ return token;
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ /**
69
+ * Deletes the Firebase Cloud Messaging registration token.
70
+ *
71
+ * @param env - env to configure push notifications
72
+ * @returns A promise that resolves with true if the token was successfully deleted, false otherwise.
73
+ */
74
+ export async function deleteRegToken(env) {
75
+ try {
76
+ const messaging = await getFirebaseMessaging(env);
77
+ if (!messaging) {
78
+ return true;
79
+ }
80
+ await deleteToken(messaging);
81
+ return true;
82
+ }
83
+ catch {
84
+ return false;
85
+ }
86
+ }
87
+ /**
88
+ * Service Worker Listener for when push notifications are received.
89
+ *
90
+ * @param env - push notification environment
91
+ * @param handler - handler to actually showing notification, MUST BE PROVIDED
92
+ * @returns unsubscribe handler
93
+ */
94
+ async function listenToPushNotificationsReceived(env, handler) {
95
+ const messaging = await getFirebaseMessaging(env);
96
+ if (!messaging) {
97
+ return null;
98
+ }
99
+ const unsubscribePushNotifications = onBackgroundMessage(messaging,
100
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
101
+ async (payload) => {
102
+ try {
103
+ const data = payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;
104
+ if (!data) {
105
+ return;
106
+ }
107
+ const notificationData = toRawOnChainNotification(data);
108
+ const notification = Processors.processNotification(notificationData);
109
+ await handler(notification);
110
+ }
111
+ catch (error) {
112
+ // Do Nothing, cannot parse a bad notification
113
+ log.error('Unable to send push notification:', {
114
+ notification: payload?.data?.data,
115
+ error,
116
+ });
117
+ throw new Error('Unable to send push notification');
118
+ }
119
+ });
120
+ const unsubscribe = () => unsubscribePushNotifications();
121
+ return unsubscribe;
122
+ }
123
+ /**
124
+ * Service Worker Listener for when a notification is clicked
125
+ *
126
+ * @param handler - listen to NotificationEvent from the service worker
127
+ * @returns unsubscribe handler
128
+ */
129
+ function listenToPushNotificationsClicked(handler) {
130
+ const clickHandler = (event) => {
131
+ // Get Data
132
+ const data = event?.notification?.data;
133
+ handler(event, data);
134
+ };
135
+ self.addEventListener('notificationclick', clickHandler);
136
+ const unsubscribe = () => self.removeEventListener('notificationclick', clickHandler);
137
+ return unsubscribe;
138
+ }
139
+ /**
140
+ * A creator function that assists creating web-specific push notification subscription:
141
+ * 1. Creates subscriptions for receiving and clicking notifications
142
+ * 2. Creates click events when a notification is clicked
143
+ * 3. Publishes controller messenger events
144
+ *
145
+ * @param props - props for this creator function.
146
+ * @param props.onReceivedHandler - allows the developer to handle showing a notification
147
+ * @param props.onClickHandler - allows the developer to handle clicking the notification
148
+ * @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events
149
+ * @returns a function that can be used by the controller
150
+ */
151
+ export function createSubscribeToPushNotifications(props) {
152
+ return async function (env) {
153
+ const onBackgroundMessageSub = await listenToPushNotificationsReceived(env, async (notification) => {
154
+ props.messenger.publish('NotificationServicesPushController:onNewNotifications', notification);
155
+ await props.onReceivedHandler(notification);
156
+ });
157
+ const onClickSub = listenToPushNotificationsClicked((event, notification) => {
158
+ props.messenger.publish('NotificationServicesPushController:pushNotificationClicked', notification);
159
+ props.onClickHandler(event, notification);
160
+ });
161
+ const unsubscribe = () => {
162
+ onBackgroundMessageSub?.();
163
+ onClickSub();
164
+ };
165
+ return unsubscribe;
166
+ };
167
+ }
168
+ //# sourceMappingURL=push-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-utils.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";;;;;;AAIA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,qBAAqB;AACrD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B;AAC3D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACZ,8BAA8B;AAE/B,OAAO,IAAG,iBAAiB;;AAG3B,OAAO,EAAE,UAAU,EAAE,uDAA6C;AAClE,OAAO,EAAE,wBAAwB,EAAE,6CAAyC;AAM5E,2BAA2B;AAC3B,uDAAuD;AACvD,MAAM,CAAC,IAAI,cAAc,GAAmB,IAAI,CAAC;AAEjD,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE;IACrC,cAAc,KAAd,cAAc,GAAK,MAAM,WAAW,EAAE,EAAC;IACvC,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAC7B,GAAwB,EACF,EAAE;IACxB,IAAI;QACF,OAAO,MAAM,EAAE,CAAC;KACjB;IAAC,MAAM;QACN,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,UAAU,EA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AI,GAAwB,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC;QAC5D,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;IAC9D,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kCAAkC,CAAC,KASlD;IACC,OAAO,KAAK,WAAW,GAAwB;QAC7C,MAAM,sBAAsB,GAAG,MAAM,iCAAiC,CACpE,GAAG,EACH,KAAK,EAAE,YAAY,EAAE,EAAE;YACrB,KAAK,CAAC,SAAS,CAAC,OAAO,CACrB,uDAAuD,EACvD,YAAY,CACb,CAAC;YACF,MAAM,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC,CACF,CAAC;QACF,MAAM,UAAU,GAAG,gCAAgC,CACjD,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;YACtB,KAAK,CAAC,SAAS,CAAC,OAAO,CACrB,4DAA4D,EAC5D,YAAY,CACb,CAAC;YACF,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC5C,CAAC,CACF,CAAC;QAEF,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,sBAAsB,EAAE,EAAE,CAAC;YAC3B,UAAU,EAAE,CAAC;QACf,CAAC,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// We are defining that this file uses a webworker global scope.\n// eslint-disable-next-line spaced-comment\n/// <reference lib=\"webworker\" />\nimport type { FirebaseApp } from 'firebase/app';\nimport { getApp, initializeApp } from 'firebase/app';\nimport { getToken, deleteToken } from 'firebase/messaging';\nimport {\n getMessaging,\n onBackgroundMessage,\n isSupported,\n} from 'firebase/messaging/sw';\nimport type { Messaging, MessagePayload } from 'firebase/messaging/sw';\nimport log from 'loglevel';\n\nimport type { Types } from '../../NotificationServicesController';\nimport { Processors } from '../../NotificationServicesController';\nimport { toRawOnChainNotification } from '../../shared/to-raw-notification';\nimport type { NotificationServicesPushControllerMessenger } from '../NotificationServicesPushController';\nimport type { PushNotificationEnv } from '../types/firebase';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let supportedCache: boolean | null = null;\n\nconst getPushAvailability = async () => {\n supportedCache ??= await isSupported();\n return supportedCache;\n};\n\nconst createFirebaseApp = async (\n env: PushNotificationEnv,\n): Promise<FirebaseApp> => {\n try {\n return getApp();\n } catch {\n const firebaseConfig = {\n apiKey: env.apiKey,\n authDomain: env.authDomain,\n storageBucket: env.storageBucket,\n projectId: env.projectId,\n messagingSenderId: env.messagingSenderId,\n appId: env.appId,\n measurementId: env.measurementId,\n };\n return initializeApp(firebaseConfig);\n }\n};\n\nconst getFirebaseMessaging = async (\n env: PushNotificationEnv,\n): Promise<Messaging | null> => {\n const supported = await getPushAvailability();\n if (!supported) {\n return null;\n }\n\n const app = await createFirebaseApp(env);\n return getMessaging(app);\n};\n\n/**\n * Creates a registration token for Firebase Cloud Messaging.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with the registration token or null if an error occurs.\n */\nexport async function createRegToken(\n env: PushNotificationEnv,\n): Promise<string | null> {\n try {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return null;\n }\n\n const token = await getToken(messaging, {\n serviceWorkerRegistration: self.registration,\n vapidKey: env.vapidKey,\n });\n return token;\n } catch {\n return null;\n }\n}\n\n/**\n * Deletes the Firebase Cloud Messaging registration token.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with true if the token was successfully deleted, false otherwise.\n */\nexport async function deleteRegToken(\n env: PushNotificationEnv,\n): Promise<boolean> {\n try {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return true;\n }\n\n await deleteToken(messaging);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Service Worker Listener for when push notifications are received.\n *\n * @param env - push notification environment\n * @param handler - handler to actually showing notification, MUST BE PROVIDED\n * @returns unsubscribe handler\n */\nasync function listenToPushNotificationsReceived(\n env: PushNotificationEnv,\n handler: (notification: Types.INotification) => void | Promise<void>,\n): Promise<(() => void) | null> {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return null;\n }\n\n const unsubscribePushNotifications = onBackgroundMessage(\n messaging,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (payload: MessagePayload) => {\n try {\n const data: Types.UnprocessedOnChainRawNotification | undefined =\n payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;\n\n if (!data) {\n return;\n }\n\n const notificationData = toRawOnChainNotification(data);\n const notification = Processors.processNotification(notificationData);\n await handler(notification);\n } catch (error) {\n // Do Nothing, cannot parse a bad notification\n log.error('Unable to send push notification:', {\n notification: payload?.data?.data,\n error,\n });\n throw new Error('Unable to send push notification');\n }\n },\n );\n\n const unsubscribe = () => unsubscribePushNotifications();\n return unsubscribe;\n}\n\n/**\n * Service Worker Listener for when a notification is clicked\n *\n * @param handler - listen to NotificationEvent from the service worker\n * @returns unsubscribe handler\n */\nfunction listenToPushNotificationsClicked(\n handler: (e: NotificationEvent, notification: Types.INotification) => void,\n) {\n const clickHandler = (event: NotificationEvent) => {\n // Get Data\n const data: Types.INotification = event?.notification?.data;\n handler(event, data);\n };\n\n self.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n self.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n\n/**\n * A creator function that assists creating web-specific push notification subscription:\n * 1. Creates subscriptions for receiving and clicking notifications\n * 2. Creates click events when a notification is clicked\n * 3. Publishes controller messenger events\n *\n * @param props - props for this creator function.\n * @param props.onReceivedHandler - allows the developer to handle showing a notification\n * @param props.onClickHandler - allows the developer to handle clicking the notification\n * @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events\n * @returns a function that can be used by the controller\n */\nexport function createSubscribeToPushNotifications(props: {\n onReceivedHandler: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n onClickHandler: (\n e: NotificationEvent,\n notification: Types.INotification,\n ) => void;\n messenger: NotificationServicesPushControllerMessenger;\n}) {\n return async function (env: PushNotificationEnv) {\n const onBackgroundMessageSub = await listenToPushNotificationsReceived(\n env,\n async (notification) => {\n props.messenger.publish(\n 'NotificationServicesPushController:onNewNotifications',\n notification,\n );\n await props.onReceivedHandler(notification);\n },\n );\n const onClickSub = listenToPushNotificationsClicked(\n (event, notification) => {\n props.messenger.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n notification,\n );\n props.onClickHandler(event, notification);\n },\n );\n\n const unsubscribe = () => {\n onBackgroundMessageSub?.();\n onClickSub();\n };\n\n return unsubscribe;\n };\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./is-onchain-notification.cjs"), exports);
18
+ __exportStar(require("./to-raw-notification.cjs"), exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA0C;AAC1C,4DAAsC","sourcesContent":["export * from './is-onchain-notification';\nexport * from './to-raw-notification';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./is-onchain-notification.cjs";
2
+ export * from "./to-raw-notification.cjs";
3
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,8CAA0C;AAC1C,0CAAsC"}
@@ -0,0 +1,3 @@
1
+ export * from "./is-onchain-notification.mjs";
2
+ export * from "./to-raw-notification.mjs";
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,8CAA0C;AAC1C,0CAAsC"}
@@ -0,0 +1,3 @@
1
+ export * from "./is-onchain-notification.mjs";
2
+ export * from "./to-raw-notification.mjs";
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,8CAA0C;AAC1C,0CAAsC","sourcesContent":["export * from './is-onchain-notification';\nexport * from './to-raw-notification';\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isOnChainRawNotification = void 0;
4
+ /**
5
+ * Checks if the given value is an OnChainRawNotification object.
6
+ *
7
+ * @param n - The value to check.
8
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
9
+ */
10
+ function isOnChainRawNotification(n) {
11
+ const assumed = n;
12
+ // We don't have a validation/parsing library to check all possible types of an on chain notification
13
+ // It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
14
+ const isValidEnoughToBeOnChainNotification = [
15
+ assumed?.id,
16
+ assumed?.data,
17
+ assumed?.trigger_id,
18
+ ].every((field) => field !== undefined);
19
+ return isValidEnoughToBeOnChainNotification;
20
+ }
21
+ exports.isOnChainRawNotification = isOnChainRawNotification;
22
+ //# sourceMappingURL=is-onchain-notification.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-onchain-notification.cjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,CAAU;IAEV,MAAM,OAAO,GAAG,CAA2B,CAAC;IAE5C,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,UAAU;KACpB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC;AAbD,4DAaC","sourcesContent":["import type { OnChainRawNotification } from '../NotificationServicesController';\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 isOnChainRawNotification(\n n: unknown,\n): n is OnChainRawNotification {\n const assumed = n as 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"]}
@@ -0,0 +1,9 @@
1
+ import type { OnChainRawNotification } from "../NotificationServicesController/index.cjs";
2
+ /**
3
+ * Checks if the given value is an OnChainRawNotification object.
4
+ *
5
+ * @param n - The value to check.
6
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
+ */
8
+ export declare function isOnChainRawNotification(n: unknown): n is OnChainRawNotification;
9
+ //# sourceMappingURL=is-onchain-notification.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-onchain-notification.d.cts","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oDAA0C;AAEhF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,sBAAsB,CAW7B"}
@@ -0,0 +1,9 @@
1
+ import type { OnChainRawNotification } from "../NotificationServicesController/index.mjs";
2
+ /**
3
+ * Checks if the given value is an OnChainRawNotification object.
4
+ *
5
+ * @param n - The value to check.
6
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
+ */
8
+ export declare function isOnChainRawNotification(n: unknown): n is OnChainRawNotification;
9
+ //# sourceMappingURL=is-onchain-notification.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-onchain-notification.d.mts","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oDAA0C;AAEhF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,sBAAsB,CAW7B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Checks if the given value is an OnChainRawNotification object.
3
+ *
4
+ * @param n - The value to check.
5
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
6
+ */
7
+ export function isOnChainRawNotification(n) {
8
+ const assumed = n;
9
+ // We don't have a validation/parsing library to check all possible types of an on chain notification
10
+ // It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
11
+ const isValidEnoughToBeOnChainNotification = [
12
+ assumed?.id,
13
+ assumed?.data,
14
+ assumed?.trigger_id,
15
+ ].every((field) => field !== undefined);
16
+ return isValidEnoughToBeOnChainNotification;
17
+ }
18
+ //# sourceMappingURL=is-onchain-notification.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-onchain-notification.mjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,CAAU;IAEV,MAAM,OAAO,GAAG,CAA2B,CAAC;IAE5C,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,UAAU;KACpB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC","sourcesContent":["import type { OnChainRawNotification } from '../NotificationServicesController';\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 isOnChainRawNotification(\n n: unknown,\n): n is OnChainRawNotification {\n const assumed = n as 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"]}
@@ -4,6 +4,6 @@
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
- "main": "../../dist/NotificationServicesController/__fixtures__/index.cjs",
8
- "types": "../../dist/NotificationServicesController/__fixtures__/index.d.cts"
7
+ "main": "../../dist/NotificationServicesController/mocks/index.cjs",
8
+ "types": "../../dist/NotificationServicesController/mocks/index.d.cts"
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/notification-services-controller",
3
- "version": "0.21.0-preview-1cc9329c",
3
+ "version": "1.0.0-preview-95a6811",
4
4
  "description": "Manages New MetaMask decentralized Notification system",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "./notification-services/mocks": {
51
51
  "import": {
52
- "types": "./dist/NotificationServicesController/__fixtures__/index.d.mts",
53
- "default": "./dist/NotificationServicesController/__fixtures__/index.mjs"
52
+ "types": "./dist/NotificationServicesController/mocks/index.d.mts",
53
+ "default": "./dist/NotificationServicesController/mocks/index.mjs"
54
54
  },
55
55
  "require": {
56
- "types": "./dist/NotificationServicesController/__fixtures__/index.d.cts",
57
- "default": "./dist/NotificationServicesController/__fixtures__/index.cjs"
56
+ "types": "./dist/NotificationServicesController/mocks/index.d.cts",
57
+ "default": "./dist/NotificationServicesController/mocks/index.cjs"
58
58
  }
59
59
  },
60
60
  "./push-services": {
@@ -67,14 +67,24 @@
67
67
  "default": "./dist/NotificationServicesPushController/index.cjs"
68
68
  }
69
69
  },
70
+ "./push-services/web": {
71
+ "import": {
72
+ "types": "./dist/NotificationServicesPushController/web/index.d.mts",
73
+ "default": "./dist/NotificationServicesPushController/web/index.mjs"
74
+ },
75
+ "require": {
76
+ "types": "./dist/NotificationServicesPushController/web/index.d.cts",
77
+ "default": "./dist/NotificationServicesPushController/web/index.cjs"
78
+ }
79
+ },
70
80
  "./push-services/mocks": {
71
81
  "import": {
72
- "types": "./dist/NotificationServicesPushController/__fixtures__/index.d.mts",
73
- "default": "./dist/NotificationServicesPushController/__fixtures__/index.mjs"
82
+ "types": "./dist/NotificationServicesPushController/mocks/index.d.mts",
83
+ "default": "./dist/NotificationServicesPushController/mocks/index.mjs"
74
84
  },
75
85
  "require": {
76
- "types": "./dist/NotificationServicesPushController/__fixtures__/index.d.cts",
77
- "default": "./dist/NotificationServicesPushController/__fixtures__/index.cjs"
86
+ "types": "./dist/NotificationServicesPushController/mocks/index.d.cts",
87
+ "default": "./dist/NotificationServicesPushController/mocks/index.cjs"
78
88
  }
79
89
  },
80
90
  "./package.json": "./package.json"
@@ -112,8 +122,8 @@
112
122
  "@lavamoat/allow-scripts": "^3.0.4",
113
123
  "@lavamoat/preinstall-always-fail": "^2.1.0",
114
124
  "@metamask/auto-changelog": "^3.4.4",
115
- "@metamask/keyring-controller": "^19.2.0",
116
- "@metamask/profile-sync-controller": "^8.1.0",
125
+ "@metamask/keyring-controller": "^19.2.1",
126
+ "@metamask/profile-sync-controller": "^8.1.1",
117
127
  "@types/jest": "^27.4.1",
118
128
  "@types/readable-stream": "^2.3.0",
119
129
  "contentful": "^10.15.0",
@@ -4,6 +4,6 @@
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
- "main": "../../dist/NotificationServicesPushController/__fixtures__/index.cjs",
8
- "types": "../../dist/NotificationServicesPushController/__fixtures__/index.d.cts"
7
+ "main": "../../dist/NotificationServicesPushController/mocks/index.cjs",
8
+ "types": "../../dist/NotificationServicesPushController/mocks/index.d.cts"
9
9
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "private": true,
4
+ "description": "",
5
+ "license": "MIT",
6
+ "sideEffects": false,
7
+ "main": "../../dist/NotificationServicesPushController/web/index.cjs",
8
+ "types": "../../dist/NotificationServicesPushController/web/index.d.cts"
9
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAA6C;AAC7C,kEAA4C;AAC5C,uEAAiD;AACjD,+DAAyC;AACzC,sDAAgC;AAChC,+DAAyC","sourcesContent":["export * from './mock-feature-announcements';\nexport * from './mock-notification-trigger';\nexport * from './mock-notification-user-storage';\nexport * from './mock-raw-notifications';\nexport * from './mockResponses';\nexport * from './mock-snap-notification';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC","sourcesContent":["export * from './mock-feature-announcements';\nexport * from './mock-notification-trigger';\nexport * from './mock-notification-user-storage';\nexport * from './mock-raw-notifications';\nexport * from './mockResponses';\nexport * from './mock-snap-notification';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-feature-announcements.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-feature-announcements.ts"],"names":[],"mappings":";;;AAAA,8EAAiE;AAIjE;;;;GAIG;AACH,SAAgB,sCAAsC;IACpD,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,OAAO;SACd;QACD,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE;oBACR,IAAI,EAAE,EAAE;iBACT;gBACD,GAAG,EAAE;oBACH,KAAK,EAAE;wBACL,GAAG,EAAE;4BACH,IAAI,EAAE,MAAM;4BACZ,QAAQ,EAAE,OAAO;4BACjB,EAAE,EAAE,cAAc;yBACnB;qBACF;oBACD,EAAE,EAAE,wBAAwB;oBAC5B,IAAI,EAAE,OAAO;oBACb,SAAS,EAAE,0BAA0B;oBACrC,SAAS,EAAE,0BAA0B;oBACrC,WAAW,EAAE;wBACX,GAAG,EAAE;4BACH,EAAE,EAAE,QAAQ;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D;4BAC7D,WAAW,EAAE,WAAW;yBACzB;qBACF;iBACF;aACF;SACF;KAC6B,CAAC;AACnC,CAAC;AA5KD,wFA4KC;AAED;;;;GAIG;AACH,SAAgB,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,mCAAa,CAAC,qBAAqB;QACzC,SAAS,EAAE,0BAA0B;QACrC,IAAI,EAAE;YACJ,EAAE,EAAE,6CAA6C;YACjD,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,+CAA+C;YACtD,eAAe,EAAE,uSAAuS;YACxT,gBAAgB,EACd,yGAAyG;YAC3G,KAAK,EAAE;gBACL,KAAK,EAAE,+CAA+C;gBACtD,WAAW,EAAE,EAAE;gBACf,GAAG,EAAE,+IAA+I;aACrJ;YACD,aAAa,EAAE;gBACb,iBAAiB,EAAE,SAAS;gBAC5B,kBAAkB,EAAE,WAAW;aAChC;SACF;KACF,CAAC;AACJ,CAAC;AAtBD,4EAsBC","sourcesContent":["import { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { ContentfulResult } from '../services/feature-announcements';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\n\n/**\n * Mocking Utility - create a mock normalized feature announcement\n *\n * @returns Mock Normalized Feature Announcement\n */\nexport function createMockFeatureAnnouncementAPIResult(): ContentfulResult {\n return {\n sys: {\n type: 'Array',\n },\n total: 17,\n skip: 0,\n limit: 1,\n items: [\n {\n metadata: {\n tags: [],\n },\n sys: {\n space: {\n sys: {\n type: 'Link',\n linkType: 'Space',\n id: 'jdkgyfmyd9sw',\n },\n },\n id: '1ABRmHaNCgmxROKXXLXsMu',\n type: 'Entry',\n createdAt: '2024-04-09T13:24:01.872Z',\n updatedAt: '2024-04-09T13:24:01.872Z',\n environment: {\n sys: {\n id: 'master',\n type: 'Link',\n linkType: 'Environment',\n },\n },\n revision: 1,\n contentType: {\n sys: {\n type: 'Link',\n linkType: 'ContentType',\n id: 'productAnnouncement',\n },\n },\n locale: 'en-US',\n },\n fields: {\n title: 'Don’t miss out on airdrops and new NFT mints!',\n id: 'dont-miss-out-on-airdrops-and-new-nft-mints',\n category: 'ANNOUNCEMENT',\n shortDescription:\n 'Check your airdrop eligibility and see trending NFT drops. Head over to the Explore tab to get started. ',\n image: {\n sys: {\n type: 'Link',\n linkType: 'Asset',\n id: '5jqq8sFeLc6XEoeWlpI3aB',\n },\n },\n longDescription: {\n data: {},\n content: [\n {\n data: {},\n content: [\n {\n data: {},\n marks: [],\n value:\n 'You can now verify if any of your connected addresses are eligible for airdrops and other ERC-20 claims in a secure and convenient way. We’ve also added trending NFT mints based on creators you’ve minted from before or other tokens you hold. Head over to the Explore tab to get started. \\n',\n nodeType: 'text',\n },\n ],\n nodeType: 'paragraph',\n },\n ],\n nodeType: 'document',\n },\n link: {\n sys: {\n type: 'Link',\n linkType: 'Entry',\n id: '62xKYM2ydo4F1mS5q97K5q',\n },\n },\n },\n },\n ],\n includes: {\n Entry: [\n {\n metadata: {\n tags: [],\n },\n sys: {\n space: {\n sys: {\n type: 'Link',\n linkType: 'Space',\n id: 'jdkgyfmyd9sw',\n },\n },\n id: '62xKYM2ydo4F1mS5q97K5q',\n type: 'Entry',\n createdAt: '2024-04-09T13:23:03.636Z',\n updatedAt: '2024-04-09T13:23:03.636Z',\n environment: {\n sys: {\n id: 'master',\n type: 'Link',\n linkType: 'Environment',\n },\n },\n revision: 1,\n contentType: {\n sys: {\n type: 'Link',\n linkType: 'ContentType',\n id: 'link',\n },\n },\n locale: 'en-US',\n },\n fields: {\n extensionLinkText: 'Try now',\n extensionLinkRoute: 'home.html',\n },\n },\n ],\n Asset: [\n {\n metadata: {\n tags: [],\n },\n sys: {\n space: {\n sys: {\n type: 'Link',\n linkType: 'Space',\n id: 'jdkgyfmyd9sw',\n },\n },\n id: '5jqq8sFeLc6XEoeWlpI3aB',\n type: 'Asset',\n createdAt: '2024-04-09T13:23:13.327Z',\n updatedAt: '2024-04-09T13:23:13.327Z',\n environment: {\n sys: {\n id: 'master',\n type: 'Link',\n linkType: 'Environment',\n },\n },\n revision: 1,\n locale: 'en-US',\n },\n fields: {\n title: 'PDAPP notification image Airdrops & NFT mints',\n description: '',\n file: {\n url: '//images.ctfassets.net/jdkgyfmyd9sw/5jqq8sFeLc6XEoeWlpI3aB/73ee0f1afa9916c3a7538b0bbee09c26/PDAPP_notification_image_Airdrops___NFT_mints.png',\n details: {\n size: 797731,\n image: {\n width: 2880,\n height: 1921,\n },\n },\n fileName: 'PDAPP notification image_Airdrops & NFT mints.png',\n contentType: 'image/png',\n },\n },\n },\n ],\n },\n } as unknown as ContentfulResult;\n}\n\n/**\n * Mocking Utility - create a mock raw feature announcement\n *\n * @returns Mock Raw Feature Announcement\n */\nexport function createMockFeatureAnnouncementRaw(): FeatureAnnouncementRawNotification {\n return {\n type: TRIGGER_TYPES.FEATURES_ANNOUNCEMENT,\n createdAt: '2999-04-09T13:24:01.872Z',\n data: {\n id: 'dont-miss-out-on-airdrops-and-new-nft-mints',\n category: 'ANNOUNCEMENT',\n title: 'Don’t miss out on airdrops and new NFT mints!',\n longDescription: `<p>You can now verify if any of your connected addresses are eligible for airdrops and other ERC-20 claims in a secure and convenient way. We’ve also added trending NFT mints based on creators you’ve minted from before or other tokens you hold. Head over to the Explore tab to get started.</p>`,\n shortDescription:\n 'Check your airdrop eligibility and see trending NFT drops. Head over to the Explore tab to get started.',\n image: {\n title: 'PDAPP notification image Airdrops & NFT mints',\n description: '',\n url: '//images.ctfassets.net/jdkgyfmyd9sw/5jqq8sFeLc6XEoeWlpI3aB/73ee0f1afa9916c3a7538b0bbee09c26/PDAPP_notification_image_Airdrops___NFT_mints.png',\n },\n extensionLink: {\n extensionLinkText: 'Try now',\n extensionLinkRoute: 'home.html',\n },\n },\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-feature-announcements.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-feature-announcements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,8CAA0C;AAC1E,OAAO,KAAK,EAAE,kCAAkC,EAAE,+DAA2D;AAE7G;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,gBAAgB,CA4KzE;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,IAAI,kCAAkC,CAsBrF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-feature-announcements.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-feature-announcements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,8CAA0C;AAC1E,OAAO,KAAK,EAAE,kCAAkC,EAAE,+DAA2D;AAE7G;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,gBAAgB,CA4KzE;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,IAAI,kCAAkC,CAsBrF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-feature-announcements.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-feature-announcements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,6CAAyC;AAIjE;;;;GAIG;AACH,MAAM,UAAU,sCAAsC;IACpD,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,OAAO;SACd;QACD,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE;oBACR,IAAI,EAAE,EAAE;iBACT;gBACD,GAAG,EAAE;oBACH,KAAK,EAAE;wBACL,GAAG,EAAE;4BACH,IAAI,EAAE,MAAM;4BACZ,QAAQ,EAAE,OAAO;4BACjB,EAAE,EAAE,cAAc;yBACnB;qBACF;oBACD,EAAE,EAAE,wBAAwB;oBAC5B,IAAI,EAAE,OAAO;oBACb,SAAS,EAAE,0BAA0B;oBACrC,SAAS,EAAE,0BAA0B;oBACrC,WAAW,EAAE;wBACX,GAAG,EAAE;4BACH,EAAE,EAA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AE,mDAAmD;4BAC7D,WAAW,EAAE,WAAW;yBACzB;qBACF;iBACF;aACF;SACF;KAC6B,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,aAAa,CAAC,qBAAqB;QACzC,SAAS,EAAE,0BAA0B;QACrC,IAAI,EAAE;YACJ,EAAE,EAAE,6CAA6C;YACjD,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,+CAA+C;YACtD,eAAe,EAAE,uSAAuS;YACxT,gBAAgB,EACd,yGAAyG;YAC3G,KAAK,EAAE;gBACL,KAAK,EAAE,+CAA+C;gBACtD,WAAW,EAAE,EAAE;gBACf,GAAG,EAAE,+IAA+I;aACrJ;YACD,aAAa,EAAE;gBACb,iBAAiB,EAAE,SAAS;gBAC5B,kBAAkB,EAAE,WAAW;aAChC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { ContentfulResult } from '../services/feature-announcements';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\n\n/**\n * Mocking Utility - create a mock normalized feature announcement\n *\n * @returns Mock Normalized Feature Announcement\n */\nexport function createMockFeatureAnnouncementAPIResult(): ContentfulResult {\n return {\n sys: {\n type: 'Array',\n },\n total: 17,\n skip: 0,\n limit: 1,\n items: [\n {\n metadata: {\n tags: [],\n },\n sys: {\n space: {\n sys: {\n type: 'Link',\n linkType: 'Space',\n id: 'jdkgyfmyd9sw',\n },\n },\n id: '1ABRmHaNCgmxROKXXLXsMu',\n type: 'Entry',\n createdAt: '2024-04-09T13:24:01.872Z',\n updatedAt: '2024-04-09T13:24:01.872Z',\n environment: {\n sys: {\n id: 'master',\n type: 'Link',\n linkType: 'Environment',\n },\n },\n revision: 1,\n contentType: {\n sys: {\n type: 'Link',\n linkType: 'ContentType',\n id: 'productAnnouncement',\n },\n },\n locale: 'en-US',\n },\n fields: {\n title: 'Don’t miss out on airdrops and new NFT mints!',\n id: 'dont-miss-out-on-airdrops-and-new-nft-mints',\n category: 'ANNOUNCEMENT',\n shortDescription:\n 'Check your airdrop eligibility and see trending NFT drops. Head over to the Explore tab to get started. ',\n image: {\n sys: {\n type: 'Link',\n linkType: 'Asset',\n id: '5jqq8sFeLc6XEoeWlpI3aB',\n },\n },\n longDescription: {\n data: {},\n content: [\n {\n data: {},\n content: [\n {\n data: {},\n marks: [],\n value:\n 'You can now verify if any of your connected addresses are eligible for airdrops and other ERC-20 claims in a secure and convenient way. We’ve also added trending NFT mints based on creators you’ve minted from before or other tokens you hold. Head over to the Explore tab to get started. \\n',\n nodeType: 'text',\n },\n ],\n nodeType: 'paragraph',\n },\n ],\n nodeType: 'document',\n },\n link: {\n sys: {\n type: 'Link',\n linkType: 'Entry',\n id: '62xKYM2ydo4F1mS5q97K5q',\n },\n },\n },\n },\n ],\n includes: {\n Entry: [\n {\n metadata: {\n tags: [],\n },\n sys: {\n space: {\n sys: {\n type: 'Link',\n linkType: 'Space',\n id: 'jdkgyfmyd9sw',\n },\n },\n id: '62xKYM2ydo4F1mS5q97K5q',\n type: 'Entry',\n createdAt: '2024-04-09T13:23:03.636Z',\n updatedAt: '2024-04-09T13:23:03.636Z',\n environment: {\n sys: {\n id: 'master',\n type: 'Link',\n linkType: 'Environment',\n },\n },\n revision: 1,\n contentType: {\n sys: {\n type: 'Link',\n linkType: 'ContentType',\n id: 'link',\n },\n },\n locale: 'en-US',\n },\n fields: {\n extensionLinkText: 'Try now',\n extensionLinkRoute: 'home.html',\n },\n },\n ],\n Asset: [\n {\n metadata: {\n tags: [],\n },\n sys: {\n space: {\n sys: {\n type: 'Link',\n linkType: 'Space',\n id: 'jdkgyfmyd9sw',\n },\n },\n id: '5jqq8sFeLc6XEoeWlpI3aB',\n type: 'Asset',\n createdAt: '2024-04-09T13:23:13.327Z',\n updatedAt: '2024-04-09T13:23:13.327Z',\n environment: {\n sys: {\n id: 'master',\n type: 'Link',\n linkType: 'Environment',\n },\n },\n revision: 1,\n locale: 'en-US',\n },\n fields: {\n title: 'PDAPP notification image Airdrops & NFT mints',\n description: '',\n file: {\n url: '//images.ctfassets.net/jdkgyfmyd9sw/5jqq8sFeLc6XEoeWlpI3aB/73ee0f1afa9916c3a7538b0bbee09c26/PDAPP_notification_image_Airdrops___NFT_mints.png',\n details: {\n size: 797731,\n image: {\n width: 2880,\n height: 1921,\n },\n },\n fileName: 'PDAPP notification image_Airdrops & NFT mints.png',\n contentType: 'image/png',\n },\n },\n },\n ],\n },\n } as unknown as ContentfulResult;\n}\n\n/**\n * Mocking Utility - create a mock raw feature announcement\n *\n * @returns Mock Raw Feature Announcement\n */\nexport function createMockFeatureAnnouncementRaw(): FeatureAnnouncementRawNotification {\n return {\n type: TRIGGER_TYPES.FEATURES_ANNOUNCEMENT,\n createdAt: '2999-04-09T13:24:01.872Z',\n data: {\n id: 'dont-miss-out-on-airdrops-and-new-nft-mints',\n category: 'ANNOUNCEMENT',\n title: 'Don’t miss out on airdrops and new NFT mints!',\n longDescription: `<p>You can now verify if any of your connected addresses are eligible for airdrops and other ERC-20 claims in a secure and convenient way. We’ve also added trending NFT mints based on creators you’ve minted from before or other tokens you hold. Head over to the Explore tab to get started.</p>`,\n shortDescription:\n 'Check your airdrop eligibility and see trending NFT drops. Head over to the Explore tab to get started.',\n image: {\n title: 'PDAPP notification image Airdrops & NFT mints',\n description: '',\n url: '//images.ctfassets.net/jdkgyfmyd9sw/5jqq8sFeLc6XEoeWlpI3aB/73ee0f1afa9916c3a7538b0bbee09c26/PDAPP_notification_image_Airdrops___NFT_mints.png',\n },\n extensionLink: {\n extensionLinkText: 'Try now',\n extensionLinkRoute: 'home.html',\n },\n },\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-trigger.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAIpC;;;;;GAKG;AACH,SAAgB,6BAA6B,CAC3C,QAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,IAAA,SAAM,GAAE;QACZ,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;QACb,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAXD,sEAWC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { NotificationTrigger } from '../utils/utils';\n\n/**\n * Mocking Utility - create a mock Notification Trigger\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock Notification Trigger\n */\nexport function createMockNotificationTrigger(\n override?: Partial<NotificationTrigger>,\n): NotificationTrigger {\n return {\n id: uuidv4(),\n address: '0xFAKE_ADDRESS',\n chainId: '1',\n kind: 'eth_sent',\n enabled: true,\n ...override,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAuB;AAE1D;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,mBAAmB,CASrB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAuB;AAE1D;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,mBAAmB,CASrB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AAIpC;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,MAAM,EAAE;QACZ,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;QACb,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { NotificationTrigger } from '../utils/utils';\n\n/**\n * Mocking Utility - create a mock Notification Trigger\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock Notification Trigger\n */\nexport function createMockNotificationTrigger(\n override?: Partial<NotificationTrigger>,\n): NotificationTrigger {\n return {\n id: uuidv4(),\n address: '0xFAKE_ADDRESS',\n chainId: '1',\n kind: 'eth_sent',\n enabled: true,\n ...override,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-user-storage.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-user-storage.ts"],"names":[],"mappings":";;;AAAA,0DAAkE;AAClE,8EAAiE;AAEjE,8CAAuD;AAE1C,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,QAA+B;IAE/B,OAAO;QACL,CAAC,oCAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,iCAAyB,CAAC,EAAE;YAC3B,CAAC,+BAAuB,CAAC,EAAE;gBACzB,iBAAiB,EAAE;oBACjB,CAAC,EAAE,mCAAa,CAAC,cAAc;oBAC/B,CAAC,EAAE,IAAI;iBACR;gBACD,iBAAiB,EAAE;oBACjB,CAAC,EAAE,mCAAa,CAAC,UAAU;oBAC3B,CAAC,EAAE,IAAI;iBACR;aACF;SACF;QACD,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAnBD,sDAmBC;AAED;;;;;GAKG;AACH,SAAgB,iCAAiC,CAC/C,QAAoE;IAEpE,MAAM,WAAW,GAAgB;QAC/B,CAAC,oCAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,iCAAyB,CAAC,EAAE;YAC3B,CAAC,+BAAuB,CAAC,EAAE,EAAE;SAC9B;KACF,CAAC;IAEF,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,IAAI,GAAW,CAAC;QAChB,IAAI,CAAU,CAAC;QACf,IAAI,CAAgB,CAAC;QACrB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;YACzB,GAAG,GAAG,CAAC,CAAC;YACR,CAAC,GAAG,IAAI,CAAC;YACT,CAAC,GAAG,mCAAa,CAAC,cAAc,CAAC;SAClC;aAAM;YACL,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;YACX,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACR,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,mCAAa,CAAC,cAAc,CAAC;SACzC;QAED,WAAW,CAAC,iCAAyB,CAAC,CAAC,+BAAuB,CAAC,CAAC,GAAG,CAAC,GAAG;YACrE,CAAC;YACD,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AAhCD,8EAgCC;AAED;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACvC,QAAyD,EAAE;IAE3D,OAAO,IAAA,6BAAqB,EAC1B,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,iCAAyB,EAAE,CAAC,EACzD,KAAK,CAAC,eAAe,IAAI,IAAI,EAC7B,KAAK,CACN,CAAC;AACJ,CAAC;AARD,8DAQC","sourcesContent":["import { USER_STORAGE_VERSION_KEY } from '../constants/constants';\nimport { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { UserStorage } from '../types/user-storage/user-storage';\nimport { initializeUserStorage } from '../utils/utils';\n\nexport const MOCK_USER_STORAGE_ACCOUNT =\n '0x0000000000000000000000000000000000000000';\nexport const MOCK_USER_STORAGE_CHAIN = '1';\n\n/**\n * Mocking Utility - create a mock notification user storage object\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock notification user storage object\n */\nexport function createMockUserStorage(\n override?: Partial<UserStorage>,\n): UserStorage {\n return {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {\n '111-111-111-111': {\n k: TRIGGER_TYPES.ERC20_RECEIVED,\n e: true,\n },\n '222-222-222-222': {\n k: TRIGGER_TYPES.ERC20_SENT,\n e: true,\n },\n },\n },\n ...override,\n };\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object with triggers\n *\n * @param triggers - provide any override configuration for the mock\n * @returns a mock notification user storage object with triggers\n */\nexport function createMockUserStorageWithTriggers(\n triggers: string[] | { id: string; e: boolean; k?: TRIGGER_TYPES }[],\n): UserStorage {\n const userStorage: UserStorage = {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {},\n },\n };\n\n // insert triggerIds\n triggers.forEach((t) => {\n let tId: string;\n let e: boolean;\n let k: TRIGGER_TYPES;\n if (typeof t === 'string') {\n tId = t;\n e = true;\n k = TRIGGER_TYPES.ERC20_RECEIVED;\n } else {\n tId = t.id;\n e = t.e;\n k = t.k ?? TRIGGER_TYPES.ERC20_RECEIVED;\n }\n\n userStorage[MOCK_USER_STORAGE_ACCOUNT][MOCK_USER_STORAGE_CHAIN][tId] = {\n k,\n e,\n };\n });\n\n return userStorage;\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object (full/realistic object)\n *\n * @param props - provide any override configuration for the mock\n * @param props.triggersEnabled - choose if all triggers created are enabled/disabled\n * @param props.address - choose a specific address for triggers to be assigned to\n * @returns a mock full notification user storage object\n */\nexport function createMockFullUserStorage(\n props: { triggersEnabled?: boolean; address?: string } = {},\n): UserStorage {\n return initializeUserStorage(\n [{ address: props.address ?? MOCK_USER_STORAGE_ACCOUNT }],\n props.triggersEnabled ?? true,\n false,\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-user-storage.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-user-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,6CAAyC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,+CAA2C;AAGtE,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAC9B,WAAW,CAiBb;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,EAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,aAAa,CAAA;CAAE,EAAE,GACnE,WAAW,CA8Bb;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1D,WAAW,CAMb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-user-storage.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-user-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,6CAAyC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,+CAA2C;AAGtE,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAC9B,WAAW,CAiBb;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,EAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,aAAa,CAAA;CAAE,EAAE,GACnE,WAAW,CA8Bb;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1D,WAAW,CAMb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-user-storage.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/mock-notification-user-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,mCAA+B;AAClE,OAAO,EAAE,aAAa,EAAE,6CAAyC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,2BAAuB;AAEvD,MAAM,CAAC,MAAM,yBAAyB,GACpC,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAA+B;IAE/B,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,yBAAyB,CAAC,EAAE;YAC3B,CAAC,uBAAuB,CAAC,EAAE;gBACzB,iBAAiB,EAAE;oBACjB,CAAC,EAAE,aAAa,CAAC,cAAc;oBAC/B,CAAC,EAAE,IAAI;iBACR;gBACD,iBAAiB,EAAE;oBACjB,CAAC,EAAE,aAAa,CAAC,UAAU;oBAC3B,CAAC,EAAE,IAAI;iBACR;aACF;SACF;QACD,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,QAAoE;IAEpE,MAAM,WAAW,GAAgB;QAC/B,CAAC,wBAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,yBAAyB,CAAC,EAAE;YAC3B,CAAC,uBAAuB,CAAC,EAAE,EAAE;SAC9B;KACF,CAAC;IAEF,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,IAAI,GAAW,CAAC;QAChB,IAAI,CAAU,CAAC;QACf,IAAI,CAAgB,CAAC;QACrB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;YACzB,GAAG,GAAG,CAAC,CAAC;YACR,CAAC,GAAG,IAAI,CAAC;YACT,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC;SAClC;aAAM;YACL,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;YACX,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACR,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,cAAc,CAAC;SACzC;QAED,WAAW,CAAC,yBAAyB,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,GAAG;YACrE,CAAC;YACD,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAyD,EAAE;IAE3D,OAAO,qBAAqB,CAC1B,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,yBAAyB,EAAE,CAAC,EACzD,KAAK,CAAC,eAAe,IAAI,IAAI,EAC7B,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { USER_STORAGE_VERSION_KEY } from '../constants/constants';\nimport { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { UserStorage } from '../types/user-storage/user-storage';\nimport { initializeUserStorage } from '../utils/utils';\n\nexport const MOCK_USER_STORAGE_ACCOUNT =\n '0x0000000000000000000000000000000000000000';\nexport const MOCK_USER_STORAGE_CHAIN = '1';\n\n/**\n * Mocking Utility - create a mock notification user storage object\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock notification user storage object\n */\nexport function createMockUserStorage(\n override?: Partial<UserStorage>,\n): UserStorage {\n return {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {\n '111-111-111-111': {\n k: TRIGGER_TYPES.ERC20_RECEIVED,\n e: true,\n },\n '222-222-222-222': {\n k: TRIGGER_TYPES.ERC20_SENT,\n e: true,\n },\n },\n },\n ...override,\n };\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object with triggers\n *\n * @param triggers - provide any override configuration for the mock\n * @returns a mock notification user storage object with triggers\n */\nexport function createMockUserStorageWithTriggers(\n triggers: string[] | { id: string; e: boolean; k?: TRIGGER_TYPES }[],\n): UserStorage {\n const userStorage: UserStorage = {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {},\n },\n };\n\n // insert triggerIds\n triggers.forEach((t) => {\n let tId: string;\n let e: boolean;\n let k: TRIGGER_TYPES;\n if (typeof t === 'string') {\n tId = t;\n e = true;\n k = TRIGGER_TYPES.ERC20_RECEIVED;\n } else {\n tId = t.id;\n e = t.e;\n k = t.k ?? TRIGGER_TYPES.ERC20_RECEIVED;\n }\n\n userStorage[MOCK_USER_STORAGE_ACCOUNT][MOCK_USER_STORAGE_CHAIN][tId] = {\n k,\n e,\n };\n });\n\n return userStorage;\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object (full/realistic object)\n *\n * @param props - provide any override configuration for the mock\n * @param props.triggersEnabled - choose if all triggers created are enabled/disabled\n * @param props.address - choose a specific address for triggers to be assigned to\n * @returns a mock full notification user storage object\n */\nexport function createMockFullUserStorage(\n props: { triggersEnabled?: boolean; address?: string } = {},\n): UserStorage {\n return initializeUserStorage(\n [{ address: props.address ?? MOCK_USER_STORAGE_ACCOUNT }],\n props.triggersEnabled ?? true,\n false,\n );\n}\n"]}