@metamask/notification-services-controller 21.0.0 → 22.1.0

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 (193) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +56 -42
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +3 -2
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +3 -2
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +56 -41
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.cjs +4 -12
  11. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  12. package/dist/NotificationServicesController/constants/notification-schema.d.cts +0 -12
  13. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/constants/notification-schema.d.mts +0 -12
  15. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -11
  17. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  18. package/dist/NotificationServicesController/index.cjs +1 -2
  19. package/dist/NotificationServicesController/index.cjs.map +1 -1
  20. package/dist/NotificationServicesController/index.d.cts +0 -1
  21. package/dist/NotificationServicesController/index.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/index.d.mts +0 -1
  23. package/dist/NotificationServicesController/index.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/index.mjs +0 -1
  25. package/dist/NotificationServicesController/index.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs +2 -2
  27. package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.cts.map +1 -1
  29. package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.mts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs +2 -2
  31. package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs.map +1 -1
  32. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +120 -0
  33. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -1
  34. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -1
  35. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -1
  36. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs +120 -0
  37. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -1
  38. package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs.map +1 -1
  39. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts +1 -1
  40. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts.map +1 -1
  41. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts +1 -1
  42. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts.map +1 -1
  43. package/dist/NotificationServicesController/mocks/mock-snap-notification.mjs.map +1 -1
  44. package/dist/NotificationServicesController/mocks/mockResponses.cjs +6 -0
  45. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  46. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  47. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  48. package/dist/NotificationServicesController/mocks/mockResponses.mjs +6 -0
  49. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  50. package/dist/NotificationServicesController/processors/process-notifications.cjs +11 -9
  51. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  52. package/dist/NotificationServicesController/processors/process-notifications.d.cts +1 -563
  53. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  54. package/dist/NotificationServicesController/processors/process-notifications.d.mts +1 -563
  55. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  56. package/dist/NotificationServicesController/processors/process-notifications.mjs +11 -9
  57. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  58. package/dist/NotificationServicesController/processors/process-snap-notifications.cjs.map +1 -1
  59. package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts +1 -1
  60. package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts.map +1 -1
  61. package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts +1 -1
  62. package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts.map +1 -1
  63. package/dist/NotificationServicesController/processors/process-snap-notifications.mjs.map +1 -1
  64. package/dist/NotificationServicesController/services/api-notifications.cjs +21 -21
  65. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
  66. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
  67. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
  68. package/dist/NotificationServicesController/services/api-notifications.mjs +21 -21
  69. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
  70. package/dist/NotificationServicesController/services/feature-announcements.cjs +19 -10
  71. package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
  72. package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -1
  73. package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -1
  74. package/dist/NotificationServicesController/services/feature-announcements.mjs +19 -10
  75. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
  76. package/dist/NotificationServicesController/services/notification-config-cache.cjs +4 -4
  77. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
  78. package/dist/NotificationServicesController/services/notification-config-cache.mjs +4 -4
  79. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
  80. package/dist/NotificationServicesController/services/perp-notifications.cjs +2 -2
  81. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  82. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  83. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  84. package/dist/NotificationServicesController/services/perp-notifications.mjs +2 -2
  85. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  86. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
  87. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts +2 -0
  88. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
  89. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +2 -0
  90. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
  91. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
  92. package/dist/NotificationServicesController/types/notification-api/schema.cjs +2 -0
  93. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -1
  94. package/dist/NotificationServicesController/types/notification-api/schema.d.cts +23 -0
  95. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -1
  96. package/dist/NotificationServicesController/types/notification-api/schema.d.mts +23 -0
  97. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -1
  98. package/dist/NotificationServicesController/types/notification-api/schema.mjs +2 -0
  99. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -1
  100. package/dist/NotificationServicesController/types/perps/schema.cjs +2 -0
  101. package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -1
  102. package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -1
  103. package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -1
  104. package/dist/NotificationServicesController/types/perps/schema.mjs +2 -0
  105. package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -1
  106. package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
  107. package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -1
  108. package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -1
  109. package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
  110. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -1
  111. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -1
  112. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -1
  113. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -1
  114. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +0 -1
  115. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  116. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +1 -1
  117. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  118. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +1 -1
  119. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  120. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +0 -1
  121. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  122. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  123. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +9 -24
  124. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  125. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +9 -24
  126. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  127. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  128. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  129. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  130. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  131. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  132. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  133. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  134. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  135. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  136. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +4 -4
  137. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
  138. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts +2 -2
  139. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -1
  140. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +2 -2
  141. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -1
  142. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +4 -4
  143. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
  144. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +62 -71
  145. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  146. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +9 -9
  147. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  148. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +9 -9
  149. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  150. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +62 -71
  151. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  152. package/dist/NotificationServicesPushController/web/push-utils.cjs +15 -7
  153. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
  154. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
  155. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
  156. package/dist/NotificationServicesPushController/web/push-utils.mjs +16 -8
  157. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  158. package/dist/shared/is-onchain-notification.cjs +3 -3
  159. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  160. package/dist/shared/is-onchain-notification.d.cts +2 -2
  161. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  162. package/dist/shared/is-onchain-notification.d.mts +2 -2
  163. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  164. package/dist/shared/is-onchain-notification.mjs +3 -3
  165. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  166. package/dist/shared/to-raw-notification.cjs.map +1 -1
  167. package/dist/shared/to-raw-notification.mjs.map +1 -1
  168. package/package.json +12 -25
  169. package/dist/NotificationServicesController/ui/constants.cjs +0 -75
  170. package/dist/NotificationServicesController/ui/constants.cjs.map +0 -1
  171. package/dist/NotificationServicesController/ui/constants.d.cts +0 -66
  172. package/dist/NotificationServicesController/ui/constants.d.cts.map +0 -1
  173. package/dist/NotificationServicesController/ui/constants.d.mts +0 -66
  174. package/dist/NotificationServicesController/ui/constants.d.mts.map +0 -1
  175. package/dist/NotificationServicesController/ui/constants.mjs +0 -71
  176. package/dist/NotificationServicesController/ui/constants.mjs.map +0 -1
  177. package/dist/NotificationServicesController/ui/index.cjs +0 -18
  178. package/dist/NotificationServicesController/ui/index.cjs.map +0 -1
  179. package/dist/NotificationServicesController/ui/index.d.cts +0 -2
  180. package/dist/NotificationServicesController/ui/index.d.cts.map +0 -1
  181. package/dist/NotificationServicesController/ui/index.d.mts +0 -2
  182. package/dist/NotificationServicesController/ui/index.d.mts.map +0 -1
  183. package/dist/NotificationServicesController/ui/index.mjs +0 -2
  184. package/dist/NotificationServicesController/ui/index.mjs.map +0 -1
  185. package/dist/NotificationServicesPushController/services/push/push-web.cjs +0 -145
  186. package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +0 -1
  187. package/dist/NotificationServicesPushController/services/push/push-web.d.cts +0 -34
  188. package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +0 -1
  189. package/dist/NotificationServicesPushController/services/push/push-web.d.mts +0 -34
  190. package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +0 -1
  191. package/dist/NotificationServicesPushController/services/push/push-web.mjs +0 -142
  192. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +0 -1
  193. package/notification-services/ui/package.json +0 -9
