@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
@@ -37,5 +37,5 @@ exports.default = NotificationServicesPushController;
37
37
  __exportStar(require("./NotificationServicesPushController.cjs"), exports);
38
38
  exports.Utils = __importStar(require("./utils/index.cjs"));
39
39
  __exportStar(require("./utils/index.cjs"), exports);
40
- exports.Mocks = __importStar(require("./__fixtures__/index.cjs"));
40
+ exports.Mocks = __importStar(require("./mocks/index.cjs"));
41
41
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kHAA8D;AAGrD,qBAHF,4CAAU,CAGE;AADnB,MAAM,kCAAkC,GAAG,4CAAU,CAAC;AAEtD,kBAAe,kCAAkC,CAAC;AAClD,2EAAqD;AAGrD,2DAAiC;AACjC,oDAAwB;AACxB,kEAAwC","sourcesContent":["import Controller from './NotificationServicesPushController';\n\nconst NotificationServicesPushController = Controller;\nexport { Controller };\nexport default NotificationServicesPushController;\nexport * from './NotificationServicesPushController';\nexport type * as Types from './types';\nexport type * from './types';\nexport * as Utils from './utils';\nexport * from './utils';\nexport * as Mocks from './__fixtures__';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kHAA8D;AAGrD,qBAHF,4CAAU,CAGE;AADnB,MAAM,kCAAkC,GAAG,4CAAU,CAAC;AAEtD,kBAAe,kCAAkC,CAAC;AAClD,2EAAqD;AAGrD,2DAAiC;AACjC,oDAAwB;AACxB,2DAAiC","sourcesContent":["import Controller from './NotificationServicesPushController';\n\nconst NotificationServicesPushController = Controller;\nexport { Controller };\nexport default NotificationServicesPushController;\nexport * from './NotificationServicesPushController';\nexport type * as Types from './types';\nexport type * from './types';\nexport * as Utils from './utils';\nexport * from './utils';\nexport * as Mocks from './mocks';\n"]}
@@ -7,5 +7,5 @@ export type * as Types from "./types/index.cjs";
7
7
  export type * from "./types/index.cjs";
8
8
  export * as Utils from "./utils/index.cjs";
9
9
  export * from "./utils/index.cjs";
10
- export * as Mocks from "./__fixtures__/index.cjs";
10
+ export * as Mocks from "./mocks/index.cjs";
11
11
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,iDAA6C;AAE9D,QAAA,MAAM,kCAAkC,mBAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,kCAAkC,CAAC;AAClD,yDAAqD;AACrD,YAAY,KAAK,KAAK,0BAAgB;AACtC,uCAA6B;AAC7B,OAAO,KAAK,KAAK,0BAAgB;AACjC,kCAAwB;AACxB,OAAO,KAAK,KAAK,iCAAuB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,iDAA6C;AAE9D,QAAA,MAAM,kCAAkC,mBAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,kCAAkC,CAAC;AAClD,yDAAqD;AACrD,YAAY,KAAK,KAAK,0BAAgB;AACtC,uCAA6B;AAC7B,OAAO,KAAK,KAAK,0BAAgB;AACjC,kCAAwB;AACxB,OAAO,KAAK,KAAK,0BAAgB"}
@@ -7,5 +7,5 @@ export type * as Types from "./types/index.mjs";
7
7
  export type * from "./types/index.mjs";
8
8
  export * as Utils from "./utils/index.mjs";
9
9
  export * from "./utils/index.mjs";
10
- export * as Mocks from "./__fixtures__/index.mjs";
10
+ export * as Mocks from "./mocks/index.mjs";
11
11
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,iDAA6C;AAE9D,QAAA,MAAM,kCAAkC,mBAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,kCAAkC,CAAC;AAClD,yDAAqD;AACrD,YAAY,KAAK,KAAK,0BAAgB;AACtC,uCAA6B;AAC7B,OAAO,KAAK,KAAK,0BAAgB;AACjC,kCAAwB;AACxB,OAAO,KAAK,KAAK,iCAAuB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,iDAA6C;AAE9D,QAAA,MAAM,kCAAkC,mBAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,kCAAkC,CAAC;AAClD,yDAAqD;AACrD,YAAY,KAAK,KAAK,0BAAgB;AACtC,uCAA6B;AAC7B,OAAO,KAAK,KAAK,0BAAgB;AACjC,kCAAwB;AACxB,OAAO,KAAK,KAAK,0BAAgB"}
@@ -5,5 +5,5 @@ export default NotificationServicesPushController;
5
5
  export * from "./NotificationServicesPushController.mjs";
6
6
  export * as Utils from "./utils/index.mjs";
7
7
  export * from "./utils/index.mjs";
