@metamask/notification-services-controller 20.0.0 → 22.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.
- package/CHANGELOG.md +41 -2
- package/dist/NotificationServicesController/NotificationServicesController.cjs +65 -51
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +4 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +4 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +65 -51
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs +4 -12
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts +0 -12
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +0 -12
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -11
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/index.cjs +1 -2
- package/dist/NotificationServicesController/index.cjs.map +1 -1
- package/dist/NotificationServicesController/index.d.cts +0 -1
- package/dist/NotificationServicesController/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/index.d.mts +0 -1
- package/dist/NotificationServicesController/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/index.mjs +0 -1
- package/dist/NotificationServicesController/index.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +120 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs +120 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts +1 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts +1 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +10 -4
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.mjs +10 -4
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +11 -9
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.cts +1 -563
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +1 -563
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.mjs +11 -9
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts +1 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts +1 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.cjs +54 -34
- package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.d.cts +15 -10
- package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.d.mts +15 -10
- package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.mjs +48 -34
- package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.cjs +10 -10
- package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.mjs +10 -10
- package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.cjs +4 -4
- package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.mjs +4 -4
- package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.cjs +2 -2
- package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.mjs +2 -2
- package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts +2 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +2 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.cjs +2 -6
- package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.d.cts +23 -0
- package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.d.mts +23 -0
- package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.mjs +2 -6
- package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.cjs +2 -0
- package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.mjs +2 -0
- package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +2 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +2 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +2 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +2 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +9 -24
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +9 -24
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs +10 -3
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts +3 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts +3 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs +7 -2
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +2 -1
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +3 -0
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +3 -0
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +2 -1
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +4 -4
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +4 -4
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +62 -71
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +9 -9
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +9 -9
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +62 -71
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.cjs +15 -7
- package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.mjs +16 -8
- package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
- package/dist/shared/is-onchain-notification.cjs +3 -3
- package/dist/shared/is-onchain-notification.cjs.map +1 -1
- package/dist/shared/is-onchain-notification.d.cts +2 -2
- package/dist/shared/is-onchain-notification.d.cts.map +1 -1
- package/dist/shared/is-onchain-notification.d.mts +2 -2
- package/dist/shared/is-onchain-notification.d.mts.map +1 -1
- package/dist/shared/is-onchain-notification.mjs +3 -3
- package/dist/shared/is-onchain-notification.mjs.map +1 -1
- package/dist/shared/to-raw-notification.cjs.map +1 -1
- package/dist/shared/to-raw-notification.mjs.map +1 -1
- package/package.json +7 -21
- package/dist/NotificationServicesController/ui/constants.cjs +0 -75
- package/dist/NotificationServicesController/ui/constants.cjs.map +0 -1
- package/dist/NotificationServicesController/ui/constants.d.cts +0 -66
- package/dist/NotificationServicesController/ui/constants.d.cts.map +0 -1
- package/dist/NotificationServicesController/ui/constants.d.mts +0 -66
- package/dist/NotificationServicesController/ui/constants.d.mts.map +0 -1
- package/dist/NotificationServicesController/ui/constants.mjs +0 -71
- package/dist/NotificationServicesController/ui/constants.mjs.map +0 -1
- package/dist/NotificationServicesController/ui/index.cjs +0 -18
- package/dist/NotificationServicesController/ui/index.cjs.map +0 -1
- package/dist/NotificationServicesController/ui/index.d.cts +0 -2
- package/dist/NotificationServicesController/ui/index.d.cts.map +0 -1
- package/dist/NotificationServicesController/ui/index.d.mts +0 -2
- package/dist/NotificationServicesController/ui/index.d.mts.map +0 -1
- package/dist/NotificationServicesController/ui/index.mjs +0 -2
- package/dist/NotificationServicesController/ui/index.mjs.map +0 -1
- package/dist/NotificationServicesPushController/services/push/push-web.cjs +0 -145
- package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +0 -1
- package/dist/NotificationServicesPushController/services/push/push-web.d.cts +0 -34
- package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/services/push/push-web.d.mts +0 -34
- package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/services/push/push-web.mjs +0 -142
- package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +0 -1
- 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.0.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Upgrade `@metamask/utils` from `^11.8.1` to `^11.9.0` ([#7511](https://github.com/MetaMask/core/pull/7511))
|
|
15
|
+
- 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))
|
|
16
|
+
- The dependencies moved are:
|
|
17
|
+
- `@metamask/keyring-controller` (^25.1.0)
|
|
18
|
+
- `@metamask/profile-sync-controller` (^27.1.0)
|
|
19
|
+
- In clients, it is now possible for multiple versions of these packages to exist in the dependency tree.
|
|
20
|
+
- 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.
|
|
21
|
+
- 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.
|
|
22
|
+
- Modified background push utilities to handle more edgecases and not throw errors ([#7275](https://github.com/MetaMask/core/pull/7275))
|
|
23
|
+
- 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))
|
|
24
|
+
- Move notifications networks metadata to backend ([#7840](https://github.com/MetaMask/core/pull/7840))
|
|
25
|
+
|
|
26
|
+
### Removed
|
|
27
|
+
|
|
28
|
+
- **BREAKING:** Removed the `"./notification-services/ui"` subpath export from `package.json` ([#7840](https://github.com/MetaMask/core/pull/7840))
|
|
29
|
+
- Consumers that import from `@metamask/notification-services-controller/notification-services/ui` must switch to network config provided by the backend.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- 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))
|
|
34
|
+
- Fix `createOnChainTriggers` to preserve user preferences on notification re-subscriptions ([#7423](https://github.com/MetaMask/core/pull/7423))
|
|
35
|
+
- Previously, `isFeatureAnnouncementsEnabled` was unconditionally set to `true` on every re-subscription, overriding user preferences
|
|
36
|
+
- Now, existing preferences are preserved when `isNotificationServicesEnabled` is already `true`
|
|
37
|
+
|
|
38
|
+
## [21.0.0]
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Bump `@metamask/controller-utils` from `^11.15.0` to `^11.16.0` ([#7202](https://github.com/MetaMask/core/pull/7202))
|
|
43
|
+
- **BREAKING:** Bump `@metamask/profile-sync-controller` from `^26.0.0` to `^27.0.0` ([#7202](https://github.com/MetaMask/core/pull/7202))
|
|
44
|
+
- **BREAKING:** Bump `@metamask/keyring-controller` from `^24.0.0` to `^25.0.0` ([#7202](https://github.com/MetaMask/core/pull/7202))
|
|
45
|
+
- Add optional `env` parameter to the `NotificationServicesController` and `NotificationServicesPushController`
|
|
46
|
+
to support different environments (`prd`, `uat`, `dev`). ([#7175](https://github.com/MetaMask/core/pull/7175))
|
|
47
|
+
|
|
10
48
|
## [20.0.0]
|
|
11
49
|
|
|
12
50
|
### Changed
|
|
@@ -187,7 +225,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
187
225
|
### Removed
|
|
188
226
|
|
|
189
227
|
- **BREAKING:** Migrated to notification v2 endpoints ([#5945](https://github.com/MetaMask/core/pull/5945))
|
|
190
|
-
|
|
191
228
|
- removed `NotificationServicesPushController:updateTriggerPushNotifications` action from `NotificationServicesController`
|
|
192
229
|
- removed `UserStorageController:getStorageKey` action from `NotificationServicesController`
|
|
193
230
|
- removed `UserStorageController:performGetStorage` action from `NotificationServicesController`
|
|
@@ -620,7 +657,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
620
657
|
|
|
621
658
|
- Initial release
|
|
622
659
|
|
|
623
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@
|
|
660
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@22.0.0...HEAD
|
|
661
|
+
[22.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@21.0.0...@metamask/notification-services-controller@22.0.0
|
|
662
|
+
[21.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@20.0.0...@metamask/notification-services-controller@21.0.0
|
|
624
663
|
[20.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@19.0.0...@metamask/notification-services-controller@20.0.0
|
|
625
664
|
[19.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@18.3.1...@metamask/notification-services-controller@19.0.0
|
|
626
665
|
[18.3.1]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@18.3.0...@metamask/notification-services-controller@18.3.1
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
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;
|
|
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
18
|
exports.defaultState = void 0;
|
|
19
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -118,6 +118,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
118
118
|
* @param args.env - environment variables for a given controller.
|
|
119
119
|
* @param args.env.featureAnnouncements - env variables for feature announcements.
|
|
120
120
|
* @param args.env.locale - users locale for better dynamic server notifications
|
|
121
|
+
* @param args.env.env - the environment to use for the controller
|
|
121
122
|
*/
|
|
122
123
|
constructor({ messenger, state, env, }) {
|
|
123
124
|
super({
|
|
@@ -167,16 +168,16 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
167
168
|
try {
|
|
168
169
|
await this.messenger.call('NotificationServicesPushController:enablePushNotifications', addresses);
|
|
169
170
|
}
|
|
170
|
-
catch
|
|
171
|
-
|
|
171
|
+
catch {
|
|
172
|
+
// Do nothing, failing silently.
|
|
172
173
|
}
|
|
173
174
|
},
|
|
174
175
|
disablePushNotifications: async () => {
|
|
175
176
|
try {
|
|
176
177
|
await this.messenger.call('NotificationServicesPushController:disablePushNotifications');
|
|
177
178
|
}
|
|
178
|
-
catch
|
|
179
|
-
|
|
179
|
+
catch {
|
|
180
|
+
// Do nothing, failing silently.
|
|
180
181
|
}
|
|
181
182
|
},
|
|
182
183
|
subscribe: () => {
|
|
@@ -215,7 +216,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
215
216
|
isNotificationAccountsSetup: false,
|
|
216
217
|
getNotificationAccounts: () => {
|
|
217
218
|
const { keyrings } = this.messenger.call('KeyringController:getState');
|
|
218
|
-
const firstHDKeyring = keyrings.find((
|
|
219
|
+
const firstHDKeyring = keyrings.find((keyring) => keyring.type === keyring_controller_1.KeyringTypes.hd.toString());
|
|
219
220
|
const keyringAccounts = firstHDKeyring?.accounts ?? null;
|
|
220
221
|
return keyringAccounts;
|
|
221
222
|
},
|
|
@@ -235,8 +236,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
235
236
|
};
|
|
236
237
|
}
|
|
237
238
|
const accounts = nonChecksumAccounts
|
|
238
|
-
.map((
|
|
239
|
-
.filter((
|
|
239
|
+
.map((address) => (0, controller_utils_1.toChecksumHexAddress)(address))
|
|
240
|
+
.filter((address) => (0, controller_utils_1.isValidHexAddress)(address));
|
|
240
241
|
const currentAccountsSet = new Set(accounts);
|
|
241
242
|
const prevAccountsSet = new Set(this.state.subscriptionAccountsSeen);
|
|
242
243
|
// Invalid value you cannot have zero accounts
|
|
@@ -249,8 +250,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
252
|
// Calculate added and removed addresses
|
|
252
|
-
const accountsAdded = accounts.filter((
|
|
253
|
-
const accountsRemoved = [...prevAccountsSet.values()].filter((
|
|
253
|
+
const accountsAdded = accounts.filter((account) => !prevAccountsSet.has(account));
|
|
254
|
+
const accountsRemoved = [...prevAccountsSet.values()].filter((account) => !currentAccountsSet.has(account));
|
|
254
255
|
// Update accounts seen
|
|
255
256
|
this.update((state) => {
|
|
256
257
|
state.subscriptionAccountsSeen = [...currentAccountsSet];
|
|
@@ -277,7 +278,10 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
277
278
|
* And call effects to subscribe/unsubscribe to notifications.
|
|
278
279
|
*/
|
|
279
280
|
subscribe: () => {
|
|
280
|
-
this.messenger.subscribe('KeyringController:stateChange',
|
|
281
|
+
this.messenger.subscribe('KeyringController:stateChange',
|
|
282
|
+
// Using void return for async callback - result is intentionally ignored
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
284
|
+
async (totalAccounts, prevTotalAccounts) => {
|
|
281
285
|
const hasTotalAccountsChanged = totalAccounts !== prevTotalAccounts;
|
|
282
286
|
if (!this.state.isNotificationServicesEnabled ||
|
|
283
287
|
!hasTotalAccountsChanged) {
|
|
@@ -300,8 +304,10 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
300
304
|
});
|
|
301
305
|
_NotificationServicesController_locale.set(this, void 0);
|
|
302
306
|
_NotificationServicesController_featureAnnouncementEnv.set(this, void 0);
|
|
307
|
+
_NotificationServicesController_env.set(this, void 0);
|
|
303
308
|
__classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
|
|
304
309
|
__classPrivateFieldSet(this, _NotificationServicesController_locale, env.locale ?? (() => 'en'), "f");
|
|
310
|
+
__classPrivateFieldSet(this, _NotificationServicesController_env, env.env ?? 'prd', "f");
|
|
305
311
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerMessageHandlers).call(this);
|
|
306
312
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
|
|
307
313
|
}
|
|
@@ -323,16 +329,16 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
323
329
|
try {
|
|
324
330
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
325
331
|
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
326
|
-
const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts);
|
|
332
|
+
const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
327
333
|
const addresses = addressesWithNotifications
|
|
328
|
-
.filter((
|
|
329
|
-
.map((
|
|
334
|
+
.filter((addressConfig) => Boolean(addressConfig.enabled))
|
|
335
|
+
.map((addressConfig) => addressConfig.address);
|
|
330
336
|
if (addresses.length > 0) {
|
|
331
337
|
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(addresses);
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
|
-
catch
|
|
335
|
-
|
|
340
|
+
catch {
|
|
341
|
+
// Do nothing, failing silently.
|
|
336
342
|
}
|
|
337
343
|
}
|
|
338
344
|
/**
|
|
@@ -346,7 +352,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
346
352
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsCheckingAccountsPresence).call(this, true);
|
|
347
353
|
// Retrieve user storage
|
|
348
354
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
349
|
-
const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts);
|
|
355
|
+
const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
350
356
|
const result = {};
|
|
351
357
|
addressesWithNotifications.forEach((a) => {
|
|
352
358
|
result[a.address] = a.enabled;
|
|
@@ -372,12 +378,12 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
372
378
|
*/
|
|
373
379
|
async setFeatureAnnouncementsEnabled(featureAnnouncementsEnabled) {
|
|
374
380
|
try {
|
|
375
|
-
this.update((
|
|
376
|
-
|
|
381
|
+
this.update((state) => {
|
|
382
|
+
state.isFeatureAnnouncementsEnabled = featureAnnouncementsEnabled;
|
|
377
383
|
});
|
|
378
384
|
}
|
|
379
|
-
catch (
|
|
380
|
-
loglevel_1.default.error('Unable to toggle feature announcements',
|
|
385
|
+
catch (error) {
|
|
386
|
+
loglevel_1.default.error('Unable to toggle feature announcements', error);
|
|
381
387
|
throw new Error('Unable to toggle feature announcements');
|
|
382
388
|
}
|
|
383
389
|
}
|
|
@@ -398,15 +404,15 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
398
404
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
399
405
|
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
400
406
|
// 1. See if has enabled notifications before
|
|
401
|
-
const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts);
|
|
407
|
+
const addressesWithNotifications = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
402
408
|
// Notifications API can return array with addresses set to false
|
|
403
409
|
// So assert that at least one address is enabled
|
|
404
410
|
let accountsWithNotifications = addressesWithNotifications
|
|
405
|
-
.filter((
|
|
406
|
-
.map((
|
|
411
|
+
.filter((addressConfig) => Boolean(addressConfig.enabled))
|
|
412
|
+
.map((addressConfig) => addressConfig.address);
|
|
407
413
|
// 2. Enable Notifications (if no accounts subscribed or we are resetting)
|
|
408
414
|
if (accountsWithNotifications.length === 0 || opts?.resetNotifications) {
|
|
409
|
-
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })));
|
|
415
|
+
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
410
416
|
accountsWithNotifications = accounts;
|
|
411
417
|
}
|
|
412
418
|
// 3. Lazily enable push notifications (FCM may take some time, so keeps UI unblocked)
|
|
@@ -417,13 +423,21 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
417
423
|
});
|
|
418
424
|
// Update the state of the controller
|
|
419
425
|
this.update((state) => {
|
|
420
|
-
|
|
421
|
-
state.
|
|
422
|
-
|
|
426
|
+
// User is re-subscribing (daily resub to get latest notifications)
|
|
427
|
+
if (state.isNotificationServicesEnabled) {
|
|
428
|
+
// Keep their existing preferences on re-subscribe
|
|
429
|
+
// No state updates needed - preserving user's current settings
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
// User is turning on notifications from a disabled state
|
|
433
|
+
state.isNotificationServicesEnabled = true;
|
|
434
|
+
state.isFeatureAnnouncementsEnabled = true;
|
|
435
|
+
state.isMetamaskNotificationsFeatureSeen = true;
|
|
436
|
+
}
|
|
423
437
|
});
|
|
424
438
|
}
|
|
425
|
-
catch (
|
|
426
|
-
loglevel_1.default.error('Failed to create On Chain triggers',
|
|
439
|
+
catch (error) {
|
|
440
|
+
loglevel_1.default.error('Failed to create On Chain triggers', error);
|
|
427
441
|
throw new Error('Failed to create On Chain triggers');
|
|
428
442
|
}
|
|
429
443
|
finally {
|
|
@@ -442,8 +456,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
442
456
|
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
|
|
443
457
|
await this.createOnChainTriggers();
|
|
444
458
|
}
|
|
445
|
-
catch (
|
|
446
|
-
loglevel_1.default.error('Unable to enable notifications',
|
|
459
|
+
catch (error) {
|
|
460
|
+
loglevel_1.default.error('Unable to enable notifications', error);
|
|
447
461
|
throw new Error('Unable to enable notifications');
|
|
448
462
|
}
|
|
449
463
|
finally {
|
|
@@ -498,10 +512,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
498
512
|
// Get and Validate BearerToken and User Storage Key
|
|
499
513
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
500
514
|
// Delete these UUIDs (Mutates User Storage)
|
|
501
|
-
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: false })));
|
|
515
|
+
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: false })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
502
516
|
}
|
|
503
|
-
catch
|
|
504
|
-
loglevel_1.default.error('Failed to delete OnChain triggers', err);
|
|
517
|
+
catch {
|
|
505
518
|
throw new Error('Failed to delete OnChain triggers');
|
|
506
519
|
}
|
|
507
520
|
finally {
|
|
@@ -527,10 +540,10 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
527
540
|
try {
|
|
528
541
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
529
542
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
530
|
-
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })));
|
|
543
|
+
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
531
544
|
}
|
|
532
|
-
catch (
|
|
533
|
-
loglevel_1.default.error('Failed to update OnChain triggers',
|
|
545
|
+
catch (error) {
|
|
546
|
+
loglevel_1.default.error('Failed to update OnChain triggers', error);
|
|
534
547
|
throw new Error('Failed to update OnChain triggers');
|
|
535
548
|
}
|
|
536
549
|
finally {
|
|
@@ -563,10 +576,10 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
563
576
|
try {
|
|
564
577
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
565
578
|
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
566
|
-
const addressesWithNotifications = (await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts))
|
|
567
|
-
.filter((
|
|
568
|
-
.map((
|
|
569
|
-
const notifications = await (0, api_notifications_1.getAPINotifications)(bearerToken, addressesWithNotifications, __classPrivateFieldGet(this, _NotificationServicesController_locale, "f").call(this), __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform).catch(() => []);
|
|
579
|
+
const addressesWithNotifications = (await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")))
|
|
580
|
+
.filter((addressConfig) => Boolean(addressConfig.enabled))
|
|
581
|
+
.map((addressConfig) => addressConfig.address);
|
|
582
|
+
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(() => []);
|
|
570
583
|
rawOnChainNotifications.push(...notifications);
|
|
571
584
|
}
|
|
572
585
|
catch {
|
|
@@ -584,7 +597,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
584
597
|
...snapNotifications,
|
|
585
598
|
];
|
|
586
599
|
// Sort Notifications
|
|
587
|
-
metamaskNotifications.sort((
|
|
600
|
+
metamaskNotifications.sort((notificationA, notificationB) => new Date(notificationB.createdAt).getTime() -
|
|
601
|
+
new Date(notificationA.createdAt).getTime());
|
|
588
602
|
// Update State
|
|
589
603
|
this.update((state) => {
|
|
590
604
|
state.metamaskNotificationsList = metamaskNotifications;
|
|
@@ -593,9 +607,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
593
607
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
|
|
594
608
|
return metamaskNotifications;
|
|
595
609
|
}
|
|
596
|
-
catch (
|
|
610
|
+
catch (error) {
|
|
597
611
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
|
|
598
|
-
loglevel_1.default.error('Failed to fetch notifications',
|
|
612
|
+
loglevel_1.default.error('Failed to fetch notifications', error);
|
|
599
613
|
throw new Error('Failed to fetch notifications');
|
|
600
614
|
}
|
|
601
615
|
}
|
|
@@ -676,7 +690,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
676
690
|
const bearerToken = await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").getBearerToken();
|
|
677
691
|
if (bearerToken) {
|
|
678
692
|
onchainNotificationIds = onChainNotifications.map((notification) => notification.id);
|
|
679
|
-
await (0, api_notifications_1.markNotificationsAsRead)(bearerToken, onchainNotificationIds).catch(() => {
|
|
693
|
+
await (0, api_notifications_1.markNotificationsAsRead)(bearerToken, onchainNotificationIds, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")).catch(() => {
|
|
680
694
|
onchainNotificationIds = [];
|
|
681
695
|
loglevel_1.default.warn('Unable to mark onchain notifications as read');
|
|
682
696
|
});
|
|
@@ -691,8 +705,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
691
705
|
snapNotificationIds = snapNotifications.map((notification) => notification.id);
|
|
692
706
|
}
|
|
693
707
|
}
|
|
694
|
-
catch (
|
|
695
|
-
loglevel_1.default.warn('Something failed when marking notifications as read',
|
|
708
|
+
catch (error) {
|
|
709
|
+
loglevel_1.default.warn('Something failed when marking notifications as read', error);
|
|
696
710
|
}
|
|
697
711
|
// Update the state (state is also used on counter & badge)
|
|
698
712
|
this.update((state) => {
|
|
@@ -729,13 +743,13 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
729
743
|
* @returns A promise that resolves when the notification list has been successfully updated.
|
|
730
744
|
*/
|
|
731
745
|
async updateMetamaskNotificationsList(notification) {
|
|
732
|
-
if (this.state.metamaskNotificationsList.some((
|
|
746
|
+
if (this.state.metamaskNotificationsList.some((existingNotification) => existingNotification.id === notification.id)) {
|
|
733
747
|
return;
|
|
734
748
|
}
|
|
735
749
|
const processedNotification = (0, process_notifications_1.safeProcessNotification)(notification);
|
|
736
750
|
if (processedNotification) {
|
|
737
751
|
this.update((state) => {
|
|
738
|
-
const existingNotificationIds = new Set(state.metamaskNotificationsList.map((
|
|
752
|
+
const existingNotificationIds = new Set(state.metamaskNotificationsList.map((existingNotification) => existingNotification.id));
|
|
739
753
|
// Add the new notification only if its ID is not already present in the list
|
|
740
754
|
if (!existingNotificationIds.has(processedNotification.id)) {
|
|
741
755
|
state.metamaskNotificationsList = [
|
|
@@ -763,7 +777,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
763
777
|
}
|
|
764
778
|
}
|
|
765
779
|
}
|
|
766
|
-
_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() {
|
|
780
|
+
_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_env = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_registerMessageHandlers = function _NotificationServicesController_registerMessageHandlers() {
|
|
767
781
|
this.messenger.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
|
|
768
782
|
this.messenger.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
|
|
769
783
|
this.messenger.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
|