@@ -1 +1 @@
1
- {"version":3,"file":"push-utils.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAGlE,OAAO,KAAK,EAAE,2CAA2C,EAAE,kDAA8C;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,8BAA0B;AAM7D,eAAO,IAAI,cAAc,EAAE,OAAO,GAAG,IAAW,CAAC;AAsCjD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAuED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE;IACxD,iBAAiB,EAAE,CACjB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,cAAc,EAAE,CACd,CAAC,EAAE,iBAAiB,EACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,CAAC;IACV,SAAS,EAAE,2CAA2C,CAAC;CACxD,SAC6B,mBAAmB,yBA4BhD"}
1
+ {"version":3,"file":"push-utils.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAMlE,OAAO,KAAK,EAAE,2CAA2C,EAAE,kDAA8C;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,8BAA0B;AAM7D,eAAO,IAAI,cAAc,EAAE,OAAO,GAAG,IAAW,CAAC;AAyCjD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,CAYlB;AA+ED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE;IACxD,iBAAiB,EAAE,CACjB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,cAAc,EAAE,CACd,CAAC,EAAE,iBAAiB,EACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,CAAC;IACV,SAAS,EAAE,2CAA2C,CAAC;CACxD,GAAG,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,MAAM,IAAI,CAAC,CA6BpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"push-utils.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAGlE,OAAO,KAAK,EAAE,2CAA2C,EAAE,kDAA8C;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,8BAA0B;AAM7D,eAAO,IAAI,cAAc,EAAE,OAAO,GAAG,IAAW,CAAC;AAsCjD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAuED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE;IACxD,iBAAiB,EAAE,CACjB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,cAAc,EAAE,CACd,CAAC,EAAE,iBAAiB,EACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,CAAC;IACV,SAAS,EAAE,2CAA2C,CAAC;CACxD,SAC6B,mBAAmB,yBA4BhD"}
1
+ {"version":3,"file":"push-utils.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAMlE,OAAO,KAAK,EAAE,2CAA2C,EAAE,kDAA8C;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,8BAA0B;AAM7D,eAAO,IAAI,cAAc,EAAE,OAAO,GAAG,IAAW,CAAC;AAyCjD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,CAYlB;AA+ED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE;IACxD,iBAAiB,EAAE,CACjB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,cAAc,EAAE,CACd,CAAC,EAAE,iBAAiB,EACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,CAAC;IACV,SAAS,EAAE,2CAA2C,CAAC;CACxD,GAAG,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,MAAM,IAAI,CAAC,CA6BpD"}
@@ -9,12 +9,15 @@ import { getToken, deleteToken } from "firebase/messaging";
9
9
  import { getMessaging, onBackgroundMessage, isSupported } from "firebase/messaging/sw";
10
10
  import $log from "loglevel";
11
11
  const log = $importDefault($log);
12
- import { Processors } from "../../NotificationServicesController/index.mjs";
12
+ import { isOnChainRawNotification, safeProcessNotification } from "../../NotificationServicesController/index.mjs";
13
13
  import { toRawAPINotification } from "../../shared/to-raw-notification.mjs";
14
14
  // Exported to help testing
15
15
  // eslint-disable-next-line import-x/no-mutable-exports
16
16
  export let supportedCache = null;
17
17
  const getPushAvailability = async () => {
18
+ // Race condition is acceptable here - worst case is isSupported() is called
19
+ // multiple times during initialization, which is harmless for caching a boolean
20
+ // eslint-disable-next-line require-atomic-updates
18
21
  supportedCache ?? (supportedCache = await isSupported());
19
22
  return supportedCache;
20
23
  };
@@ -100,16 +103,22 @@ async function listenToPushNotificationsReceived(env, handler) {
100
103
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
101
104
  async (payload) => {
102
105
  try {
103
- const data = payload?.data
104
- ?.data
105
- ? JSON.parse(payload?.data?.data)
106
- : undefined;
106
+ // MessagePayload shapes are not known
107
+ // TODO - provide open-api unfied backend/frontend types
108
+ // TODO - we will replace the underlying Data payload with the same Notification payload used by mobile
109
+ const data = JSON.parse(payload?.data?.data ?? 'null');
107
110
  if (!data) {
108
111
  return;
109
112
  }
113
+ if (!isOnChainRawNotification(data)) {
114
+ return;
115
+ }
110
116
  const notificationData = toRawAPINotification(data);
111
- const notification = Processors.processNotification(notificationData);
112
- await handler(notification);
117
+ const notification = safeProcessNotification(notificationData);
118
+ if (!notification) {
119
+ return;
120
+ }
121
+ await handler?.(notification);
113
122
  }
114
123
  catch (error) {
115
124
  // Do Nothing, cannot parse a bad notification
@@ -117,7 +126,6 @@ async function listenToPushNotificationsReceived(env, handler) {
117
126
  notification: payload?.data?.data,
118
127
  error,
119
128
  });
120
- throw new Error('Unable to send push notification');
121
129
  }
122
130
  });