8
- export * as Mocks from "./__fixtures__/index.mjs";
8
+ export * as Mocks from "./mocks/index.mjs";
9
9
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,iDAA6C;AAE9D,MAAM,kCAAkC,GAAG,UAAU,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,kCAAkC,CAAC;AAClD,yDAAqD;AAGrD,OAAO,KAAK,KAAK,0BAAgB;AACjC,kCAAwB;AACxB,OAAO,KAAK,KAAK,iCAAuB","sourcesContent":["import Controller from './NotificationServicesPushController';\n\nconst NotificationServicesPushController = Controller;\nexport { Controller };\nexport default NotificationServicesPushController;\nexport * from './NotificationServicesPushController';\nexport type * as Types from './types';\nexport type * from './types';\nexport * as Utils from './utils';\nexport * from './utils';\nexport * as Mocks from './__fixtures__';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/NotificationServicesPushController/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,iDAA6C;AAE9D,MAAM,kCAAkC,GAAG,UAAU,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,kCAAkC,CAAC;AAClD,yDAAqD;AAGrD,OAAO,KAAK,KAAK,0BAAgB;AACjC,kCAAwB;AACxB,OAAO,KAAK,KAAK,0BAAgB","sourcesContent":["import Controller from './NotificationServicesPushController';\n\nconst NotificationServicesPushController = Controller;\nexport { Controller };\nexport default NotificationServicesPushController;\nexport * from './NotificationServicesPushController';\nexport type * as Types from './types';\nexport type * from './types';\nexport * as Utils from './utils';\nexport * from './utils';\nexport * as Mocks from './mocks';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA+B","sourcesContent":["export * from './mockResponse';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/index.ts"],"names":[],"mappings":"AAAA,mCAA+B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/index.ts"],"names":[],"mappings":"AAAA,mCAA+B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/index.ts"],"names":[],"mappings":"AAAA,mCAA+B","sourcesContent":["export * from './mockResponse';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponse.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/__fixtures__/mockResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,kCAA8B;AASrE,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,mBAAmB,GAAgB;IAC9C,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC5B,mBAAmB,EAAE;QACnB,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;QAC/C,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;KAChD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,4CAA4C,GAAG,GAAG,EAAE;IAC/D,OAAO;QACL,GAAG,EAAE,4BAA4B;QACjC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,mBAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0CAA0C,GAAG,GAAG,EAAE;IAC7D,OAAO;QACL,GAAG,EAAE,4BAA4B;QACjC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,EAAE;IAC5D,OAAO;QACL,GAAG,EAAE,kEAAkE;QACvE,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,iBAAiB;KACL,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,EAAE;IAC5D,OAAO;QACL,GAAG,EAAE,kEAAkE;QACvE,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,EAAE;KACU,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import { REGISTRATION_TOKENS_ENDPOINT } from '../services/endpoints';\nimport type { LinksResult } from '../services/services';\n\ntype MockResponse = {\n url: string | RegExp;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_REG_TOKEN = 'REG_TOKEN';\nexport const MOCK_LINKS_RESPONSE: LinksResult = {\n trigger_ids: ['1', '2', '3'],\n registration_tokens: [\n { token: 'reg_token_1', platform: 'portfolio' },\n { token: 'reg_token_2', platform: 'extension' },\n ],\n};\n\nexport const getMockRetrievePushNotificationLinksResponse = () => {\n return {\n url: REGISTRATION_TOKENS_ENDPOINT,\n requestMethod: 'GET',\n response: MOCK_LINKS_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockUpdatePushNotificationLinksResponse = () => {\n return {\n url: REGISTRATION_TOKENS_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const MOCK_FCM_RESPONSE = {\n name: '',\n token: 'fcm-token',\n web: {\n endpoint: '',\n p256dh: '',\n auth: '',\n applicationPubKey: '',\n },\n};\n\nexport const getMockCreateFCMRegistrationTokenResponse = () => {\n return {\n url: /^https:\\/\\/fcmregistrations\\.googleapis\\.com\\/v1\\/projects\\/.*$/u,\n requestMethod: 'POST',\n response: MOCK_FCM_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockDeleteFCMRegistrationTokenResponse = () => {\n return {\n url: /^https:\\/\\/fcmregistrations\\.googleapis\\.com\\/v1\\/projects\\/.*$/u,\n requestMethod: 'POST',\n response: {},\n } satisfies MockResponse;\n};\n"]}
1
+ {"version":3,"file":"mockResponse.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/mockResponse.ts"],"names":[],"mappings":";;;AAAA,yDAAqE;AASxD,QAAA,cAAc,GAAG,WAAW,CAAC;AAC7B,QAAA,mBAAmB,GAAgB;IAC9C,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC5B,mBAAmB,EAAE;QACnB,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;QAC/C,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;KAChD;CACF,CAAC;AAEK,MAAM,4CAA4C,GAAG,GAAG,EAAE;IAC/D,OAAO;QACL,GAAG,EAAE,wCAA4B;QACjC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,2BAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,4CAA4C,gDAMvD;AAEK,MAAM,0CAA0C,GAAG,GAAG,EAAE;IAC7D,OAAO;QACL,GAAG,EAAE,wCAA4B;QACjC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,0CAA0C,8CAMrD;AAEW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAC;AAEK,MAAM,yCAAyC,GAAG,GAAG,EAAE;IAC5D,OAAO;QACL,GAAG,EAAE,kEAAkE;QACvE,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,yBAAiB;KACL,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,yCAAyC,6CAMpD;AAEK,MAAM,yCAAyC,GAAG,GAAG,EAAE;IAC5D,OAAO;QACL,GAAG,EAAE,kEAAkE;QACvE,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,EAAE;KACU,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,yCAAyC,6CAMpD","sourcesContent":["import { REGISTRATION_TOKENS_ENDPOINT } from '../services/endpoints';\nimport type { LinksResult } from '../services/services';\n\ntype MockResponse = {\n url: string | RegExp;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_REG_TOKEN = 'REG_TOKEN';\nexport const MOCK_LINKS_RESPONSE: LinksResult = {\n trigger_ids: ['1', '2', '3'],\n registration_tokens: [\n { token: 'reg_token_1', platform: 'portfolio' },\n { token: 'reg_token_2', platform: 'extension' },\n ],\n};\n\nexport const getMockRetrievePushNotificationLinksResponse = () => {\n return {\n url: REGISTRATION_TOKENS_ENDPOINT,\n requestMethod: 'GET',\n response: MOCK_LINKS_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockUpdatePushNotificationLinksResponse = () => {\n return {\n url: REGISTRATION_TOKENS_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const MOCK_FCM_RESPONSE = {\n name: '',\n token: 'fcm-token',\n web: {\n endpoint: '',\n p256dh: '',\n auth: '',\n applicationPubKey: '',\n },\n};\n\nexport const getMockCreateFCMRegistrationTokenResponse = () => {\n return {\n url: /^https:\\/\\/fcmregistrations\\.googleapis\\.com\\/v1\\/projects\\/.*$/u,\n requestMethod: 'POST',\n response: MOCK_FCM_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockDeleteFCMRegistrationTokenResponse = () => {\n return {\n url: /^https:\\/\\/fcmregistrations\\.googleapis\\.com\\/v1\\/projects\\/.*$/u,\n requestMethod: 'POST',\n response: {},\n } satisfies MockResponse;\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockResponse.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/mockResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iCAA6B;AAQxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,mBAAmB,EAAE,WAMjC,CAAC;AAEF,eAAO,MAAM,4CAA4C;;;;CAMxD,CAAC;AAEF,eAAO,MAAM,0CAA0C;;;;CAMtD,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;CAS7B,CAAC;AAEF,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;CAMrD,CAAC;AAEF,eAAO,MAAM,yCAAyC;;;;CAMrD,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockResponse.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/mocks/mockResponse.ts"],"names":[],"mappings":"A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ACR,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,EAAE;IAC5D,OAAO;QACL,GAAG,EAAE,kEAAkE;QACvE,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,iBAAiB;KACL,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,EAAE;IAC5D,OAAO;QACL,GAAG,EAAE,kEAAkE;QACvE,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,EAAE;KACU,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import { REGISTRATION_TOKENS_ENDPOINT } from '../services/endpoints';\nimport type { LinksResult } from '../services/services';\n\ntype MockResponse = {\n url: string | RegExp;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_REG_TOKEN = 'REG_TOKEN';\nexport const MOCK_LINKS_RESPONSE: LinksResult = {\n trigger_ids: ['1', '2', '3'],\n registration_tokens: [\n { token: 'reg_token_1', platform: 'portfolio' },\n { token: 'reg_token_2', platform: 'extension' },\n ],\n};\n\nexport const getMockRetrievePushNotificationLinksResponse = () => {\n return {\n url: REGISTRATION_TOKENS_ENDPOINT,\n requestMethod: 'GET',\n response: MOCK_LINKS_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockUpdatePushNotificationLinksResponse = () => {\n return {\n url: REGISTRATION_TOKENS_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const MOCK_FCM_RESPONSE = {\n name: '',\n token: 'fcm-token',\n web: {\n endpoint: '',\n p256dh: '',\n auth: '',\n applicationPubKey: '',\n },\n};\n\nexport const getMockCreateFCMRegistrationTokenResponse = () => {\n return {\n url: /^https:\\/\\/fcmregistrations\\.googleapis\\.com\\/v1\\/projects\\/.*$/u,\n requestMethod: 'POST',\n response: MOCK_FCM_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockDeleteFCMRegistrationTokenResponse = () => {\n return {\n url: /^https:\\/\\/fcmregistrations\\.googleapis\\.com\\/v1\\/projects\\/.*$/u,\n requestMethod: 'POST',\n response: {},\n } satisfies MockResponse;\n};\n"]}
@@ -23,9 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.listenToPushNotifications = exports.updateTriggerPushNotifications = exports.deactivatePushNotifications = exports.activatePushNotifications = exports.updateLinksAPI = void 0;
26
+ exports.updateTriggerPushNotifications = exports.deactivatePushNotifications = exports.activatePushNotifications = exports.updateLinksAPI = void 0;
27
27
  const endpoints = __importStar(require("./endpoints.cjs"));
28
- const push_web_1 = require("./push/push-web.cjs");
29
28
  /**
30
29
  * Updates the push notification links on a remote API.
31
30
  *
@@ -62,8 +61,8 @@ exports.updateLinksAPI = updateLinksAPI;
62
61
  * @returns A promise that resolves with an object containing the success status and the BearerToken token.
63
62
  */
64
63
  async function activatePushNotifications(params) {
65
- const { bearerToken, triggers, env, createRegToken, platform, fcmToken } = params;
66
- const regToken = fcmToken ?? (await createRegToken(env).catch(() => null));
64
+ const { bearerToken, triggers, env, createRegToken, platform } = params;
65
+ const regToken = await createRegToken(env).catch(() => null);
67
66
  if (!regToken) {
68
67
  return null;
69
68
  }
@@ -108,33 +107,15 @@ async function updateTriggerPushNotifications(params) {
108
107
  if (!newRegToken) {
109
108
  throw new Error('Failed to create a new registration token');
110
109
  }
111
- const isTriggersLinkedToPushNotifications = await updateLinksAPI(bearerToken, triggers, [{ token: newRegToken, platform }]);
110
+ const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [
111
+ { token: newRegToken, platform },
112
+ ]);
113
+ if (!linksNotUpdated) {
114
+ throw new Error('Failed to create links to new reg token');
115
+ }
112
116
  return {
113
- isTriggersLinkedToPushNotifications,
114
117
  fcmToken: newRegToken,
115
118
  };
116
119
  }
117
120
  exports.updateTriggerPushNotifications = updateTriggerPushNotifications;
118
- /**
119
- * Listens to push notifications and invokes the provided callback function with the received notification data.
120
- *
121
- * @param params - listen params
122
- * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.
123
- */
124
- async function listenToPushNotifications(params) {
125
- const { env, listenToPushReceived, listenToPushClicked } = params;
126
- /*
127
- Push notifications require 2 listeners that need tracking (when creating and for tearing down):
128
- 1. handling receiving a push notification (and the content we want to display)
129
- 2. handling when a user clicks on a push notification
130
- */
131
- const unsubscribePushNotifications = await (0, push_web_1.listenToPushNotificationsReceived)(env, listenToPushReceived);
132
- const unsubscribeNotificationClicks = (0, push_web_1.listenToPushNotificationsClicked)(listenToPushClicked);
133
- const unsubscribe = () => {
134
- unsubscribePushNotifications?.();
135
- unsubscribeNotificationClicks();
136
- };
137
- return unsubscribe;
138
- }
139
- exports.listenToPushNotifications = listenToPushNotifications;
140
121
  //# sourceMappingURL=services.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAyC;AAEzC,kDAGyB;AAkBzB;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,QAAkB,EAClB,SAAqB;IAErB,IAAI;QACF,MAAM,IAAI,GAAgB;YACxB,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,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EX,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,mCAAmC,GAAG,MAAM,cAAc,CAC9D,WAAW,EACX,QAAQ,EACR,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CACnC,CAAC;IAEF,OAAO;QACL,mCAAmC;QACnC,QAAQ,EAAE,WAAW;KACtB,CAAC;AACJ,CAAC;AA/BD,wEA+BC;AAaD;;;;;GAKG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;IAElE;;;;MAIE;IACF,MAAM,4BAA4B,GAAG,MAAM,IAAA,4CAAiC,EAC1E,GAAG,EACH,oBAAoB,CACrB,CAAC;IACF,MAAM,6BAA6B,GACjC,IAAA,2CAAgC,EAAC,mBAAmB,CAAC,CAAC;IAExD,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,4BAA4B,EAAE,EAAE,CAAC;QACjC,6BAA6B,EAAE,CAAC;IAClC,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAvBD,8DAuBC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { CreateRegToken, DeleteRegToken } from './push';\nimport {\n listenToPushNotificationsClicked,\n listenToPushNotificationsReceived,\n} from './push/push-web';\nimport type { Types } from '../../NotificationServicesController';\nimport type { PushNotificationEnv } from '../types';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n trigger_ids: string[];\n\n registration_tokens: RegToken[];\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n trigger_ids: triggers,\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n fcmToken?: string;\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform, fcmToken } =\n params;\n\n const regToken = fcmToken ?? (await createRegToken(env).catch(() => null));\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI(bearerToken, triggers, [{ token: regToken, platform }]);\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n isTriggersLinkedToPushNotifications: boolean;\n fcmToken?: string | null;\n}> {\n const {\n bearerToken,\n triggers,\n createRegToken,\n platform,\n deleteRegToken,\n env,\n } = params;\n\n await deleteRegToken(env);\n const newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n\n const isTriggersLinkedToPushNotifications = await updateLinksAPI(\n bearerToken,\n triggers,\n [{ token: newRegToken, platform }],\n );\n\n return {\n isTriggersLinkedToPushNotifications,\n fcmToken: newRegToken,\n };\n}\n\ntype ListenToPushNotificationsParams = {\n env: PushNotificationEnv;\n listenToPushReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n listenToPushClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n};\n\n/**\n * Listens to push notifications and invokes the provided callback function with the received notification data.\n *\n * @param params - listen params\n * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.\n */\nexport async function listenToPushNotifications(\n params: ListenToPushNotificationsParams,\n): Promise<() => void> {\n const { env, listenToPushReceived, listenToPushClicked } = params;\n\n /*\n Push notifications require 2 listeners that need tracking (when creating and for tearing down):\n 1. handling receiving a push notification (and the content we want to display)\n 2. handling when a user clicks on a push notification\n */\n const unsubscribePushNotifications = await listenToPushNotificationsReceived(\n env,\n listenToPushReceived,\n );\n const unsubscribeNotificationClicks =\n listenToPushNotificationsClicked(listenToPushClicked);\n\n const unsubscribe = () => {\n unsubscribePushNotifications?.();\n unsubscribeNotificationClicks();\n };\n\n return unsubscribe;\n}\n"]}
1
+ {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAyC;AAoBzC;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,QAAkB,EAClB,SAAqB;IAErB,IAAI;QACF,MAAM,IAAI,GAAgB;YACxB,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC;KAChC;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAtBD,wCAsBC;AAaD;;;;;GAKG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAAuC;IAEvC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAExE,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,QAAQ,E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C","sourcesContent":["import * as endpoints from './endpoints';\nimport type { PushNotificationEnv } from '../types';\nimport type {\n CreateRegToken,\n DeleteRegToken,\n} from '../types/push-service-interface';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n trigger_ids: string[];\n registration_tokens: RegToken[];\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n trigger_ids: triggers,\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform } = params;\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI(bearerToken, triggers, [{ token: regToken, platform }]);\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n fcmToken: string;\n}> {\n const {\n bearerToken,\n triggers,\n createRegToken,\n platform,\n deleteRegToken,\n env,\n } = params;\n\n await deleteRegToken(env);\n const newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n\n const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [\n { token: newRegToken, platform },\n ]);\n if (!linksNotUpdated) {\n throw new Error('Failed to create links to new reg token');\n }\n\n return {\n fcmToken: newRegToken,\n };\n}\n"]}
@@ -1,6 +1,5 @@
1
- import type { CreateRegToken, DeleteRegToken } from "./push/index.cjs";
2
- import type { Types } from "../../NotificationServicesController/index.cjs";
3
1
  import type { PushNotificationEnv } from "../types/index.cjs";
2
+ import type { CreateRegToken, DeleteRegToken } from "../types/push-service-interface.cjs";
4
3
  export type RegToken = {
5
4
  token: string;
6
5
  platform: 'extension' | 'mobile' | 'portfolio';
@@ -27,7 +26,6 @@ type ActivatePushNotificationsParams = {
27
26
  env: PushNotificationEnv;
28
27
  createRegToken: CreateRegToken;
29
28
  platform: 'extension' | 'mobile' | 'portfolio';
30
- fcmToken?: string;
31
29
  };
32
30
  /**
33
31
  * Enables push notifications by registering the device and linking triggers.
@@ -68,20 +66,7 @@ type UpdateTriggerPushNotificationsParams = {
68
66
  * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.
69
67
  */
70
68
  export declare function updateTriggerPushNotifications(params: UpdateTriggerPushNotificationsParams): Promise<{
71
- isTriggersLinkedToPushNotifications: boolean;
72
- fcmToken?: string | null;
69
+ fcmToken: string;
73
70
  }>;
74
- type ListenToPushNotificationsParams = {
75
- env: PushNotificationEnv;
76
- listenToPushReceived: (notification: Types.INotification) => void | Promise<void>;
77
- listenToPushClicked: (event: NotificationEvent, notification?: Types.INotification) => void;
78
- };
79
- /**
80
- * Listens to push notifications and invokes the provided callback function with the received notification data.
81
- *
82
- * @param params - listen params
83
- * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.
84
- */
85
- export declare function listenToPushNotifications(params: ListenToPushNotificationsParams): Promise<() => void>;
86
71
  export {};
87
72
  //# sourceMappingURL=services.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,yBAAe;AAK7D,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AAEpD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,C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ClD,MAAM,EAAE,oCAAoC,GAC3C,OAAO,CAAC;IACT,mCAAmC,EAAE,OAAO,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC,CA0BD;AAED,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,mBAAmB,CAAC;IACzB,oBAAoB,EAAE,CACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,mBAAmB,EAAE,CACnB,KAAK,EAAE,iBAAiB,EACxB,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,KAC/B,IAAI,CAAC;CACX,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,MAAM,IAAI,CAAC,CAqBrB"}
1
+ {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACf,4CAAwC;AAEzC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,EAAE,QAAQ,EAAE,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAkBlB;AAED,KAAK,+BAA+B,GAAG;IAErC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAGnB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxB;AAED,KAAK,iCAAiC,GAAG;IAEvC,QAAQ,EAAE,MAAM,CAAC;IAGjB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,OAAO,CAAC,CAclB;AAED,KAAK,oCAAoC,GAAG;IAE1C,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAGnB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAG/C,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,oCAAoC,GAC3C,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CA0BD"}
@@ -1,6 +1,5 @@
1
- import type { CreateRegToken, DeleteRegToken } from "./push/index.mjs";
2
- import type { Types } from "../../NotificationServicesController/index.mjs";
3
1
  import type { PushNotificationEnv } from "../types/index.mjs";
2
+ import type { CreateRegToken, DeleteRegToken } from "../types/push-service-interface.mjs";
4
3
  export type RegToken = {
5
4
  token: string;
6
5
  platform: 'extension' | 'mobile' | 'portfolio';
@@ -27,7 +26,6 @@ type ActivatePushNotificationsParams = {
27
26
  env: PushNotificationEnv;
28
27
  createRegToken: CreateRegToken;
29
28
  platform: 'extension' | 'mobile' | 'portfolio';
30
- fcmToken?: string;
31
29
  };
32
30
  /**
33
31
  * Enables push notifications by registering the device and linking triggers.
@@ -68,20 +66,7 @@ type UpdateTriggerPushNotificationsParams = {
68
66
  * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.
69
67
  */
70
68
  export declare function updateTriggerPushNotifications(params: UpdateTriggerPushNotificationsParams): Promise<{
71
- isTriggersLinkedToPushNotifications: boolean;
72
- fcmToken?: string | null;
69
+ fcmToken: string;
73
70
  }>;
74
- type ListenToPushNotificationsParams = {
75
- env: PushNotificationEnv;
76
- listenToPushReceived: (notification: Types.INotification) => void | Promise<void>;
77
- listenToPushClicked: (event: NotificationEvent, notification?: Types.INotification) => void;
78
- };
79
- /**
80
- * Listens to push notifications and invokes the provided callback function with the received notification data.
81
- *
82
- * @param params - listen params
83
- * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.
84
- */
85
- export declare function listenToPushNotifications(params: ListenToPushNotificationsParams): Promise<() => void>;
86
71
  export {};
87
72
  //# sourceMappingURL=services.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,yBAAe;AAK7D,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AAEpD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,mBAAmB,EAAE,QAAQ,EAAE,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAA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,oBAAoB,EAAE,CACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,mBAAmB,EAAE,CACnB,KAAK,EAAE,iBAAiB,EACxB,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,KAC/B,IAAI,CAAC;CACX,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,MAAM,IAAI,CAAC,CAqBrB"}
1
+ {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACf,4CAAwC;AAEzC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,EAAE,QAAQ,EAAE,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAkBlB;AAED,KAAK,+BAA+B,GAAG;IAErC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAGnB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxB;AAED,KAAK,iCAAiC,GAAG;IAEvC,QAAQ,EAAE,MAAM,CAAC;IAGjB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,OAAO,CAAC,CAclB;AAED,KAAK,oCAAoC,GAAG;IAE1C,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAGnB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAG/C,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,oCAAoC,GAC3C,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CA0BD"}
@@ -1,5 +1,4 @@
1
1
  import * as endpoints from "./endpoints.mjs";
2
- import { listenToPushNotificationsClicked, listenToPushNotificationsReceived } from "./push/push-web.mjs";
3
2
  /**
4
3
  * Updates the push notification links on a remote API.
5
4
  *
@@ -35,8 +34,8 @@ export async function updateLinksAPI(bearerToken, triggers, regTokens) {
35
34
  * @returns A promise that resolves with an object containing the success status and the BearerToken token.
36
35
  */
37
36
  export async function activatePushNotifications(params) {
38
- const { bearerToken, triggers, env, createRegToken, platform, fcmToken } = params;
39
- const regToken = fcmToken ?? (await createRegToken(env).catch(() => null));
37
+ const { bearerToken, triggers, env, createRegToken, platform } = params;
38
+ const regToken = await createRegToken(env).catch(() => null);
40
39
  if (!regToken) {
41
40
  return null;
42
41
  }
@@ -79,31 +78,14 @@ export async function updateTriggerPushNotifications(params) {
79
78
  if (!newRegToken) {
80
79
  throw new Error('Failed to create a new registration token');
81
80
  }
82
- const isTriggersLinkedToPushNotifications = await updateLinksAPI(bearerToken, triggers, [{ token: newRegToken, platform }]);
81
+ const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [
82
+ { token: newRegToken, platform },
83
+ ]);
84
+ if (!linksNotUpdated) {
85
+ throw new Error('Failed to create links to new reg token');
86
+ }
83
87
  return {
84
- isTriggersLinkedToPushNotifications,
85
88
  fcmToken: newRegToken,
86
89
  };
87
90
  }
88
- /**
89
- * Listens to push notifications and invokes the provided callback function with the received notification data.
90
- *
91
- * @param params - listen params
92
- * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.
93
- */
94
- export async function listenToPushNotifications(params) {
95
- const { env, listenToPushReceived, listenToPushClicked } = params;
96
- /*
97
- Push notifications require 2 listeners that need tracking (when creating and for tearing down):
98
- 1. handling receiving a push notification (and the content we want to display)
99
- 2. handling when a user clicks on a push notification
100
- */
101
- const unsubscribePushNotifications = await listenToPushNotificationsReceived(env, listenToPushReceived);
102
- const unsubscribeNotificationClicks = listenToPushNotificationsClicked(listenToPushClicked);
103
- const unsubscribe = () => {
104
- unsubscribePushNotifications?.();
105
- unsubscribeNotificationClicks();
106
- };
107
- return unsubscribe;
108
- }
109
91
  //# sourceMappingURL=services.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,wBAAoB;AAEzC,OAAO,EACL,gCAAgC,EAChC,iCAAiC,EAClC,4BAAwB;AAkBzB;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,QAAkB,EAClB,SAAqB;IAErB,IAAI;QACF,MAAM,IAAI,GAAgB;YACxB,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,EA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AAC,KAAK,UAAU,8BAA8B,CAClD,MAA4C;IAK5C,MAAM,EACJ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACd,GAAG,GACJ,GAAG,MAAM,CAAC;IAEX,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,mCAAmC,GAAG,MAAM,cAAc,CAC9D,WAAW,EACX,QAAQ,EACR,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CACnC,CAAC;IAEF,OAAO;QACL,mCAAmC;QACnC,QAAQ,EAAE,WAAW;KACtB,CAAC;AACJ,CAAC;AAaD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;IAElE;;;;MAIE;IACF,MAAM,4BAA4B,GAAG,MAAM,iCAAiC,CAC1E,GAAG,EACH,oBAAoB,CACrB,CAAC;IACF,MAAM,6BAA6B,GACjC,gCAAgC,CAAC,mBAAmB,CAAC,CAAC;IAExD,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,4BAA4B,EAAE,EAAE,CAAC;QACjC,6BAA6B,EAAE,CAAC;IAClC,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { CreateRegToken, DeleteRegToken } from './push';\nimport {\n listenToPushNotificationsClicked,\n listenToPushNotificationsReceived,\n} from './push/push-web';\nimport type { Types } from '../../NotificationServicesController';\nimport type { PushNotificationEnv } from '../types';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n trigger_ids: string[];\n\n registration_tokens: RegToken[];\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n trigger_ids: triggers,\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n fcmToken?: string;\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform, fcmToken } =\n params;\n\n const regToken = fcmToken ?? (await createRegToken(env).catch(() => null));\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI(bearerToken, triggers, [{ token: regToken, platform }]);\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n isTriggersLinkedToPushNotifications: boolean;\n fcmToken?: string | null;\n}> {\n const {\n bearerToken,\n triggers,\n createRegToken,\n platform,\n deleteRegToken,\n env,\n } = params;\n\n await deleteRegToken(env);\n const newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n\n const isTriggersLinkedToPushNotifications = await updateLinksAPI(\n bearerToken,\n triggers,\n [{ token: newRegToken, platform }],\n );\n\n return {\n isTriggersLinkedToPushNotifications,\n fcmToken: newRegToken,\n };\n}\n\ntype ListenToPushNotificationsParams = {\n env: PushNotificationEnv;\n listenToPushReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n listenToPushClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n};\n\n/**\n * Listens to push notifications and invokes the provided callback function with the received notification data.\n *\n * @param params - listen params\n * @returns A promise that resolves to an unsubscribe function to stop listening to push notifications.\n */\nexport async function listenToPushNotifications(\n params: ListenToPushNotificationsParams,\n): Promise<() => void> {\n const { env, listenToPushReceived, listenToPushClicked } = params;\n\n /*\n Push notifications require 2 listeners that need tracking (when creating and for tearing down):\n 1. handling receiving a push notification (and the content we want to display)\n 2. handling when a user clicks on a push notification\n */\n const unsubscribePushNotifications = await listenToPushNotificationsReceived(\n env,\n listenToPushReceived,\n );\n const unsubscribeNotificationClicks =\n listenToPushNotificationsClicked(listenToPushClicked);\n\n const unsubscribe = () => {\n unsubscribePushNotifications?.();\n unsubscribeNotificationClicks();\n };\n\n return unsubscribe;\n}\n"]}
1
+ {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,wBAAoB;AAoBzC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,QAAkB,EAClB,SAAqB;IAErB,IAAI;QACF,MAAM,IAAI,GAAgB;YACxB,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC;KAChC;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAaD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAuC;IAEvC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAExE,MAAM,QAAQ,GAAG,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,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,OAAO;QACL,QAAQ,EAAE,WAAW;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { PushNotificationEnv } from '../types';\nimport type {\n CreateRegToken,\n DeleteRegToken,\n} from '../types/push-service-interface';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n trigger_ids: string[];\n registration_tokens: RegToken[];\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n trigger_ids: triggers,\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform } = params;\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI(bearerToken, triggers, [{ token: regToken, platform }]);\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n fcmToken: string;\n}> {\n const {\n bearerToken,\n triggers,\n createRegToken,\n platform,\n deleteRegToken,\n env,\n } = params;\n\n await deleteRegToken(env);\n const newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n\n const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [\n { token: newRegToken, platform },\n ]);\n if (!linksNotUpdated) {\n throw new Error('Failed to create links to new reg token');\n }\n\n return {\n fcmToken: newRegToken,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type * from './firebase';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type * from './firebase';\nexport type * from './push-service-interface';\n"]}
@@ -1,2 +1,3 @@
1
1
  export type * from "./firebase.cjs";
2
+ export type * from "./push-service-interface.cjs";
2
3
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"AAAA,oCAAgC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,kDAA8C"}
@@ -1,2 +1,3 @@
1
1
  export type * from "./firebase.mjs";
2
+ export type * from "./push-service-interface.mjs";
2
3
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"AAAA,oCAAgC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,kDAA8C"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type * from './firebase';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type * from './firebase';\nexport type * from './push-service-interface';\n"]}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.cjs.map
3
+ //# sourceMappingURL=push-service-interface.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-service-interface.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/push-service-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { PushNotificationEnv } from '.';\n\ntype Unsubscribe = () => void;\n\n/**\n * Firebase - allows creating of a registration token for push notifications\n */\nexport type CreateRegToken = (\n env: PushNotificationEnv,\n) => Promise<string | null>;\n\n/**\n * Firebase - allows deleting a reg token. Returns true if successful, otherwise false if failed\n */\nexport type DeleteRegToken = (env: PushNotificationEnv) => Promise<boolean>;\n\n/**\n * Firebase + Platform Specific Logic.\n * Will be used to subscribe to the `onMessage` and `onBackgroundMessage` handlers\n * But will also need client specific logic for showing a notification and clicking a notification\n * (browser APIs for web, and Notifee on mobile)\n *\n * We can either create \"creator\"/\"builder\" function in platform specific files (see push-web.ts),\n * Or the platform needs to correctly handle:\n * - subscriptions\n * - click events\n * - publishing PushController events using it's messenger\n */\nexport type SubscribeToPushNotifications = (\n env: PushNotificationEnv,\n) => Promise<Unsubscribe | null>;\n\nexport type PushService = {\n createRegToken: CreateRegToken;\n\n deleteRegToken: DeleteRegToken;\n\n subscribeToPushNotifications: SubscribeToPushNotifications;\n};\n"]}
@@ -0,0 +1,30 @@
1
+ import type { PushNotificationEnv } from "./index.cjs";
2
+ type Unsubscribe = () => void;
3
+ /**
4
+ * Firebase - allows creating of a registration token for push notifications
5
+ */
6
+ export type CreateRegToken = (env: PushNotificationEnv) => Promise<string | null>;
7
+ /**
8
+ * Firebase - allows deleting a reg token. Returns true if successful, otherwise false if failed
9
+ */
10
+ export type DeleteRegToken = (env: PushNotificationEnv) => Promise<boolean>;
11
+ /**
12
+ * Firebase + Platform Specific Logic.
13
+ * Will be used to subscribe to the `onMessage` and `onBackgroundMessage` handlers
14
+ * But will also need client specific logic for showing a notification and clicking a notification
15
+ * (browser APIs for web, and Notifee on mobile)
16
+ *
17
+ * We can either create "creator"/"builder" function in platform specific files (see push-web.ts),
18
+ * Or the platform needs to correctly handle:
19
+ * - subscriptions
20
+ * - click events
21
+ * - publishing PushController events using it's messenger
22
+ */
23
+ export type SubscribeToPushNotifications = (env: PushNotificationEnv) => Promise<Unsubscribe | null>;
24
+ export type PushService = {
25
+ createRegToken: CreateRegToken;
26
+ deleteRegToken: DeleteRegToken;
27
+ subscribeToPushNotifications: SubscribeToPushNotifications;
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=push-service-interface.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-service-interface.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/push-service-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAU;AAE7C,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,mBAAmB,KACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE5E;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,4BAA4B,GAAG,CACzC,GAAG,EAAE,mBAAmB,KACrB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AAEjC,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,cAAc,CAAC;IAE/B,cAAc,EAAE,cAAc,CAAC;IAE/B,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { PushNotificationEnv } from "./index.mjs";
2
+ type Unsubscribe = () => void;
3
+ /**
4
+ * Firebase - allows creating of a registration token for push notifications
5
+ */
6
+ export type CreateRegToken = (env: PushNotificationEnv) => Promise<string | null>;
7
+ /**
8
+ * Firebase - allows deleting a reg token. Returns true if successful, otherwise false if failed
9
+ */
10
+ export type DeleteRegToken = (env: PushNotificationEnv) => Promise<boolean>;
11
+ /**
12
+ * Firebase + Platform Specific Logic.
13
+ * Will be used to subscribe to the `onMessage` and `onBackgroundMessage` handlers
14
+ * But will also need client specific logic for showing a notification and clicking a notification
15
+ * (browser APIs for web, and Notifee on mobile)
16
+ *
17
+ * We can either create "creator"/"builder" function in platform specific files (see push-web.ts),
18
+ * Or the platform needs to correctly handle:
19
+ * - subscriptions
20
+ * - click events
21
+ * - publishing PushController events using it's messenger
22
+ */
23
+ export type SubscribeToPushNotifications = (env: PushNotificationEnv) => Promise<Unsubscribe | null>;
24
+ export type PushService = {
25
+ createRegToken: CreateRegToken;
26
+ deleteRegToken: DeleteRegToken;
27
+ subscribeToPushNotifications: SubscribeToPushNotifications;
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=push-service-interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-service-interface.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/push-service-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAU;AAE7C,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,mBAAmB,KACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE5E;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,4BAA4B,GAAG,CACzC,GAAG,EAAE,mBAAmB,KACrB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AAEjC,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,cAAc,CAAC;IAE/B,cAAc,EAAE,cAAc,CAAC;IAE/B,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=push-service-interface.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-service-interface.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/types/push-service-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { PushNotificationEnv } from '.';\n\ntype Unsubscribe = () => void;\n\n/**\n * Firebase - allows creating of a registration token for push notifications\n */\nexport type CreateRegToken = (\n env: PushNotificationEnv,\n) => Promise<string | null>;\n\n/**\n * Firebase - allows deleting a reg token. Returns true if successful, otherwise false if failed\n */\nexport type DeleteRegToken = (env: PushNotificationEnv) => Promise<boolean>;\n\n/**\n * Firebase + Platform Specific Logic.\n * Will be used to subscribe to the `onMessage` and `onBackgroundMessage` handlers\n * But will also need client specific logic for showing a notification and clicking a notification\n * (browser APIs for web, and Notifee on mobile)\n *\n * We can either create \"creator\"/\"builder\" function in platform specific files (see push-web.ts),\n * Or the platform needs to correctly handle:\n * - subscriptions\n * - click events\n * - publishing PushController events using it's messenger\n */\nexport type SubscribeToPushNotifications = (\n env: PushNotificationEnv,\n) => Promise<Unsubscribe | null>;\n\nexport type PushService = {\n createRegToken: CreateRegToken;\n\n deleteRegToken: DeleteRegToken;\n\n subscribeToPushNotifications: SubscribeToPushNotifications;\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOnChainPushNotificationMessage = exports.isOnChainNotification = exports.createOnChainPushNotificationMessages = void 0;
3
+ exports.createOnChainPushNotificationMessage = exports.createOnChainPushNotificationMessages = void 0;
4
4
  const get_notification_data_1 = require("./get-notification-data.cjs");
5
5
  const NotificationServicesController_1 = require("../../NotificationServicesController/index.cjs");
6
6
  /**
@@ -137,24 +137,6 @@ exports.createOnChainPushNotificationMessages = createOnChainPushNotificationMes
137
137
  function getChainSymbol(chainId) {
138
138
  return NotificationServicesController_1.Constants.CHAIN_SYMBOLS[chainId] ?? null;
139
139
  }
140
- /**
141
- * Checks if the given value is an OnChainRawNotification object.
142
- *
143
- * @param n - The value to check.
144
- * @returns True if the value is an OnChainRawNotification object, false otherwise.
145
- */
146
- function isOnChainNotification(n) {
147
- const assumed = n;
148
- // We don't have a validation/parsing library to check all possible types of an on chain notification
149
- // It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
150
- const isValidEnoughToBeOnChainNotification = [
151
- assumed?.id,
152
- assumed?.data,
153
- assumed?.trigger_id,
154
- ].every((field) => field !== undefined);
155
- return isValidEnoughToBeOnChainNotification;
156
- }
157
- exports.isOnChainNotification = isOnChainNotification;
158
140
  /**
159
141
  * Creates a push notification message based on the given on-chain raw notification.
160
142
  *