@metamask/notification-services-controller 18.3.1 → 20.0.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 (207) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +47 -68
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +8 -7
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +8 -7
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +47 -45
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.cjs +4 -14
  11. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  12. package/dist/NotificationServicesController/constants/notification-schema.d.cts +3 -13
  13. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/constants/notification-schema.d.mts +3 -13
  15. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -13
  17. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  18. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +427 -529
  19. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -1
  20. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts +20 -50
  21. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts +20 -50
  23. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs +424 -521
  25. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/mockResponses.cjs +5 -5
  27. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/mockResponses.d.cts +2 -2
  29. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/mockResponses.d.mts +2 -2
  31. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/mocks/mockResponses.mjs +1 -1
  33. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  34. package/dist/NotificationServicesController/processors/index.cjs +1 -1
  35. package/dist/NotificationServicesController/processors/index.cjs.map +1 -1
  36. package/dist/NotificationServicesController/processors/index.d.cts +1 -1
  37. package/dist/NotificationServicesController/processors/index.d.cts.map +1 -1
  38. package/dist/NotificationServicesController/processors/index.d.mts +1 -1
  39. package/dist/NotificationServicesController/processors/index.d.mts.map +1 -1
  40. package/dist/NotificationServicesController/processors/index.mjs +1 -1
  41. package/dist/NotificationServicesController/processors/index.mjs.map +1 -1
  42. package/dist/NotificationServicesController/processors/process-api-notifications.cjs +22 -0
  43. package/dist/NotificationServicesController/processors/process-api-notifications.cjs.map +1 -0
  44. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts +10 -0
  45. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts.map +1 -0
  46. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts +10 -0
  47. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts.map +1 -0
  48. package/dist/NotificationServicesController/processors/process-api-notifications.mjs +18 -0
  49. package/dist/NotificationServicesController/processors/process-api-notifications.mjs.map +1 -0
  50. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs +2 -7
  51. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs.map +1 -1
  52. package/dist/NotificationServicesController/processors/process-feature-announcement.d.cts.map +1 -1
  53. package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts.map +1 -1
  54. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +1 -6
  55. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -1
  56. package/dist/NotificationServicesController/processors/process-notifications.cjs +3 -3
  57. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  58. package/dist/NotificationServicesController/processors/process-notifications.d.cts +398 -458
  59. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  60. package/dist/NotificationServicesController/processors/process-notifications.d.mts +398 -458
  61. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  62. package/dist/NotificationServicesController/processors/process-notifications.mjs +4 -4
  63. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  64. package/dist/NotificationServicesController/services/{onchain-notifications.cjs → api-notifications.cjs} +28 -15
  65. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -0
  66. package/dist/NotificationServicesController/services/{onchain-notifications.d.cts → api-notifications.d.cts} +9 -7
  67. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -0
  68. package/dist/NotificationServicesController/services/{onchain-notifications.d.mts → api-notifications.d.mts} +9 -7
  69. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -0
  70. package/dist/NotificationServicesController/services/{onchain-notifications.mjs → api-notifications.mjs} +26 -13
  71. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -0
  72. package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
  73. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
  74. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
  75. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
  76. package/dist/NotificationServicesController/services/perp-notifications.cjs +0 -1
  77. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  78. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  79. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  80. package/dist/NotificationServicesController/services/perp-notifications.mjs +0 -1
  81. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  82. package/dist/NotificationServicesController/types/index.cjs.map +1 -1
  83. package/dist/NotificationServicesController/types/index.d.cts +1 -1
  84. package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
  85. package/dist/NotificationServicesController/types/index.d.mts +1 -1
  86. package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
  87. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  88. package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -1
  89. package/dist/NotificationServicesController/types/notification/notification.d.cts +3 -11
  90. package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -1
  91. package/dist/NotificationServicesController/types/notification/notification.d.mts +3 -11
  92. package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -1
  93. package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -1
  94. package/dist/NotificationServicesController/types/notification-api/index.cjs.map +1 -0
  95. package/dist/NotificationServicesController/types/notification-api/index.d.cts +3 -0
  96. package/dist/NotificationServicesController/types/notification-api/index.d.cts.map +1 -0
  97. package/dist/NotificationServicesController/types/notification-api/index.d.mts +3 -0
  98. package/dist/NotificationServicesController/types/notification-api/index.d.mts.map +1 -0
  99. package/dist/NotificationServicesController/types/notification-api/index.mjs.map +1 -0
  100. package/dist/NotificationServicesController/types/{on-chain-notification/on-chain-notification.cjs → notification-api/notification-api.cjs} +1 -1
  101. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -0
  102. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts +64 -0
  103. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -0
  104. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +64 -0
  105. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -0
  106. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs +2 -0
  107. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -0
  108. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -0
  109. package/dist/NotificationServicesController/types/notification-api/schema.d.cts +365 -0
  110. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -0
  111. package/dist/NotificationServicesController/types/notification-api/schema.d.mts +365 -0
  112. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -0
  113. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -0
  114. package/dist/NotificationServicesController/ui/constants.d.cts +27 -27
  115. package/dist/NotificationServicesController/ui/constants.d.mts +27 -27
  116. package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
  117. package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
  118. package/dist/NotificationServicesController/utils/should-auto-expire.cjs +12 -0
  119. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -0
  120. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts +2 -0
  121. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -0
  122. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts +2 -0
  123. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -0
  124. package/dist/NotificationServicesController/utils/should-auto-expire.mjs +8 -0
  125. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -0
  126. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +8 -8
  127. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  128. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +4 -4
  129. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  130. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +4 -4
  131. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  132. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +8 -8
  133. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  134. package/dist/NotificationServicesPushController/services/push/push-web.cjs +5 -2
  135. package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +1 -1
  136. package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +1 -1
  137. package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +1 -1
  138. package/dist/NotificationServicesPushController/services/push/push-web.mjs +6 -3
  139. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -1
  140. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  141. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  142. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
  143. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
  144. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +51 -43
  145. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  146. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +4 -2
  147. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  148. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +4 -2
  149. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  150. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +51 -43
  151. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  152. package/dist/NotificationServicesPushController/web/push-utils.cjs +5 -2
  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 +6 -3
  157. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  158. package/dist/shared/is-onchain-notification.cjs +1 -2
  159. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  160. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  161. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  162. package/dist/shared/is-onchain-notification.mjs +1 -2
  163. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  164. package/dist/shared/to-raw-notification.cjs +22 -6
  165. package/dist/shared/to-raw-notification.cjs.map +1 -1
  166. package/dist/shared/to-raw-notification.d.cts +2 -2
  167. package/dist/shared/to-raw-notification.d.cts.map +1 -1
  168. package/dist/shared/to-raw-notification.d.mts +2 -2
  169. package/dist/shared/to-raw-notification.d.mts.map +1 -1
  170. package/dist/shared/to-raw-notification.mjs +20 -4
  171. package/dist/shared/to-raw-notification.mjs.map +1 -1
  172. package/package.json +11 -8
  173. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs +0 -19
  174. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs.map +0 -1
  175. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts +0 -10
  176. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts.map +0 -1
  177. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts +0 -10
  178. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts.map +0 -1
  179. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +0 -15
  180. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +0 -1
  181. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +0 -1
  182. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +0 -1
  183. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +0 -1
  184. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +0 -1
  185. package/dist/NotificationServicesController/types/on-chain-notification/index.cjs.map +0 -1
  186. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts +0 -2
  187. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts.map +0 -1
  188. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts +0 -2
  189. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts.map +0 -1
  190. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +0 -1
  191. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs.map +0 -1
  192. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts +0 -49
  193. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts.map +0 -1
  194. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts +0 -49
  195. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts.map +0 -1
  196. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +0 -2
  197. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +0 -1
  198. package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs.map +0 -1
  199. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts +0 -681
  200. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts.map +0 -1
  201. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts +0 -681
  202. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts.map +0 -1
  203. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +0 -1
  204. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/index.cjs +0 -0
  205. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/index.mjs +0 -0
  206. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/schema.cjs +0 -0
  207. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/schema.mjs +0 -0
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getBearerToken, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
12
+ var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_locale, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getBearerToken, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
13
13
  function $importDefault(module) {
14
14
  if (module?.__esModule) {
15
15
  return module.default;
@@ -24,8 +24,8 @@ import $log from "loglevel";
24
24
  const log = $importDefault($log);
25
25
  import { TRIGGER_TYPES } from "./constants/notification-schema.mjs";
26
26
  import { processAndFilterNotifications, safeProcessNotification } from "./processors/process-notifications.mjs";
27
- import * as FeatureNotifications from "./services/feature-announcements.mjs";
28
- import * as OnChainNotifications from "./services/onchain-notifications.mjs";
27
+ import { getAPINotifications, getNotificationsApiConfigCached, markNotificationsAsRead, updateOnChainNotifications } from "./services/api-notifications.mjs";
28
+ import { getFeatureAnnouncementNotifications } from "./services/feature-announcements.mjs";
29
29
  import { createPerpOrderNotification } from "./services/perp-notifications.mjs";
30
30
  // Unique name for the controller
31
31
  const controllerName = 'NotificationServicesController';
@@ -33,61 +33,61 @@ const metadata = {
33
33
  subscriptionAccountsSeen: {
34
34
  includeInStateLogs: true,
35
35
  persist: true,
36
- anonymous: true,
36
+ includeInDebugSnapshot: true,
37
37
  usedInUi: true,
38
38
  },
39
39
  isMetamaskNotificationsFeatureSeen: {
40
40
  includeInStateLogs: true,
41
41
  persist: true,
42
- anonymous: false,
42
+ includeInDebugSnapshot: false,
43
43
  usedInUi: true,
44
44
  },
45
45
  isNotificationServicesEnabled: {
46
46
  includeInStateLogs: true,
47
47
  persist: true,
48
- anonymous: false,
48
+ includeInDebugSnapshot: false,
49
49
  usedInUi: true,
50
50
  },
51
51
  isFeatureAnnouncementsEnabled: {
52
52
  includeInStateLogs: true,
53
53
  persist: true,
54
- anonymous: false,
54
+ includeInDebugSnapshot: false,
55
55
  usedInUi: true,
56
56
  },
57
57
  metamaskNotificationsList: {
58
58
  includeInStateLogs: true,
59
59
  persist: true,
60
- anonymous: true,
60
+ includeInDebugSnapshot: true,
61
61
  usedInUi: true,
62
62
  },
63
63
  metamaskNotificationsReadList: {
64
64
  includeInStateLogs: false,
65
65
  persist: true,
66
- anonymous: true,
66
+ includeInDebugSnapshot: true,
67
67
  usedInUi: true,
68
68
  },
69
69
  isUpdatingMetamaskNotifications: {
70
70
  includeInStateLogs: false,
71
71
  persist: false,
72
- anonymous: false,
72
+ includeInDebugSnapshot: false,
73
73
  usedInUi: true,
74
74
  },
75
75
  isFetchingMetamaskNotifications: {
76
76
  includeInStateLogs: false,
77
77
  persist: false,
78
- anonymous: false,
78
+ includeInDebugSnapshot: false,
79
79
  usedInUi: true,
80
80
  },
81
81
  isUpdatingMetamaskNotificationsAccount: {
82
82
  includeInStateLogs: false,
83
83
  persist: false,
84
- anonymous: false,
84
+ includeInDebugSnapshot: false,
85
85
  usedInUi: true,
86
86
  },
87
87
  isCheckingAccountsPresence: {
88
88
  includeInStateLogs: false,
89
89
  persist: false,
90
- anonymous: false,
90
+ includeInDebugSnapshot: false,
91
91
  usedInUi: true,
92
92
  },
93
93
  };
@@ -118,7 +118,7 @@ class NotificationServicesController extends BaseController {
118
118
  * @param args.state - Initial state to set on this controller.
119
119
  * @param args.env - environment variables for a given controller.
120
120
  * @param args.env.featureAnnouncements - env variables for feature announcements.
121
- * @param args.env.isPushIntegrated - toggle push notifications on/off if client has integrated them.
121
+ * @param args.env.locale - users locale for better dynamic server notifications
122
122
  */
123
123
  constructor({ messenger, state, env, }) {
124
124
  super({
@@ -131,29 +131,29 @@ class NotificationServicesController extends BaseController {
131
131
  _NotificationServicesController_keyringController.set(this, {
132
132
  isUnlocked: false,
133
133
  setupLockedStateSubscriptions: (onUnlock) => {
134
- const { isUnlocked } = this.messagingSystem.call('KeyringController:getState');
134
+ const { isUnlocked } = this.messenger.call('KeyringController:getState');
135
135
  __classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = isUnlocked;
136
- this.messagingSystem.subscribe('KeyringController:unlock', () => {
136
+ this.messenger.subscribe('KeyringController:unlock', () => {
137
137
  __classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = true;
138
138
  // messaging system cannot await promises
139
139
  // we don't need to wait for a result on this.
140
140
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
141
141
  onUnlock();
142
142
  });
143
- this.messagingSystem.subscribe('KeyringController:lock', () => {
143
+ this.messenger.subscribe('KeyringController:lock', () => {
144
144
  __classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = false;
145
145
  });
146
146
  },
147
147
  });
148
148
  _NotificationServicesController_auth.set(this, {
149
149
  getBearerToken: async () => {
150
- return await this.messagingSystem.call('AuthenticationController:getBearerToken');
150
+ return await this.messenger.call('AuthenticationController:getBearerToken');
151
151
  },
152
152
  isSignedIn: () => {
153
- return this.messagingSystem.call('AuthenticationController:isSignedIn');
153
+ return this.messenger.call('AuthenticationController:isSignedIn');
154
154
  },
155
155
  signIn: async () => {
156
- return await this.messagingSystem.call('AuthenticationController:performSignIn');
156
+ return await this.messenger.call('AuthenticationController:performSignIn');
157
157
  },
158
158
  });
159
159
  _NotificationServicesController_pushNotifications.set(this, {
@@ -162,11 +162,11 @@ class NotificationServicesController extends BaseController {
162
162
  // To ensure we subscribe to the most up-to-date notifications
163
163
  isSetup: false,
164
164
  subscribeToPushNotifications: async () => {
165
- await this.messagingSystem.call('NotificationServicesPushController:subscribeToPushNotifications');
165
+ await this.messenger.call('NotificationServicesPushController:subscribeToPushNotifications');
166
166
  },
167
167
  enablePushNotifications: async (addresses) => {
168
168
  try {
169
- await this.messagingSystem.call('NotificationServicesPushController:enablePushNotifications', addresses);
169
+ await this.messenger.call('NotificationServicesPushController:enablePushNotifications', addresses);
170
170
  }
171
171
  catch (e) {
172
172
  log.error('Silently failed to enable push notifications', e);
@@ -174,14 +174,14 @@ class NotificationServicesController extends BaseController {
174
174
  },
175
175
  disablePushNotifications: async () => {
176
176
  try {
177
- await this.messagingSystem.call('NotificationServicesPushController:disablePushNotifications');
177
+ await this.messenger.call('NotificationServicesPushController:disablePushNotifications');
178
178
  }
179
179
  catch (e) {
180
180
  log.error('Silently failed to disable push notifications', e);
181
181
  }
182
182
  },
183
183
  subscribe: () => {
184
- this.messagingSystem.subscribe('NotificationServicesPushController:onNewNotifications', (notification) => {
184
+ this.messenger.subscribe('NotificationServicesPushController:onNewNotifications', (notification) => {
185
185
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
186
186
  this.updateMetamaskNotificationsList(notification);
187
187
  });
@@ -215,7 +215,7 @@ class NotificationServicesController extends BaseController {
215
215
  // Flag to ensure we only setup once
216
216
  isNotificationAccountsSetup: false,
217
217
  getNotificationAccounts: () => {
218
- const { keyrings } = this.messagingSystem.call('KeyringController:getState');
218
+ const { keyrings } = this.messenger.call('KeyringController:getState');
219
219
  const firstHDKeyring = keyrings.find((k) => k.type === KeyringTypes.hd.toString());
220
220
  const keyringAccounts = firstHDKeyring?.accounts ?? null;
221
221
  return keyringAccounts;
@@ -278,7 +278,7 @@ class NotificationServicesController extends BaseController {
278
278
  * And call effects to subscribe/unsubscribe to notifications.
279
279
  */
280
280
  subscribe: () => {
281
- this.messagingSystem.subscribe('KeyringController:stateChange', async (totalAccounts, prevTotalAccounts) => {
281
+ this.messenger.subscribe('KeyringController:stateChange', async (totalAccounts, prevTotalAccounts) => {
282
282
  const hasTotalAccountsChanged = totalAccounts !== prevTotalAccounts;
283
283
  if (!this.state.isNotificationServicesEnabled ||
284
284
  !hasTotalAccountsChanged) {
@@ -299,8 +299,10 @@ class NotificationServicesController extends BaseController {
299
299
  });
300
300
  },
301
301
  });
302
+ _NotificationServicesController_locale.set(this, void 0);
302
303
  _NotificationServicesController_featureAnnouncementEnv.set(this, void 0);
303
304
  __classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
305
+ __classPrivateFieldSet(this, _NotificationServicesController_locale, env.locale ?? (() => 'en'), "f");
304
306
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerMessageHandlers).call(this);
305
307
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
306
308
  }
@@ -322,7 +324,7 @@ class NotificationServicesController extends BaseController {
322
324
  try {
323
325
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
324
326
  const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
325
- const addressesWithNotifications = await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts);
327
+ const addressesWithNotifications = await getNotificationsApiConfigCached(bearerToken, accounts);
326
328
  const addresses = addressesWithNotifications
327
329
  .filter((a) => Boolean(a.enabled))
328
330
  .map((a) => a.address);
@@ -345,7 +347,7 @@ class NotificationServicesController extends BaseController {
345
347
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsCheckingAccountsPresence).call(this, true);
346
348
  // Retrieve user storage
347
349
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
348
- const addressesWithNotifications = await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts);
350
+ const addressesWithNotifications = await getNotificationsApiConfigCached(bearerToken, accounts);
349
351
  const result = {};
350
352
  addressesWithNotifications.forEach((a) => {
351
353
  result[a.address] = a.enabled;
@@ -397,7 +399,7 @@ class NotificationServicesController extends BaseController {
397
399
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
398
400
  const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
399
401
  // 1. See if has enabled notifications before
400
- const addressesWithNotifications = await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts);
402
+ const addressesWithNotifications = await getNotificationsApiConfigCached(bearerToken, accounts);
401
403
  // Notifications API can return array with addresses set to false
402
404
  // So assert that at least one address is enabled
403
405
  let accountsWithNotifications = addressesWithNotifications
@@ -405,7 +407,7 @@ class NotificationServicesController extends BaseController {
405
407
  .map((a) => a.address);
406
408
  // 2. Enable Notifications (if no accounts subscribed or we are resetting)
407
409
  if (accountsWithNotifications.length === 0 || opts?.resetNotifications) {
408
- await OnChainNotifications.updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: true })));
410
+ await updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: true })));
409
411
  accountsWithNotifications = accounts;
410
412
  }
411
413
  // 3. Lazily enable push notifications (FCM may take some time, so keeps UI unblocked)
@@ -497,7 +499,7 @@ class NotificationServicesController extends BaseController {
497
499
  // Get and Validate BearerToken and User Storage Key
498
500
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
499
501
  // Delete these UUIDs (Mutates User Storage)
500
- await OnChainNotifications.updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: false })));
502
+ await updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: false })));
501
503
  }
502
504
  catch (err) {
503
505
  log.error('Failed to delete OnChain triggers', err);
@@ -526,7 +528,7 @@ class NotificationServicesController extends BaseController {
526
528
  try {
527
529
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
528
530
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
529
- await OnChainNotifications.updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: true })));
531
+ await updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: true })));
530
532
  }
531
533
  catch (err) {
532
534
  log.error('Failed to update OnChain triggers', err);
@@ -554,7 +556,7 @@ class NotificationServicesController extends BaseController {
554
556
  const isGlobalNotifsEnabled = this.state.isNotificationServicesEnabled;
555
557
  // Raw Feature Notifications
556
558
  const rawAnnouncements = isGlobalNotifsEnabled && this.state.isFeatureAnnouncementsEnabled
557
- ? await FeatureNotifications.getFeatureAnnouncementNotifications(__classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f"), previewToken).catch(() => [])
559
+ ? await getFeatureAnnouncementNotifications(__classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f"), previewToken).catch(() => [])
558
560
  : [];
559
561
  // Raw On Chain Notifications
560
562
  const rawOnChainNotifications = [];
@@ -562,10 +564,10 @@ class NotificationServicesController extends BaseController {
562
564
  try {
563
565
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
564
566
  const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
565
- const addressesWithNotifications = (await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts))
567
+ const addressesWithNotifications = (await getNotificationsApiConfigCached(bearerToken, accounts))
566
568
  .filter((a) => Boolean(a.enabled))
567
569
  .map((a) => a.address);
568
- const notifications = await OnChainNotifications.getOnChainNotifications(bearerToken, addressesWithNotifications).catch(() => []);
570
+ const notifications = await getAPINotifications(bearerToken, addressesWithNotifications, __classPrivateFieldGet(this, _NotificationServicesController_locale, "f").call(this), __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform).catch(() => []);
569
571
  rawOnChainNotifications.push(...notifications);
570
572
  }
571
573
  catch {
@@ -588,7 +590,7 @@ class NotificationServicesController extends BaseController {
588
590
  this.update((state) => {
589
591
  state.metamaskNotificationsList = metamaskNotifications;
590
592
  });
591
- this.messagingSystem.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
593
+ this.messenger.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
592
594
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
593
595
  return metamaskNotifications;
594
596
  }
@@ -642,7 +644,7 @@ class NotificationServicesController extends BaseController {
642
644
  for (const id of ids) {
643
645
  await this.deleteNotificationById(id);
644
646
  }
645
- this.messagingSystem.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
647
+ this.messenger.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
646
648
  }
647
649
  /**
648
650
  * Marks specified metamask notifications as read.
@@ -675,7 +677,7 @@ class NotificationServicesController extends BaseController {
675
677
  const bearerToken = await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").getBearerToken();
676
678
  if (bearerToken) {
677
679
  onchainNotificationIds = onChainNotifications.map((notification) => notification.id);
678
- await OnChainNotifications.markNotificationsAsRead(bearerToken, onchainNotificationIds).catch(() => {
680
+ await markNotificationsAsRead(bearerToken, onchainNotificationIds).catch(() => {
679
681
  onchainNotificationIds = [];
680
682
  log.warn('Unable to mark onchain notifications as read');
681
683
  });
@@ -718,7 +720,7 @@ class NotificationServicesController extends BaseController {
718
720
  return notification;
719
721
  });
720
722
  });
721
- this.messagingSystem.publish(`${controllerName}:markNotificationsAsRead`, this.state.metamaskNotificationsList);
723
+ this.messenger.publish(`${controllerName}:markNotificationsAsRead`, this.state.metamaskNotificationsList);
722
724
  }
723
725
  /**
724
726
  * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.
@@ -743,7 +745,7 @@ class NotificationServicesController extends BaseController {
743
745
  ];
744
746
  }
745
747
  });
746
- this.messagingSystem.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
748
+ this.messenger.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
747
749
  }
748
750
  }
749
751
  /**
@@ -762,11 +764,11 @@ class NotificationServicesController extends BaseController {
762
764
  }
763
765
  }
764
766
  }
765
- _NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(), _NotificationServicesController_pushNotifications = new WeakMap(), _NotificationServicesController_accounts = new WeakMap(), _NotificationServicesController_featureAnnouncementEnv = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_registerMessageHandlers = function _NotificationServicesController_registerMessageHandlers() {
766
- this.messagingSystem.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
767
- this.messagingSystem.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
768
- this.messagingSystem.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
769
- this.messagingSystem.registerActionHandler(`${controllerName}:deleteNotificationsById`, this.deleteNotificationsById.bind(this));
767
+ _NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(), _NotificationServicesController_pushNotifications = new WeakMap(), _NotificationServicesController_accounts = new WeakMap(), _NotificationServicesController_locale = new WeakMap(), _NotificationServicesController_featureAnnouncementEnv = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_registerMessageHandlers = function _NotificationServicesController_registerMessageHandlers() {
768
+ this.messenger.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
769
+ this.messenger.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
770
+ this.messenger.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
771
+ this.messenger.registerActionHandler(`${controllerName}:deleteNotificationsById`, this.deleteNotificationsById.bind(this));
770
772
  }, _NotificationServicesController_clearLoadingStates = function _NotificationServicesController_clearLoadingStates() {
771
773
  this.update((state) => {
772
774
  state.isUpdatingMetamaskNotifications = false;