123
131
  const unsubscribe = () => unsubscribePushNotifications();
@@ -1 +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,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pE,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 { toRawAPINotification } 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.UnprocessedRawNotification | undefined = payload?.data\n ?.data\n ? JSON.parse(payload?.data?.data)\n : undefined;\n\n if (!data) {\n return;\n }\n\n const notificationData = toRawAPINotification(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"]}
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,EACL,wBAAwB,EACxB,uBAAuB,EACxB,uDAA6C;AAC9C,OAAO,EAAE,oBAAoB,EAAE,6CAAyC;AAMxE,2BAA2B;AAC3B,uDAAuD;AACvD,MAAM,CAAC,IAAI,cAAc,GAAmB,IAAI,CAAC;AAEjD,MAAM,mBAAmB,GAAG,KAAK,IAAsB,EAAE;IACvD,4EAA4E;IAC5E,gFAAgF;IAChF,kDAAkD;IAClD,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,CAAC;QACH,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,aAAa,EAAE,GAAG,CAAC,aAAa;SACjC,CAAC;QACF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K,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,GAAS,EAAE,CAC7B,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,EAAiB,EAAE;YACpC,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,EAAQ,EAAE;YAC5B,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,GAAS,EAAE;YAC7B,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 {\n isOnChainRawNotification,\n safeProcessNotification,\n} from '../../NotificationServicesController';\nimport { toRawAPINotification } 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 (): Promise<boolean> => {\n // Race condition is acceptable here - worst case is isSupported() is called\n // multiple times during initialization, which is harmless for caching a boolean\n // eslint-disable-next-line require-atomic-updates\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): Promise<void> => {\n try {\n // MessagePayload shapes are not known\n // TODO - provide open-api unfied backend/frontend types\n // TODO - we will replace the underlying Data payload with the same Notification payload used by mobile\n const data: unknown | null = JSON.parse(payload?.data?.data ?? 'null');\n\n if (!data) {\n return;\n }\n\n if (!isOnChainRawNotification(data)) {\n return;\n }\n\n const notificationData = toRawAPINotification(data);\n const notification = safeProcessNotification(notificationData);\n\n if (!notification) {\n return;\n }\n\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 }\n },\n );\n\n const unsubscribe = (): void => 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): () => void {\n const clickHandler = (event: NotificationEvent): void => {\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 = (): void =>\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}): (env: PushNotificationEnv) => Promise<() => void> {\n return async function (env: PushNotificationEnv): Promise<() => void> {\n const onBackgroundMessageSub = await listenToPushNotificationsReceived(\n env,\n async (notification): Promise<void> => {\n props.messenger.publish(\n 'NotificationServicesPushController:onNewNotifications',\n notification,\n );\n await props.onReceivedHandler(notification);\n },\n );\n const onClickSub = listenToPushNotificationsClicked(\n (event, notification): void => {\n props.messenger.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n notification,\n );\n props.onClickHandler(event, notification);\n },\n );\n\n const unsubscribe = (): void => {\n onBackgroundMessageSub?.();\n onClickSub();\n };\n\n return unsubscribe;\n };\n}\n"]}
@@ -4,11 +4,11 @@ exports.isOnChainRawNotification = void 0;
4
4
  /**
5
5
  * Checks if the given value is an OnChainRawNotification object.
6
6
  *
7
- * @param n - The value to check.
7
+ * @param notification - The value to check.
8
8
  * @returns True if the value is an OnChainRawNotification object, false otherwise.
9
9
  */
10
- function isOnChainRawNotification(n) {
11
- const assumed = n;
10
+ function isOnChainRawNotification(notification) {
11
+ const assumed = notification;
12
12
  // We don't have a validation/parsing library to check all possible types of an on chain notification
13
13
  // It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
14
14
  const isValidEnoughToBeOnChainNotification = [
@@ -1 +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,OAAO,EAAE,IAAI;KACvB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC;AAZD,4DAYC","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?.payload?.data,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
1
+ {"version":3,"file":"is-onchain-notification.cjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,YAAqB;IAErB,MAAM,OAAO,GAAG,YAAsC,CAAC;IAEvD,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,OAAO,EAAE,IAAI;KACvB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC;AAZD,4DAYC","sourcesContent":["import type { OnChainRawNotification } from '../NotificationServicesController';\n\n/**\n * Checks if the given value is an OnChainRawNotification object.\n *\n * @param notification - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainRawNotification(\n notification: unknown,\n): notification is OnChainRawNotification {\n const assumed = notification 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?.payload?.data,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
@@ -2,8 +2,8 @@ import type { OnChainRawNotification } from "../NotificationServicesController/i
2
2
  /**
3
3
  * Checks if the given value is an OnChainRawNotification object.
4
4
  *
5
- * @param n - The value to check.
5
+ * @param notification - The value to check.
6
6
  * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
7
  */
8
- export declare function isOnChainRawNotification(n: unknown): n is OnChainRawNotification;
8
+ export declare function isOnChainRawNotification(notification: unknown): notification is OnChainRawNotification;
9
9
  //# sourceMappingURL=is-onchain-notification.d.cts.map
@@ -1 +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,CAU7B"}
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,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,sBAAsB,CAUxC"}
@@ -2,8 +2,8 @@ import type { OnChainRawNotification } from "../NotificationServicesController/i
2
2
  /**
3
3
  * Checks if the given value is an OnChainRawNotification object.
4
4
  *
5
- * @param n - The value to check.
5
+ * @param notification - The value to check.
6
6
  * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
7
  */
8
- export declare function isOnChainRawNotification(n: unknown): n is OnChainRawNotification;
8
+ export declare function isOnChainRawNotification(notification: unknown): notification is OnChainRawNotification;
9
9
  //# sourceMappingURL=is-onchain-notification.d.mts.map
@@ -1 +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,CAU7B"}
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,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,sBAAsB,CAUxC"}
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Checks if the given value is an OnChainRawNotification object.
3
3
  *
4
- * @param n - The value to check.
4
+ * @param notification - The value to check.
5
5
  * @returns True if the value is an OnChainRawNotification object, false otherwise.
6
6
  */
7
- export function isOnChainRawNotification(n) {
8
- const assumed = n;
7
+ export function isOnChainRawNotification(notification) {
8
+ const assumed = notification;
9
9
  // We don't have a validation/parsing library to check all possible types of an on chain notification
10
10
  // It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
11
11
  const isValidEnoughToBeOnChainNotification = [
@@ -1 +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,OAAO,EAAE,IAAI;KACvB,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?.payload?.data,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
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,YAAqB;IAErB,MAAM,OAAO,GAAG,YAAsC,CAAC;IAEvD,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,OAAO,EAAE,IAAI;KACvB,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 notification - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainRawNotification(\n notification: unknown,\n): notification is OnChainRawNotification {\n const assumed = notification 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?.payload?.data,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"to-raw-notification.cjs","sourceRoot":"","sources":["../../src/shared/to-raw-notification.ts"],"names":[],"mappings":";;;AAOA;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAClC,IAAgC;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,IAAI,EAAE,iBAAiB,CAAC;QAC7C,MAAM,IAAI,KAAK,CACb,mEAAmE,IAAI,EAAE,CAC1E,CAAC;IACJ,CAAC,CAAC;IAEF,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;SACH,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,iBAAiB;SACF,CAAC;IAC/B,CAAC;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AA9BD,oDA8BC","sourcesContent":["import type {\n UnprocessedRawNotification,\n NormalisedAPINotification,\n OnChainRawNotification,\n PlatformRawNotification,\n} from 'src/NotificationServicesController/types/notification-api';\n\n/**\n * A true \"raw notification\" does not have some fields that exist on this type. E.g. the `type` field.\n * This is retro-actively added when we fetch notifications to be able to easily type-discriminate notifications.\n * We use this to ensure that the correct missing fields are added to the raw shapes\n *\n * @param data - raw onchain notification\n * @returns a complete raw onchain notification\n */\nexport function toRawAPINotification(\n data: UnprocessedRawNotification,\n): NormalisedAPINotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = data?.notification_type;\n throw new Error(\n `toRawAPINotification - No processor found for notification kind ${type}`,\n );\n };\n\n if (data.notification_type === 'on-chain') {\n if (!data?.payload?.data?.kind) {\n throw new Error(\n 'toRawAPINotification - No kind found for on-chain notification',\n );\n }\n return {\n ...data,\n type: data.payload.data.kind,\n } as OnChainRawNotification;\n }\n\n if (data.notification_type === 'platform') {\n return {\n ...data,\n type: data.notification_type,\n } as PlatformRawNotification;\n }\n\n return exhaustedAllCases(data);\n}\n"]}
1
+ {"version":3,"file":"to-raw-notification.cjs","sourceRoot":"","sources":["../../src/shared/to-raw-notification.ts"],"names":[],"mappings":";;;AAOA;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAClC,IAAgC;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAS,EAAE;QAC5C,MAAM,IAAI,GAAW,IAAI,EAAE,iBAAiB,CAAC;QAC7C,MAAM,IAAI,KAAK,CACb,mEAAmE,IAAI,EAAE,CAC1E,CAAC;IACJ,CAAC,CAAC;IAEF,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;SACH,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,iBAAiB;SACF,CAAC;IAC/B,CAAC;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AA9BD,oDA8BC","sourcesContent":["import type {\n UnprocessedRawNotification,\n NormalisedAPINotification,\n OnChainRawNotification,\n PlatformRawNotification,\n} from 'src/NotificationServicesController/types/notification-api';\n\n/**\n * A true \"raw notification\" does not have some fields that exist on this type. E.g. the `type` field.\n * This is retro-actively added when we fetch notifications to be able to easily type-discriminate notifications.\n * We use this to ensure that the correct missing fields are added to the raw shapes\n *\n * @param data - raw onchain notification\n * @returns a complete raw onchain notification\n */\nexport function toRawAPINotification(\n data: UnprocessedRawNotification,\n): NormalisedAPINotification {\n const exhaustedAllCases = (_: never): never => {\n const type: string = data?.notification_type;\n throw new Error(\n `toRawAPINotification - No processor found for notification kind ${type}`,\n );\n };\n\n if (data.notification_type === 'on-chain') {\n if (!data?.payload?.data?.kind) {\n throw new Error(\n 'toRawAPINotification - No kind found for on-chain notification',\n );\n }\n return {\n ...data,\n type: data.payload.data.kind,\n } as OnChainRawNotification;\n }\n\n if (data.notification_type === 'platform') {\n return {\n ...data,\n type: data.notification_type,\n } as PlatformRawNotification;\n }\n\n return exhaustedAllCases(data);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"to-raw-notification.mjs","sourceRoot":"","sources":["../../src/shared/to-raw-notification.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAgC;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,IAAI,EAAE,iBAAiB,CAAC;QAC7C,MAAM,IAAI,KAAK,CACb,mEAAmE,IAAI,EAAE,CAC1E,CAAC;IACJ,CAAC,CAAC;IAEF,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;SACH,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,iBAAiB;SACF,CAAC;IAC/B,CAAC;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import type {\n UnprocessedRawNotification,\n NormalisedAPINotification,\n OnChainRawNotification,\n PlatformRawNotification,\n} from 'src/NotificationServicesController/types/notification-api';\n\n/**\n * A true \"raw notification\" does not have some fields that exist on this type. E.g. the `type` field.\n * This is retro-actively added when we fetch notifications to be able to easily type-discriminate notifications.\n * We use this to ensure that the correct missing fields are added to the raw shapes\n *\n * @param data - raw onchain notification\n * @returns a complete raw onchain notification\n */\nexport function toRawAPINotification(\n data: UnprocessedRawNotification,\n): NormalisedAPINotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = data?.notification_type;\n throw new Error(\n `toRawAPINotification - No processor found for notification kind ${type}`,\n );\n };\n\n if (data.notification_type === 'on-chain') {\n if (!data?.payload?.data?.kind) {\n throw new Error(\n 'toRawAPINotification - No kind found for on-chain notification',\n );\n }\n return {\n ...data,\n type: data.payload.data.kind,\n } as OnChainRawNotification;\n }\n\n if (data.notification_type === 'platform') {\n return {\n ...data,\n type: data.notification_type,\n } as PlatformRawNotification;\n }\n\n return exhaustedAllCases(data);\n}\n"]}
1
+ {"version":3,"file":"to-raw-notification.mjs","sourceRoot":"","sources":["../../src/shared/to-raw-notification.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAgC;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAS,EAAE;QAC5C,MAAM,IAAI,GAAW,IAAI,EAAE,iBAAiB,CAAC;QAC7C,MAAM,IAAI,KAAK,CACb,mEAAmE,IAAI,EAAE,CAC1E,CAAC;IACJ,CAAC,CAAC;IAEF,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;SACH,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,iBAAiB;SACF,CAAC;IAC/B,CAAC;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import type {\n UnprocessedRawNotification,\n NormalisedAPINotification,\n OnChainRawNotification,\n PlatformRawNotification,\n} from 'src/NotificationServicesController/types/notification-api';\n\n/**\n * A true \"raw notification\" does not have some fields that exist on this type. E.g. the `type` field.\n * This is retro-actively added when we fetch notifications to be able to easily type-discriminate notifications.\n * We use this to ensure that the correct missing fields are added to the raw shapes\n *\n * @param data - raw onchain notification\n * @returns a complete raw onchain notification\n */\nexport function toRawAPINotification(\n data: UnprocessedRawNotification,\n): NormalisedAPINotification {\n const exhaustedAllCases = (_: never): never => {\n const type: string = data?.notification_type;\n throw new Error(\n `toRawAPINotification - No processor found for notification kind ${type}`,\n );\n };\n\n if (data.notification_type === 'on-chain') {\n if (!data?.payload?.data?.kind) {\n throw new Error(\n 'toRawAPINotification - No kind found for on-chain notification',\n );\n }\n return {\n ...data,\n type: data.payload.data.kind,\n } as OnChainRawNotification;\n }\n\n if (data.notification_type === 'platform') {\n return {\n ...data,\n type: data.notification_type,\n } as PlatformRawNotification;\n }\n\n return exhaustedAllCases(data);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/notification-services-controller",
3
- "version": "21.0.0",
3
+ "version": "22.1.0",
4
4
  "description": "Manages New MetaMask decentralized Notification system",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -37,16 +37,6 @@
37
37
  "default": "./dist/NotificationServicesController/index.cjs"
38
38
  }
39
39
  },
40
- "./notification-services/ui": {
41
- "import": {
42
- "types": "./dist/NotificationServicesController/ui/index.d.mts",
43
- "default": "./dist/NotificationServicesController/ui/index.mjs"
44
- },
45
- "require": {
46
- "types": "./dist/NotificationServicesController/ui/index.d.cts",
47
- "default": "./dist/NotificationServicesController/ui/index.cjs"
48
- }
49
- },
50
40
  "./notification-services/mocks": {
51
41
  "import": {
52
42
  "types": "./dist/NotificationServicesController/mocks/index.d.mts",
@@ -102,7 +92,6 @@
102
92
  "build:docs": "typedoc",
103
93
  "changelog:update": "../../scripts/update-changelog.sh @metamask/notification-services-controller",
104
94
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/notification-services-controller",
105
- "publish:preview": "yarn npm publish --tag preview",
106
95
  "since-latest-release": "../../scripts/since-latest-release.sh",
107
96
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
108
97
  "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -112,11 +101,14 @@
112
101
  "dependencies": {
113
102
  "@contentful/rich-text-html-renderer": "^16.5.2",
114
103
  "@metamask/base-controller": "^9.0.0",
115
- "@metamask/controller-utils": "^11.16.0",
104
+ "@metamask/controller-utils": "^11.19.0",
105
+ "@metamask/keyring-controller": "^25.1.0",
116
106
  "@metamask/messenger": "^0.3.0",
117
- "@metamask/utils": "^11.8.1",
107
+ "@metamask/profile-sync-controller": "^28.0.0",
108
+ "@metamask/utils": "^11.9.0",
118
109
  "bignumber.js": "^9.1.2",
119
110
  "firebase": "^11.2.0",
111
+ "lodash": "^4.17.21",
120
112
  "loglevel": "^1.8.1",
121
113
  "semver": "^7.6.3",
122
114
  "uuid": "^8.3.2"
@@ -125,26 +117,21 @@
125
117
  "@lavamoat/allow-scripts": "^3.0.4",
126
118
  "@lavamoat/preinstall-always-fail": "^2.1.0",
127
119
  "@metamask/auto-changelog": "^3.4.4",
128
- "@metamask/keyring-controller": "^25.0.0",
129
- "@metamask/profile-sync-controller": "^27.0.0",
130
120
  "@ts-bridge/cli": "^0.6.4",
131
- "@types/jest": "^27.4.1",
121
+ "@types/jest": "^29.5.14",
122
+ "@types/lodash": "^4.14.191",
132
123
  "@types/readable-stream": "^2.3.0",
133
124
  "@types/semver": "^7",
134
125
  "contentful": "^10.15.0",
135
126
  "deepmerge": "^4.2.2",
136
- "jest": "^27.5.1",
137
- "jest-environment-jsdom": "^27.5.1",
127
+ "jest": "^29.7.0",
128
+ "jest-environment-jsdom": "^29.7.0",
138
129
  "nock": "^13.3.1",
139
- "ts-jest": "^27.1.4",
140
- "typedoc": "^0.24.8",
130
+ "ts-jest": "^29.2.5",
131
+ "typedoc": "^0.25.13",
141
132
  "typedoc-plugin-missing-exports": "^2.0.0",
142
133
  "typescript": "~5.3.3"
143
134
  },
144
- "peerDependencies": {
145
- "@metamask/keyring-controller": "^25.0.0",
146
- "@metamask/profile-sync-controller": "^27.0.0"
147
- },
148
135
  "engines": {
149
136
  "node": "^18.18 || >=20"
150
137
  },
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NOTIFICATION_CHAINS_ID = exports.SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = exports.NOTIFICATION_NETWORK_CURRENCY_SYMBOL = exports.NOTIFICATION_NETWORK_CURRENCY_NAME = void 0;
4
- const notification_schema_1 = require("../constants/notification-schema.cjs");
5
- exports.NOTIFICATION_NETWORK_CURRENCY_NAME = {
6
- [notification_schema_1.NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',
7
- [notification_schema_1.NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',
8
- [notification_schema_1.NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',
9
- [notification_schema_1.NOTIFICATION_CHAINS_ID.BSC]: 'Binance',
10
- [notification_schema_1.NOTIFICATION_CHAINS_ID.BASE]: 'Base',
11
- [notification_schema_1.NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',
12
- [notification_schema_1.NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',
13
- [notification_schema_1.NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',
14
- [notification_schema_1.NOTIFICATION_CHAINS_ID.SEI]: 'Sei Network',
15
- };
16
- exports.NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {
17
- [notification_schema_1.NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',
18
- [notification_schema_1.NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',
19
- [notification_schema_1.NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',
20
- [notification_schema_1.NOTIFICATION_CHAINS_ID.BSC]: 'BNB',
21
- [notification_schema_1.NOTIFICATION_CHAINS_ID.BASE]: 'ETH',
22
- [notification_schema_1.NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',
23
- [notification_schema_1.NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',
24
- [notification_schema_1.NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',
25
- [notification_schema_1.NOTIFICATION_CHAINS_ID.SEI]: 'SEI',
26
- };
27
- exports.SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {
28
- // ETHEREUM
29
- [notification_schema_1.NOTIFICATION_CHAINS_ID.ETHEREUM]: {
30
- url: 'https://etherscan.io',
31
- name: 'Etherscan',
32
- },
33
- // OPTIMISM
34
- [notification_schema_1.NOTIFICATION_CHAINS_ID.OPTIMISM]: {
35
- url: 'https://optimistic.etherscan.io',
36
- name: 'Optimistic Etherscan',
37
- },
38
- // BSC
39
- [notification_schema_1.NOTIFICATION_CHAINS_ID.BSC]: {
40
- url: 'https://bscscan.com',
41
- name: 'BscScan',
42
- },
43
- // BASE
44
- [notification_schema_1.NOTIFICATION_CHAINS_ID.BASE]: {
45
- url: 'https://basescan.org',
46
- name: 'BaseScan',
47
- },
48
- // POLYGON
49
- [notification_schema_1.NOTIFICATION_CHAINS_ID.POLYGON]: {
50
- url: 'https://polygonscan.com',
51
- name: 'PolygonScan',
52
- },
53
- // ARBITRUM
54
- [notification_schema_1.NOTIFICATION_CHAINS_ID.ARBITRUM]: {
55
- url: 'https://arbiscan.io',
56
- name: 'Arbiscan',
57
- },
58
- // AVALANCHE
59
- [notification_schema_1.NOTIFICATION_CHAINS_ID.AVALANCHE]: {
60
- url: 'https://snowtrace.io',
61
- name: 'Snowtrace',
62
- },
63
- // LINEA
64
- [notification_schema_1.NOTIFICATION_CHAINS_ID.LINEA]: {
65
- url: 'https://lineascan.build',
66
- name: 'LineaScan',
67
- },
68
- [notification_schema_1.NOTIFICATION_CHAINS_ID.SEI]: {
69
- url: 'https://seitrace.com/',
70
- name: 'SeiTrace',
71
- },
72
- };
73
- var notification_schema_2 = require("../constants/notification-schema.cjs");
74
- Object.defineProperty(exports, "NOTIFICATION_CHAINS_ID", { enumerable: true, get: function () { return notification_schema_2.NOTIFICATION_CHAINS_ID; } });
75
- //# sourceMappingURL=constants.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":";;;AAAA,8EAG0C;AAE7B,QAAA,kCAAkC,GAAG;IAChD,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7C,CAAC,4CAAsB,CAAC,QA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AC1B,IAAI,EAAE,SAAS;KAChB;IACD,OAAO;IACP,CAAC,4CAAsB,CAAC,IAAI,CAAC,EAAE;QAC7B,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,UAAU;KACjB;IACD,UAAU;IACV,CAAC,4CAAsB,CAAC,OAAO,CAAC,EAAE;QAChC,GAAG,EAAE,yBAAyB;QAC9B,IAAI,EAAE,aAAa;KACpB;IACD,WAAW;IACX,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE;QACjC,GAAG,EAAE,qBAAqB;QAC1B,IAAI,EAAE,UAAU;KACjB;IACD,YAAY;IACZ,CAAC,4CAAsB,CAAC,SAAS,CAAC,EAAE;QAClC,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,WAAW;KAClB;IACD,QAAQ;IACR,CAAC,4CAAsB,CAAC,KAAK,CAAC,EAAE;QAC9B,GAAG,EAAE,yBAAyB;QAC9B,IAAI,EAAE,WAAW;KAClB;IACD,CAAC,4CAAsB,CAAC,GAAG,CAAC,EAAE;QAC5B,GAAG,EAAE,uBAAuB;QAC5B,IAAI,EAAE,UAAU;KACjB;CAC6D,CAAC;AAEjE,4EAA0E;AAAjE,6HAAA,sBAAsB,OAAA","sourcesContent":["import {\n NOTIFICATION_CHAINS_ID,\n type NOTIFICATION_CHAINS_IDS,\n} from '../constants/notification-schema';\n\nexport const NOTIFICATION_NETWORK_CURRENCY_NAME = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',\n [NOTIFICATION_CHAINS_ID.BSC]: 'Binance',\n [NOTIFICATION_CHAINS_ID.BASE]: 'Base',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',\n [NOTIFICATION_CHAINS_ID.SEI]: 'Sei Network',\n} satisfies Record<NOTIFICATION_CHAINS_IDS, string>;\n\nexport const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS_ID.BSC]: 'BNB',\n [NOTIFICATION_CHAINS_ID.BASE]: 'ETH',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',\n [NOTIFICATION_CHAINS_ID.SEI]: 'SEI',\n} satisfies Record<NOTIFICATION_CHAINS_IDS, string>;\n\nexport type BlockExplorerConfig = {\n url: string;\n name: string;\n};\n\nexport const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {\n // ETHEREUM\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: {\n url: 'https://etherscan.io',\n name: 'Etherscan',\n },\n // OPTIMISM\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: {\n url: 'https://optimistic.etherscan.io',\n name: 'Optimistic Etherscan',\n },\n // BSC\n [NOTIFICATION_CHAINS_ID.BSC]: {\n url: 'https://bscscan.com',\n name: 'BscScan',\n },\n // BASE\n [NOTIFICATION_CHAINS_ID.BASE]: {\n url: 'https://basescan.org',\n name: 'BaseScan',\n },\n // POLYGON\n [NOTIFICATION_CHAINS_ID.POLYGON]: {\n url: 'https://polygonscan.com',\n name: 'PolygonScan',\n },\n // ARBITRUM\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: {\n url: 'https://arbiscan.io',\n name: 'Arbiscan',\n },\n // AVALANCHE\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: {\n url: 'https://snowtrace.io',\n name: 'Snowtrace',\n },\n // LINEA\n [NOTIFICATION_CHAINS_ID.LINEA]: {\n url: 'https://lineascan.build',\n name: 'LineaScan',\n },\n [NOTIFICATION_CHAINS_ID.SEI]: {\n url: 'https://seitrace.com/',\n name: 'SeiTrace',\n },\n} satisfies Record<NOTIFICATION_CHAINS_IDS, BlockExplorerConfig>;\n\nexport { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n"]}
@@ -1,66 +0,0 @@
1
- export declare const NOTIFICATION_NETWORK_CURRENCY_NAME: {
2
- "1": string;
3
- "42161": string;
4
- "43114": string;
5
- "56": string;
6
- "8453": string;
7
- "59144": string;
8
- "10": string;
9
- "137": string;
10
- "1329": string;
11
- };
12
- export declare const NOTIFICATION_NETWORK_CURRENCY_SYMBOL: {
13
- "1": string;
14
- "42161": string;
15
- "43114": string;
16
- "56": string;
17
- "8453": string;
18
- "59144": string;
19
- "10": string;
20
- "137": string;
21
- "1329": string;
22
- };
23
- export type BlockExplorerConfig = {
24
- url: string;
25
- name: string;
26
- };
27
- export declare const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS: {
28
- "1": {
29
- url: string;
30
- name: string;
31
- };
32
- "10": {
33
- url: string;
34
- name: string;
35
- };
36
- "56": {
37
- url: string;
38
- name: string;
39
- };
40
- "8453": {
41
- url: string;
42
- name: string;
43
- };
44
- "137": {
45
- url: string;
46
- name: string;
47
- };
48
- "42161": {
49
- url: string;
50
- name: string;
51
- };
52
- "43114": {
53
- url: string;
54
- name: string;
55
- };
56
- "59144": {
57
- url: string;
58
- name: string;
59
- };
60
- "1329": {
61
- url: string;
62
- name: string;
63
- };
64
- };
65
- export { NOTIFICATION_CHAINS_ID } from "../constants/notification-schema.cjs";
66
- //# sourceMappingURL=constants.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC;;;;;;;;;;CAUI,CAAC;AAEpD,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUE,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ca,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,6CAAyC"}
@@ -1,66 +0,0 @@
1
- export declare const NOTIFICATION_NETWORK_CURRENCY_NAME: {
2
- "1": string;
3
- "42161": string;
4
- "43114": string;
5
- "56": string;
6
- "8453": string;
7
- "59144": string;
8
- "10": string;
9
- "137": string;
10
- "1329": string;
11
- };
12
- export declare const NOTIFICATION_NETWORK_CURRENCY_SYMBOL: {
13
- "1": string;
14
- "42161": string;
15
- "43114": string;
16
- "56": string;
17
- "8453": string;
18
- "59144": string;
19
- "10": string;
20
- "137": string;
21
- "1329": string;
22
- };
23
- export type BlockExplorerConfig = {
24
- url: string;
25
- name: string;
26
- };
27
- export declare const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS: {
28
- "1": {
29
- url: string;
30
- name: string;
31
- };
32
- "10": {
33
- url: string;
34
- name: string;
35
- };
36
- "56": {
37
- url: string;
38
- name: string;
39
- };
40
- "8453": {
41
- url: string;
42
- name: string;
43
- };
44
- "137": {
45
- url: string;
46
- name: string;
47
- };
48
- "42161": {
49
- url: string;
50
- name: string;
51
- };
52
- "43114": {
53
- url: string;
54
- name: string;
55
- };
56
- "59144": {
57
- url: string;
58
- name: string;
59
- };
60
- "1329": {
61
- url: string;
62
- name: string;
63
- };
64
- };
65
- export { NOTIFICATION_CHAINS_ID } from "../constants/notification-schema.mjs";
66
- //# sourceMappingURL=constants.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC;;;;;;;;;;CAUI,CAAC;AAEpD,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUE,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ca,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,6CAAyC"}
@@ -1,71 +0,0 @@
1
- import { NOTIFICATION_CHAINS_ID } from "../constants/notification-schema.mjs";
2
- export const NOTIFICATION_NETWORK_CURRENCY_NAME = {
3
- [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',
4
- [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',
5
- [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',
6
- [NOTIFICATION_CHAINS_ID.BSC]: 'Binance',
7
- [NOTIFICATION_CHAINS_ID.BASE]: 'Base',
8
- [NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',
9
- [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',
10
- [NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',
11
- [NOTIFICATION_CHAINS_ID.SEI]: 'Sei Network',
12
- };
13
- export const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {
14
- [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',
15
- [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',
16
- [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',
17
- [NOTIFICATION_CHAINS_ID.BSC]: 'BNB',
18
- [NOTIFICATION_CHAINS_ID.BASE]: 'ETH',
19
- [NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',
20
- [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',
21
- [NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',
22
- [NOTIFICATION_CHAINS_ID.SEI]: 'SEI',
23
- };
24
- export const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {
25
- // ETHEREUM
26
- [NOTIFICATION_CHAINS_ID.ETHEREUM]: {
27
- url: 'https://etherscan.io',
28
- name: 'Etherscan',
29
- },
30
- // OPTIMISM
31
- [NOTIFICATION_CHAINS_ID.OPTIMISM]: {
32
- url: 'https://optimistic.etherscan.io',
33
- name: 'Optimistic Etherscan',
34
- },
35
- // BSC
36
- [NOTIFICATION_CHAINS_ID.BSC]: {
37
- url: 'https://bscscan.com',
38
- name: 'BscScan',
39
- },
40
- // BASE
41
- [NOTIFICATION_CHAINS_ID.BASE]: {
42
- url: 'https://basescan.org',
43
- name: 'BaseScan',
44
- },
45
- // POLYGON
46
- [NOTIFICATION_CHAINS_ID.POLYGON]: {
47
- url: 'https://polygonscan.com',
48
- name: 'PolygonScan',
49
- },
50
- // ARBITRUM
51
- [NOTIFICATION_CHAINS_ID.ARBITRUM]: {
52
- url: 'https://arbiscan.io',
53
- name: 'Arbiscan',
54
- },
55
- // AVALANCHE
56
- [NOTIFICATION_CHAINS_ID.AVALANCHE]: {
57
- url: 'https://snowtrace.io',
58
- name: 'Snowtrace',
59
- },
60
- // LINEA
61
- [NOTIFICATION_CHAINS_ID.LINEA]: {
62
- url: 'https://lineascan.build',
63
- name: 'LineaScan',
64
- },
65
- [NOTIFICATION_CHAINS_ID.SEI]: {
66
- url: 'https://seitrace.com/',
67
- name: 'SeiTrace',
68
- },
69
- };
70
- export { NOTIFICATION_CHAINS_ID } from "../constants/notification-schema.mjs";
71
- //# sourceMappingURL=constants.mjs.map