@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
package/CHANGELOG.md CHANGED
@@ -7,6 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [22.1.0]
11
+
12
+ ### Changed
13
+
14
+ - Debounce `KeyringController:stateChange` handler to reduce redundant notification subscription calls during rapid account syncing ([#7980](https://github.com/MetaMask/core/pull/7980))
15
+ - Filter out Product Account announcements notifications older than 3 months ([#7884](https://github.com/MetaMask/core/pull/7884))
16
+ - Bump `@metamask/controller-utils` from `^11.18.0` to `^11.19.0` ([#7995](https://github.com/MetaMask/core/pull/7995))
17
+ - Bump `@metamask/profile-sync-controller` from `^27.1.0` to `^28.0.0` ([#8162](https://github.com/MetaMask/core/pull/8162))
18
+
19
+ ## [22.0.0]
20
+
21
+ ### Changed
22
+
23
+ - Upgrade `@metamask/utils` from `^11.8.1` to `^11.9.0` ([#7511](https://github.com/MetaMask/core/pull/7511))
24
+ - Move peer dependencies for controller and service packages to direct dependencies ([#7209](https://github.com/MetaMask/core/pull/7209), [#7713](https://github.com/MetaMask/core/pull/7713), [#7849](https://github.com/MetaMask/core/pull/7849))
25
+ - The dependencies moved are:
26
+ - `@metamask/keyring-controller` (^25.1.0)
27
+ - `@metamask/profile-sync-controller` (^27.1.0)
28
+ - In clients, it is now possible for multiple versions of these packages to exist in the dependency tree.
29
+ - For example, this scenario would be valid: a client relies on `@metamask/controller-a` 1.0.0 and `@metamask/controller-b` 1.0.0, and `@metamask/controller-b` depends on `@metamask/controller-a` 1.1.0.
30
+ - Note, however, that the versions specified in the client's `package.json` always "win", and you are expected to keep them up to date so as not to break controller and service intercommunication.
31
+ - Modified background push utilities to handle more edgecases and not throw errors ([#7275](https://github.com/MetaMask/core/pull/7275))
32
+ - Bump `@metamask/controller-utils` from `^11.16.0` to `^11.18.0` ([#7534](https://github.com/MetaMask/core/pull/7534), [#7583](https://github.com/MetaMask/core/pull/7583))
33
+ - Filter feature announcements older than 3 months ([#7884](https://github.com/MetaMask/core/pull/7884))
34
+ - Move notifications networks metadata to backend ([#7840](https://github.com/MetaMask/core/pull/7840))
35
+
36
+ ### Removed
37
+
38
+ - **BREAKING:** Removed the `"./notification-services/ui"` subpath export from `package.json` ([#7840](https://github.com/MetaMask/core/pull/7840))
39
+ - Consumers that import from `@metamask/notification-services-controller/notification-services/ui` must switch to network config provided by the backend.
40
+
41
+ ### Fixed
42
+
43
+ - Remove non-actionable internal `log.error` calls for expected silent-failure notification paths, while preserving thrown errors where propagation is required ([#7885](https://github.com/MetaMask/core/pull/7885))
44
+ - Fix `createOnChainTriggers` to preserve user preferences on notification re-subscriptions ([#7423](https://github.com/MetaMask/core/pull/7423))
45
+ - Previously, `isFeatureAnnouncementsEnabled` was unconditionally set to `true` on every re-subscription, overriding user preferences
46
+ - Now, existing preferences are preserved when `isNotificationServicesEnabled` is already `true`
47
+
10
48
  ## [21.0.0]
11
49
 
12
50
  ### Changed
@@ -629,7 +667,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
629
667
 
630
668
  - Initial release
631
669
 
632
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@21.0.0...HEAD
670
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@22.1.0...HEAD
671
+ [22.1.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@22.0.0...@metamask/notification-services-controller@22.1.0
672
+ [22.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@21.0.0...@metamask/notification-services-controller@22.0.0
633
673
  [21.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@20.0.0...@metamask/notification-services-controller@21.0.0
634
674
  [20.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@19.0.0...@metamask/notification-services-controller@20.0.0
635
675
  [19.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@18.3.1...@metamask/notification-services-controller@19.0.0
@@ -15,11 +15,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_locale, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_env, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getBearerToken, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.defaultState = void 0;
18
+ exports.defaultState = exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = void 0;
19
19
  const base_controller_1 = require("@metamask/base-controller");
20
20
  const controller_utils_1 = require("@metamask/controller-utils");
21
21
  const keyring_controller_1 = require("@metamask/keyring-controller");
22
22
  const utils_1 = require("@metamask/utils");
23
+ const lodash_1 = require("lodash");
23
24
  const loglevel_1 = __importDefault(require("loglevel"));
24
25
  const notification_schema_1 = require("./constants/notification-schema.cjs");
25
26
  const process_notifications_1 = require("./processors/process-notifications.cjs");
@@ -28,6 +29,7 @@ const feature_announcements_1 = require("./services/feature-announcements.cjs");
28
29
  const perp_notifications_1 = require("./services/perp-notifications.cjs");
29
30
  // Unique name for the controller
30
31
  const controllerName = 'NotificationServicesController';
32
+ exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = 1000;
31
33
  const metadata = {
32
34
  subscriptionAccountsSeen: {
33
35
  includeInStateLogs: true,
@@ -168,16 +170,16 @@ class NotificationServicesController extends base_controller_1.BaseController {
168
170
  try {
169
171
  await this.messenger.call('NotificationServicesPushController:enablePushNotifications', addresses);
170
172
  }
171
- catch (e) {
172
- loglevel_1.default.error('Silently failed to enable push notifications', e);
173
+ catch {
174
+ // Do nothing, failing silently.
173
175
  }
174
176
  },
175
177
  disablePushNotifications: async () => {
176
178
  try {
177
179
  await this.messenger.call('NotificationServicesPushController:disablePushNotifications');
178
180
  }
179
- catch (e) {
180
- loglevel_1.default.error('Silently failed to disable push notifications', e);
181
+ catch {
182
+ // Do nothing, failing silently.
181
183
  }
182
184
  },
183
185
  subscribe: () => {
@@ -216,7 +218,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
216
218
  isNotificationAccountsSetup: false,
217
219
  getNotificationAccounts: () => {
218
220
  const { keyrings } = this.messenger.call('KeyringController:getState');
219
- const firstHDKeyring = keyrings.find((k) => k.type === keyring_controller_1.KeyringTypes.hd.toString());
221
+ const firstHDKeyring = keyrings.find((keyring) => keyring.type === keyring_controller_1.KeyringTypes.hd.toString());
220
222
  const keyringAccounts = firstHDKeyring?.accounts ?? null;
221
223
  return keyringAccounts;
222
224
  },
@@ -236,8 +238,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
236
238
  };
237
239
  }
238
240
  const accounts = nonChecksumAccounts
239
- .map((a) => (0, controller_utils_1.toChecksumHexAddress)(a))
240
- .filter((a) => (0, controller_utils_1.isValidHexAddress)(a));
241
+ .map((address) => (0, controller_utils_1.toChecksumHexAddress)(address))
242
+ .filter((address) => (0, controller_utils_1.isValidHexAddress)(address));
241
243
  const currentAccountsSet = new Set(accounts);
242
244
  const prevAccountsSet = new Set(this.state.subscriptionAccountsSeen);
243
245
  // Invalid value you cannot have zero accounts
@@ -250,8 +252,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
250
252
  };
251
253
  }
252
254
  // Calculate added and removed addresses
253
- const accountsAdded = accounts.filter((a) => !prevAccountsSet.has(a));
254
- const accountsRemoved = [...prevAccountsSet.values()].filter((a) => !currentAccountsSet.has(a));
255
+ const accountsAdded = accounts.filter((account) => !prevAccountsSet.has(account));
256
+ const accountsRemoved = [...prevAccountsSet.values()].filter((account) => !currentAccountsSet.has(account));
255
257
  // Update accounts seen
256
258
  this.update((state) => {
257
259
  state.subscriptionAccountsSeen = [...currentAccountsSet];
@@ -278,7 +280,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
278
280
  * And call effects to subscribe/unsubscribe to notifications.
279
281
  */
280
282
  subscribe: () => {
281
- this.messenger.subscribe('KeyringController:stateChange', async (totalAccounts, prevTotalAccounts) => {
283
+ const debouncedUpdateAccountNotifications = (0, lodash_1.debounce)(async (totalAccounts, prevTotalAccounts) => {
282
284
  const hasTotalAccountsChanged = totalAccounts !== prevTotalAccounts;
283
285
  if (!this.state.isNotificationServicesEnabled ||
284
286
  !hasTotalAccountsChanged) {
@@ -293,7 +295,11 @@ class NotificationServicesController extends base_controller_1.BaseController {
293
295
  promises.push(this.disableAccounts(accountsRemoved));
294
296
  }
295
297
  await Promise.allSettled(promises);
296
- }, (state) => {
298
+ }, exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS);
299
+ this.messenger.subscribe('KeyringController:stateChange',
300
+ // Using void return for async callback - result is intentionally ignored
301
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
302
+ debouncedUpdateAccountNotifications, (state) => {
297
303
  return (state?.keyrings?.flatMap?.((keyring) => keyring.accounts)?.length ??
298
304
  0);
299
305
  });
@@ -328,14 +334,14 @@ class NotificationServicesController extends base_controller_1.BaseController {
328
334
  const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
329
335
  const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
330
336
  const addresses = addressesWithNotifications
331
- .filter((a) => Boolean(a.enabled))
332
- .map((a) => a.address);
337
+ .filter((addressConfig) => Boolean(addressConfig.enabled))
338
+ .map((addressConfig) => addressConfig.address);
333
339
  if (addresses.length > 0) {
334
340
  await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(addresses);
335
341
  }
336
342
  }
337
- catch (e) {
338
- loglevel_1.default.error('Failed to enable push notifications', e);
343
+ catch {
344
+ // Do nothing, failing silently.
339
345
  }
340
346
  }
341
347
  /**
@@ -375,12 +381,12 @@ class NotificationServicesController extends base_controller_1.BaseController {
375
381
  */
376
382
  async setFeatureAnnouncementsEnabled(featureAnnouncementsEnabled) {
377
383
  try {
378
- this.update((s) => {
379
- s.isFeatureAnnouncementsEnabled = featureAnnouncementsEnabled;
384
+ this.update((state) => {
385
+ state.isFeatureAnnouncementsEnabled = featureAnnouncementsEnabled;
380
386
  });
381
387
  }
382
- catch (e) {
383
- loglevel_1.default.error('Unable to toggle feature announcements', e);
388
+ catch (error) {
389
+ loglevel_1.default.error('Unable to toggle feature announcements', error);
384
390
  throw new Error('Unable to toggle feature announcements');
385
391
  }
386
392
  }
@@ -405,8 +411,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
405
411
  // Notifications API can return array with addresses set to false
406
412
  // So assert that at least one address is enabled
407
413
  let accountsWithNotifications = addressesWithNotifications
408
- .filter((a) => Boolean(a.enabled))
409
- .map((a) => a.address);
414
+ .filter((addressConfig) => Boolean(addressConfig.enabled))
415
+ .map((addressConfig) => addressConfig.address);
410
416
  // 2. Enable Notifications (if no accounts subscribed or we are resetting)
411
417
  if (accountsWithNotifications.length === 0 || opts?.resetNotifications) {
412
418
  await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
@@ -420,13 +426,21 @@ class NotificationServicesController extends base_controller_1.BaseController {
420
426
  });
421
427
  // Update the state of the controller
422
428
  this.update((state) => {
423
- state.isNotificationServicesEnabled = true;
424
- state.isFeatureAnnouncementsEnabled = true;
425
- state.isMetamaskNotificationsFeatureSeen = true;
429
+ // User is re-subscribing (daily resub to get latest notifications)
430
+ if (state.isNotificationServicesEnabled) {
431
+ // Keep their existing preferences on re-subscribe
432
+ // No state updates needed - preserving user's current settings
433
+ }
434
+ else {
435
+ // User is turning on notifications from a disabled state
436
+ state.isNotificationServicesEnabled = true;
437
+ state.isFeatureAnnouncementsEnabled = true;
438
+ state.isMetamaskNotificationsFeatureSeen = true;
439
+ }
426
440
  });
427
441
  }
428
- catch (err) {
429
- loglevel_1.default.error('Failed to create On Chain triggers', err);
442
+ catch (error) {
443
+ loglevel_1.default.error('Failed to create On Chain triggers', error);
430
444
  throw new Error('Failed to create On Chain triggers');
431
445
  }
432
446
  finally {
@@ -445,8 +459,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
445
459
  await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
446
460
  await this.createOnChainTriggers();
447
461
  }
448
- catch (e) {
449
- loglevel_1.default.error('Unable to enable notifications', e);
462
+ catch (error) {
463
+ loglevel_1.default.error('Unable to enable notifications', error);
450
464
  throw new Error('Unable to enable notifications');
451
465
  }
452
466
  finally {
@@ -503,8 +517,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
503
517
  // Delete these UUIDs (Mutates User Storage)
504
518
  await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: false })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
505
519
  }
506
- catch (err) {
507
- loglevel_1.default.error('Failed to delete OnChain triggers', err);
520
+ catch {
508
521
  throw new Error('Failed to delete OnChain triggers');
509
522
  }
510
523
  finally {
@@ -532,8 +545,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
532
545
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
533
546
  await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
534
547
  }
535
- catch (err) {
536
- loglevel_1.default.error('Failed to update OnChain triggers', err);
548
+ catch (error) {
549
+ loglevel_1.default.error('Failed to update OnChain triggers', error);
537
550
  throw new Error('Failed to update OnChain triggers');
538
551
  }
539
552
  finally {
@@ -567,8 +580,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
567
580
  const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
568
581
  const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
569
582
  const addressesWithNotifications = (await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")))
570
- .filter((a) => Boolean(a.enabled))
571
- .map((a) => a.address);
583
+ .filter((addressConfig) => Boolean(addressConfig.enabled))
584
+ .map((addressConfig) => addressConfig.address);
572
585
  const notifications = await (0, api_notifications_1.getAPINotifications)(bearerToken, addressesWithNotifications, __classPrivateFieldGet(this, _NotificationServicesController_locale, "f").call(this), __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")).catch(() => []);
573
586
  rawOnChainNotifications.push(...notifications);
574
587
  }
@@ -587,7 +600,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
587
600
  ...snapNotifications,
588
601
  ];
589
602
  // Sort Notifications
590
- metamaskNotifications.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
603
+ metamaskNotifications.sort((notificationA, notificationB) => new Date(notificationB.createdAt).getTime() -
604
+ new Date(notificationA.createdAt).getTime());
591
605
  // Update State
592
606
  this.update((state) => {
593
607
  state.metamaskNotificationsList = metamaskNotifications;
@@ -596,9 +610,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
596
610
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
597
611
  return metamaskNotifications;
598
612
  }
599
- catch (err) {
613
+ catch (error) {
600
614
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
601
- loglevel_1.default.error('Failed to fetch notifications', err);
615
+ loglevel_1.default.error('Failed to fetch notifications', error);
602
616
  throw new Error('Failed to fetch notifications');
603
617
  }
604
618
  }
@@ -694,8 +708,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
694
708
  snapNotificationIds = snapNotifications.map((notification) => notification.id);
695
709
  }
696
710
  }
697
- catch (err) {
698
- loglevel_1.default.warn('Something failed when marking notifications as read', err);
711
+ catch (error) {
712
+ loglevel_1.default.warn('Something failed when marking notifications as read', error);
699
713
  }
700
714
  // Update the state (state is also used on counter & badge)
701
715
  this.update((state) => {
@@ -732,13 +746,13 @@ class NotificationServicesController extends base_controller_1.BaseController {
732
746
  * @returns A promise that resolves when the notification list has been successfully updated.
733
747
  */
734
748
  async updateMetamaskNotificationsList(notification) {
735
- if (this.state.metamaskNotificationsList.some((n) => n.id === notification.id)) {
749
+ if (this.state.metamaskNotificationsList.some((existingNotification) => existingNotification.id === notification.id)) {
736
750
  return;
737
751
  }
738
752
  const processedNotification = (0, process_notifications_1.safeProcessNotification)(notification);
739
753
  if (processedNotification) {
740
754
  this.update((state) => {
741
- const existingNotificationIds = new Set(state.metamaskNotificationsList.map((n) => n.id));
755
+ const existingNotificationIds = new Set(state.metamaskNotificationsList.map((existingNotification) => existingNotification.id));
742
756
  // Add the new notification only if its ID is not already present in the list
743
757
  if (!existingNotificationIds.has(processedNotification.id)) {
744
758
  state.metamaskNotificationsList = [