@metamask-previews/notification-services-controller 10.0.0-preview-3636a128 → 12.0.0-preview-08a4995
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 +39 -1
- package/dist/NotificationServicesController/NotificationServicesController.cjs +78 -188
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +10 -16
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +10 -16
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +79 -189
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/index.cjs +0 -1
- package/dist/NotificationServicesController/constants/index.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/index.d.cts +0 -1
- package/dist/NotificationServicesController/constants/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/index.d.mts +0 -1
- package/dist/NotificationServicesController/constants/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/index.mjs +0 -1
- package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.cjs +0 -2
- package/dist/NotificationServicesController/mocks/index.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.d.cts +0 -2
- package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/index.d.mts +0 -2
- package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/index.mjs +0 -2
- package/dist/NotificationServicesController/mocks/index.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +9 -9
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts +7 -4
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts +7 -4
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.mjs +7 -7
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +4 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.cts +623 -0
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +623 -0
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.mjs +2 -0
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.cjs +61 -0
- package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -0
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts +15 -0
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts +15 -0
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/notification-config-cache.mjs +57 -0
- package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.cjs +67 -140
- package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts +25 -31
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts +25 -31
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.mjs +65 -137
- package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/index.cjs.map +1 -1
- package/dist/NotificationServicesController/types/index.d.cts +0 -1
- package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/index.d.mts +0 -1
- package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesController/ui/constants.cjs +6 -0
- package/dist/NotificationServicesController/ui/constants.cjs.map +1 -1
- package/dist/NotificationServicesController/ui/constants.d.cts +6 -0
- package/dist/NotificationServicesController/ui/constants.d.cts.map +1 -1
- package/dist/NotificationServicesController/ui/constants.d.mts +6 -0
- package/dist/NotificationServicesController/ui/constants.d.mts.map +1 -1
- package/dist/NotificationServicesController/ui/constants.mjs +6 -0
- package/dist/NotificationServicesController/ui/constants.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.cjs +1 -350
- package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.cts +0 -141
- package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.mts +0 -141
- package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.mjs +0 -337
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +22 -15
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +6 -5
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +6 -5
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +23 -16
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +1 -16
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +0 -7
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +0 -7
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +0 -14
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +18 -41
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +19 -33
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +19 -33
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +17 -39
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/NotificationServicesController/constants/constants.cjs +0 -7
- package/dist/NotificationServicesController/constants/constants.cjs.map +0 -1
- package/dist/NotificationServicesController/constants/constants.d.cts +0 -3
- package/dist/NotificationServicesController/constants/constants.d.cts.map +0 -1
- package/dist/NotificationServicesController/constants/constants.d.mts +0 -3
- package/dist/NotificationServicesController/constants/constants.d.mts.map +0 -1
- package/dist/NotificationServicesController/constants/constants.mjs +0 -4
- package/dist/NotificationServicesController/constants/constants.mjs.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs +0 -22
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts +0 -9
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts +0 -9
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs +0 -18
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs +0 -82
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts +0 -35
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts +0 -35
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs +0 -76
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/index.cjs +0 -3
- package/dist/NotificationServicesController/types/user-storage/index.cjs.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/index.d.cts +0 -2
- package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/index.d.mts +0 -2
- package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/index.mjs +0 -2
- package/dist/NotificationServicesController/types/user-storage/index.mjs.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +0 -3
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts +0 -26
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +0 -26
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +0 -2
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [12.0.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **BREAKING:** Bump peer dependency `@metamask/profile-sync-controller` to `^19.0.0` ([#5999](https://github.com/MetaMask/core/pull/5999))
|
|
15
|
+
|
|
16
|
+
## [11.0.0]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- SEI network to supported networks for notifications ([#5945](https://github.com/MetaMask/core/pull/5945))
|
|
21
|
+
- Added `SEI` to `NOTIFICATION_CHAINS_ID` constant
|
|
22
|
+
- Added `Sei Network` to default `NOTIFICATION_NETWORK_CURRENCY_NAME` constant
|
|
23
|
+
- Added `SEI` to default `NOTIFICATION_NETWORK_CURRENCY_SYMBOL` constant
|
|
24
|
+
- Added SEI block explorer to default `SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS` constant
|
|
25
|
+
|
|
10
26
|
### Changed
|
|
11
27
|
|
|
28
|
+
- **BREAKING:** bump `@metamask/profile-sync-controller` peer dependency to `^18.0.0` ([#5996](https://github.com/MetaMask/core/pull/5996))
|
|
29
|
+
- **BREAKING:** Migrated to notification v2 endpoints ([#5945](https://github.com/MetaMask/core/pull/5945))
|
|
30
|
+
|
|
31
|
+
- `https://trigger.api.cx.metamask.io/api/v1` to `https://trigger.api.cx.metamask.io/api/v2` for managing out notification subscriptions
|
|
32
|
+
- `https://notification.api.cx.metamask.io/api/v1` to `https://notification.api.cx.metamask.io/api/v2` for fetching notifications (in-app notifications)
|
|
33
|
+
- `https://push.api.cx.metamask.io/v1` to `https://push.api.cx.metamask.io/v2` for subscribing push notifications
|
|
34
|
+
- Renamed method `updateOnChainTriggersByAccount` to `enableAccounts` in `NotificationServicesController`
|
|
35
|
+
- Renamed method `deleteOnChainTriggersByAccount` to `disableAccounts` in `NotificationServicesController`
|
|
36
|
+
- Deprecated `updateTriggerPushNotifications` from `NotificationServicesPushController` and will be removed in a subsequent release.
|
|
37
|
+
|
|
12
38
|
- Bump `@metamask/controller-utils` to `^11.10.0` ([#5935](https://github.com/MetaMask/core/pull/5935))
|
|
13
39
|
|
|
40
|
+
### Removed
|
|
41
|
+
|
|
42
|
+
- **BREAKING:** Migrated to notification v2 endpoints ([#5945](https://github.com/MetaMask/core/pull/5945))
|
|
43
|
+
|
|
44
|
+
- removed `NotificationServicesPushController:updateTriggerPushNotifications` action from `NotificationServicesController`
|
|
45
|
+
- removed `UserStorageController:getStorageKey` action from `NotificationServicesController`
|
|
46
|
+
- removed `UserStorageController:performGetStorage` action from `NotificationServicesController`
|
|
47
|
+
- removed `UserStorageController:performSetStorage` action from `NotificationServicesController`
|
|
48
|
+
- removed UserStorage notification utilities: `initializeUserStorage`, `cleanUserStorage`, `traverseUserStorageTriggers`, `checkAccountsPresence`, `inferEnabledKinds`, `getUUIDsForAccount`, `getAllUUIDs`, `getUUIDsForKinds`, `getUUIDsForAccountByKinds`, `upsertAddressTriggers`, `upsertTriggerTypeTriggers`, `toggleUserStorageTriggerStatus`.
|
|
49
|
+
|
|
14
50
|
## [10.0.0]
|
|
15
51
|
|
|
16
52
|
### Changed
|
|
@@ -437,7 +473,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
437
473
|
|
|
438
474
|
- Initial release
|
|
439
475
|
|
|
440
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@
|
|
476
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@12.0.0...HEAD
|
|
477
|
+
[12.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@11.0.0...@metamask/notification-services-controller@12.0.0
|
|
478
|
+
[11.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@10.0.0...@metamask/notification-services-controller@11.0.0
|
|
441
479
|
[10.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@9.0.0...@metamask/notification-services-controller@10.0.0
|
|
442
480
|
[9.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@8.0.0...@metamask/notification-services-controller@9.0.0
|
|
443
481
|
[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@7.0.0...@metamask/notification-services-controller@8.0.0
|
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth,
|
|
39
|
+
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;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.defaultState = void 0;
|
|
42
42
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -44,12 +44,10 @@ const controller_utils_1 = require("@metamask/controller-utils");
|
|
|
44
44
|
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
45
45
|
const utils_1 = require("@metamask/utils");
|
|
46
46
|
const loglevel_1 = __importDefault(require("loglevel"));
|
|
47
|
-
const constants_1 = require("./constants/constants.cjs");
|
|
48
47
|
const notification_schema_1 = require("./constants/notification-schema.cjs");
|
|
49
48
|
const process_notifications_1 = require("./processors/process-notifications.cjs");
|
|
50
49
|
const FeatureNotifications = __importStar(require("./services/feature-announcements.cjs"));
|
|
51
50
|
const OnChainNotifications = __importStar(require("./services/onchain-notifications.cjs"));
|
|
52
|
-
const Utils = __importStar(require("./utils/utils.cjs"));
|
|
53
51
|
// Unique name for the controller
|
|
54
52
|
const controllerName = 'NotificationServicesController';
|
|
55
53
|
const metadata = {
|
|
@@ -159,17 +157,6 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
159
157
|
return await this.messagingSystem.call('AuthenticationController:performSignIn');
|
|
160
158
|
},
|
|
161
159
|
});
|
|
162
|
-
_NotificationServicesController_storage.set(this, {
|
|
163
|
-
getStorageKey: () => {
|
|
164
|
-
return this.messagingSystem.call('UserStorageController:getStorageKey');
|
|
165
|
-
},
|
|
166
|
-
getNotificationStorage: async () => {
|
|
167
|
-
return await this.messagingSystem.call('UserStorageController:performGetStorage', 'notifications.notification_settings');
|
|
168
|
-
},
|
|
169
|
-
setNotificationStorage: async (state) => {
|
|
170
|
-
return await this.messagingSystem.call('UserStorageController:performSetStorage', 'notifications.notification_settings', state);
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
160
|
_NotificationServicesController_pushNotifications.set(this, {
|
|
174
161
|
// Flag to check is notifications have been setup when the browser/extension is initialized.
|
|
175
162
|
// We want to re-initialize push notifications when the browser/extension is refreshed
|
|
@@ -178,9 +165,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
178
165
|
subscribeToPushNotifications: async () => {
|
|
179
166
|
await this.messagingSystem.call('NotificationServicesPushController:subscribeToPushNotifications');
|
|
180
167
|
},
|
|
181
|
-
enablePushNotifications: async (
|
|
168
|
+
enablePushNotifications: async (addresses) => {
|
|
182
169
|
try {
|
|
183
|
-
await this.messagingSystem.call('NotificationServicesPushController:enablePushNotifications',
|
|
170
|
+
await this.messagingSystem.call('NotificationServicesPushController:enablePushNotifications', addresses);
|
|
184
171
|
}
|
|
185
172
|
catch (e) {
|
|
186
173
|
loglevel_1.default.error('Silently failed to enable push notifications', e);
|
|
@@ -194,14 +181,6 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
194
181
|
loglevel_1.default.error('Silently failed to disable push notifications', e);
|
|
195
182
|
}
|
|
196
183
|
},
|
|
197
|
-
updatePushNotifications: async (UUIDs) => {
|
|
198
|
-
try {
|
|
199
|
-
await this.messagingSystem.call('NotificationServicesPushController:updateTriggerPushNotifications', UUIDs);
|
|
200
|
-
}
|
|
201
|
-
catch (e) {
|
|
202
|
-
loglevel_1.default.error('Silently failed to update push notifications', e);
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
184
|
subscribe: () => {
|
|
206
185
|
this.messagingSystem.subscribe('NotificationServicesPushController:onNewNotifications', (notification) => {
|
|
207
186
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
@@ -236,7 +215,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
236
215
|
_NotificationServicesController_accounts.set(this, {
|
|
237
216
|
// Flag to ensure we only setup once
|
|
238
217
|
isNotificationAccountsSetup: false,
|
|
239
|
-
getNotificationAccounts:
|
|
218
|
+
getNotificationAccounts: () => {
|
|
240
219
|
const { keyrings } = this.messagingSystem.call('KeyringController:getState');
|
|
241
220
|
const firstHDKeyring = keyrings.find((k) => k.type === keyring_controller_1.KeyringTypes.hd.toString());
|
|
242
221
|
const keyringAccounts = firstHDKeyring?.accounts ?? null;
|
|
@@ -247,9 +226,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
247
226
|
*
|
|
248
227
|
* @returns addresses removed, added, and latest list of addresses
|
|
249
228
|
*/
|
|
250
|
-
listAccounts:
|
|
229
|
+
listAccounts: () => {
|
|
251
230
|
// Get previous and current account sets
|
|
252
|
-
const nonChecksumAccounts =
|
|
231
|
+
const nonChecksumAccounts = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").getNotificationAccounts();
|
|
253
232
|
if (!nonChecksumAccounts) {
|
|
254
233
|
return {
|
|
255
234
|
accountsAdded: [],
|
|
@@ -286,13 +265,11 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
286
265
|
},
|
|
287
266
|
/**
|
|
288
267
|
* Initializes the cache/previous list. This is handy so we have an accurate in-mem state of the previous list of accounts.
|
|
289
|
-
*
|
|
290
|
-
* @returns result from list accounts
|
|
291
268
|
*/
|
|
292
|
-
initialize:
|
|
269
|
+
initialize: () => {
|
|
293
270
|
if (__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked &&
|
|
294
271
|
!__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup) {
|
|
295
|
-
|
|
272
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
296
273
|
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup = true;
|
|
297
274
|
}
|
|
298
275
|
},
|
|
@@ -308,15 +285,15 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
308
285
|
!hasTotalAccountsChanged) {
|
|
309
286
|
return;
|
|
310
287
|
}
|
|
311
|
-
const { accountsAdded, accountsRemoved } =
|
|
288
|
+
const { accountsAdded, accountsRemoved } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
312
289
|
const promises = [];
|
|
313
290
|
if (accountsAdded.length > 0) {
|
|
314
|
-
promises.push(this.
|
|
291
|
+
promises.push(this.enableAccounts(accountsAdded));
|
|
315
292
|
}
|
|
316
293
|
if (accountsRemoved.length > 0) {
|
|
317
|
-
promises.push(this.
|
|
294
|
+
promises.push(this.disableAccounts(accountsRemoved));
|
|
318
295
|
}
|
|
319
|
-
await Promise.
|
|
296
|
+
await Promise.allSettled(promises);
|
|
320
297
|
}, (state) => {
|
|
321
298
|
return (state?.keyrings?.flatMap?.((keyring) => keyring.accounts)?.length ??
|
|
322
299
|
0);
|
|
@@ -330,10 +307,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
330
307
|
}
|
|
331
308
|
init() {
|
|
332
309
|
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").setupLockedStateSubscriptions(async () => {
|
|
333
|
-
|
|
310
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").initialize();
|
|
334
311
|
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").initializePushNotifications();
|
|
335
312
|
});
|
|
336
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
337
313
|
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").initialize();
|
|
338
314
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
339
315
|
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").initializePushNotifications();
|
|
@@ -344,13 +320,20 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
344
320
|
* Public method to expose enabling push notifications
|
|
345
321
|
*/
|
|
346
322
|
async enablePushNotifications() {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
323
|
+
try {
|
|
324
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
325
|
+
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
326
|
+
const addressesWithNotifications = await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts);
|
|
327
|
+
const addresses = addressesWithNotifications
|
|
328
|
+
.filter((a) => Boolean(a.enabled))
|
|
329
|
+
.map((a) => a.address);
|
|
330
|
+
if (addresses.length > 0) {
|
|
331
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(addresses);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
catch (e) {
|
|
335
|
+
loglevel_1.default.error('Failed to enable push notifications', e);
|
|
351
336
|
}
|
|
352
|
-
const uuids = Utils.getAllUUIDs(storage);
|
|
353
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(uuids);
|
|
354
337
|
}
|
|
355
338
|
/**
|
|
356
339
|
* Public method to expose disabling push notifications
|
|
@@ -362,10 +345,13 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
362
345
|
try {
|
|
363
346
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsCheckingAccountsPresence).call(this, true);
|
|
364
347
|
// Retrieve user storage
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
348
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
349
|
+
const addressesWithNotifications = await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts);
|
|
350
|
+
const result = {};
|
|
351
|
+
addressesWithNotifications.forEach((a) => {
|
|
352
|
+
result[a.address] = a.enabled;
|
|
353
|
+
});
|
|
354
|
+
return result;
|
|
369
355
|
}
|
|
370
356
|
catch (error) {
|
|
371
357
|
loglevel_1.default.error('Failed to check accounts presence', error);
|
|
@@ -409,40 +395,32 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
409
395
|
async createOnChainTriggers(opts) {
|
|
410
396
|
try {
|
|
411
397
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
412
|
-
const { bearerToken
|
|
413
|
-
const { accounts } =
|
|
414
|
-
//
|
|
415
|
-
|
|
416
|
-
//
|
|
417
|
-
//
|
|
418
|
-
let
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
//
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
// Write the userStorage
|
|
426
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
398
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
399
|
+
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
400
|
+
// 1. See if has enabled notifications before
|
|
401
|
+
const addressesWithNotifications = await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts);
|
|
402
|
+
// Notifications API can return array with addresses set to false
|
|
403
|
+
// So assert that at least one address is enabled
|
|
404
|
+
let accountsWithNotifications = addressesWithNotifications
|
|
405
|
+
.filter((a) => Boolean(a.enabled))
|
|
406
|
+
.map((a) => a.address);
|
|
407
|
+
// 2. Enable Notifications (if no accounts subscribed or we are resetting)
|
|
408
|
+
if (accountsWithNotifications.length === 0 || opts?.resetNotifications) {
|
|
409
|
+
await OnChainNotifications.updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: true })));
|
|
410
|
+
accountsWithNotifications = accounts;
|
|
427
411
|
}
|
|
428
|
-
//
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
const allUUIDS = Utils.getAllUUIDs(userStorage);
|
|
433
|
-
// We do not want to wait for this request as it may take a while (e.g. for Firebase to setup)
|
|
434
|
-
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(allUUIDS).catch(() => {
|
|
412
|
+
// 3. Lazily enable push notifications (FCM may take some time, so keeps UI unblocked)
|
|
413
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
414
|
+
.enablePushNotifications(accountsWithNotifications)
|
|
415
|
+
.catch(() => {
|
|
435
416
|
// Do Nothing
|
|
436
417
|
});
|
|
437
|
-
// Write the new userStorage (triggers are now "enabled")
|
|
438
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
439
418
|
// Update the state of the controller
|
|
440
419
|
this.update((state) => {
|
|
441
420
|
state.isNotificationServicesEnabled = true;
|
|
442
421
|
state.isFeatureAnnouncementsEnabled = true;
|
|
443
422
|
state.isMetamaskNotificationsFeatureSeen = true;
|
|
444
423
|
});
|
|
445
|
-
return userStorage;
|
|
446
424
|
}
|
|
447
425
|
catch (err) {
|
|
448
426
|
loglevel_1.default.error('Failed to create On Chain triggers', err);
|
|
@@ -455,10 +433,6 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
455
433
|
/**
|
|
456
434
|
* Enables all MetaMask notifications for the user.
|
|
457
435
|
* This is identical flow when initializing notifications for the first time.
|
|
458
|
-
* 1. Enable Profile Syncing
|
|
459
|
-
* 2. Get or Create Notification User Storage
|
|
460
|
-
* 3. Upsert Triggers
|
|
461
|
-
* 4. Update Push notifications
|
|
462
436
|
*
|
|
463
437
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
464
438
|
*/
|
|
@@ -506,12 +480,11 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
506
480
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
507
481
|
}
|
|
508
482
|
/**
|
|
509
|
-
* Deletes on-chain triggers associated with a specific account.
|
|
483
|
+
* Deletes on-chain triggers associated with a specific account/s.
|
|
510
484
|
* This method performs several key operations:
|
|
511
|
-
* 1. Validates Auth
|
|
512
|
-
* 2.
|
|
513
|
-
*
|
|
514
|
-
* 4. Updates Storage to reflect new state.
|
|
485
|
+
* 1. Validates Auth
|
|
486
|
+
* 2. Deletes accounts
|
|
487
|
+
* (note) We do not need to look through push notifications as we've deleted triggers
|
|
515
488
|
*
|
|
516
489
|
* **Action** - When a user disables notifications for a given account in settings.
|
|
517
490
|
*
|
|
@@ -519,29 +492,13 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
519
492
|
* @returns A promise that resolves to void or an object containing a success message.
|
|
520
493
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
521
494
|
*/
|
|
522
|
-
async
|
|
495
|
+
async disableAccounts(accounts) {
|
|
523
496
|
try {
|
|
524
497
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
525
498
|
// Get and Validate BearerToken and User Storage Key
|
|
526
|
-
const { bearerToken
|
|
527
|
-
// Get & Validate User Storage
|
|
528
|
-
const userStorage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
529
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertUserStorage).call(this, userStorage);
|
|
530
|
-
// Get the UUIDs to delete
|
|
531
|
-
const UUIDs = accounts
|
|
532
|
-
.map((a) => Utils.getUUIDsForAccount(userStorage, a.toLowerCase()))
|
|
533
|
-
.flat();
|
|
534
|
-
if (UUIDs.length === 0) {
|
|
535
|
-
return userStorage;
|
|
536
|
-
}
|
|
499
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
537
500
|
// Delete these UUIDs (Mutates User Storage)
|
|
538
|
-
await OnChainNotifications.
|
|
539
|
-
// Update Push Notifications with new list of IDs
|
|
540
|
-
const remainingTriggerIds = Utils.getAllUUIDs(userStorage);
|
|
541
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").updatePushNotifications(remainingTriggerIds);
|
|
542
|
-
// Update User Storage
|
|
543
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
544
|
-
return userStorage;
|
|
501
|
+
await OnChainNotifications.updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: false })));
|
|
545
502
|
}
|
|
546
503
|
catch (err) {
|
|
547
504
|
loglevel_1.default.error('Failed to delete OnChain triggers', err);
|
|
@@ -566,45 +523,11 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
566
523
|
* @returns A promise that resolves to the updated user storage.
|
|
567
524
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
568
525
|
*/
|
|
569
|
-
async
|
|
526
|
+
async enableAccounts(accounts) {
|
|
570
527
|
try {
|
|
571
528
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
// Get & Validate User Storage
|
|
575
|
-
const userStorage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
576
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertUserStorage).call(this, userStorage);
|
|
577
|
-
// Add any missing triggers
|
|
578
|
-
accounts.forEach((a) => Utils.upsertAddressTriggers(a, userStorage));
|
|
579
|
-
const newTriggers = Utils.traverseUserStorageTriggers(userStorage, {
|
|
580
|
-
mapTrigger: (t) => {
|
|
581
|
-
if (!t.enabled) {
|
|
582
|
-
return t;
|
|
583
|
-
}
|
|
584
|
-
return undefined;
|
|
585
|
-
},
|
|
586
|
-
});
|
|
587
|
-
// Create any missing triggers.
|
|
588
|
-
if (newTriggers.length > 0) {
|
|
589
|
-
// Write te updated userStorage (where triggers are disabled)
|
|
590
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
591
|
-
// Create the triggers
|
|
592
|
-
const triggers = Utils.traverseUserStorageTriggers(userStorage, {
|
|
593
|
-
mapTrigger: (t) => {
|
|
594
|
-
if (accounts.some((a) => a.toLowerCase() === t.address.toLowerCase())) {
|
|
595
|
-
return t;
|
|
596
|
-
}
|
|
597
|
-
return undefined;
|
|
598
|
-
},
|
|
599
|
-
});
|
|
600
|
-
await OnChainNotifications.createOnChainTriggers(userStorage, storageKey, bearerToken, triggers);
|
|
601
|
-
}
|
|
602
|
-
// Update Push Notifications Triggers
|
|
603
|
-
const UUIDs = Utils.getAllUUIDs(userStorage);
|
|
604
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").updatePushNotifications(UUIDs);
|
|
605
|
-
// Update the userStorage (where triggers are enabled)
|
|
606
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
607
|
-
return userStorage;
|
|
529
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
530
|
+
await OnChainNotifications.updateOnChainNotifications(bearerToken, accounts.map((address) => ({ address, enabled: true })));
|
|
608
531
|
}
|
|
609
532
|
catch (err) {
|
|
610
533
|
loglevel_1.default.error('Failed to update OnChain triggers', err);
|
|
@@ -631,37 +554,33 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
631
554
|
// Not used by Snaps
|
|
632
555
|
const isGlobalNotifsEnabled = this.state.isNotificationServicesEnabled;
|
|
633
556
|
// Raw Feature Notifications
|
|
634
|
-
const
|
|
557
|
+
const rawAnnouncements = isGlobalNotifsEnabled && this.state.isFeatureAnnouncementsEnabled
|
|
635
558
|
? await FeatureNotifications.getFeatureAnnouncementNotifications(__classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f"), previewToken).catch(() => [])
|
|
636
559
|
: [];
|
|
637
560
|
// Raw On Chain Notifications
|
|
638
561
|
const rawOnChainNotifications = [];
|
|
639
562
|
if (isGlobalNotifsEnabled) {
|
|
640
|
-
|
|
641
|
-
.
|
|
642
|
-
|
|
643
|
-
.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const notifications = await OnChainNotifications.getOnChainNotifications(
|
|
563
|
+
try {
|
|
564
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
565
|
+
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
566
|
+
const addressesWithNotifications = (await OnChainNotifications.getOnChainNotificationsConfigCached(bearerToken, accounts))
|
|
567
|
+
.filter((a) => Boolean(a.enabled))
|
|
568
|
+
.map((a) => a.address);
|
|
569
|
+
const notifications = await OnChainNotifications.getOnChainNotifications(bearerToken, addressesWithNotifications).catch(() => []);
|
|
647
570
|
rawOnChainNotifications.push(...notifications);
|
|
648
571
|
}
|
|
572
|
+
catch {
|
|
573
|
+
// Do nothing
|
|
574
|
+
}
|
|
649
575
|
}
|
|
650
576
|
// Snap Notifications (original)
|
|
651
577
|
// We do not want to remove them
|
|
652
578
|
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === notification_schema_1.TRIGGER_TYPES.SNAP);
|
|
653
|
-
// Process Notifications
|
|
654
579
|
const readIds = this.state.metamaskNotificationsReadList;
|
|
655
|
-
const isNotUndefined = (t) => Boolean(t);
|
|
656
|
-
const processAndFilter = (ns) => ns
|
|
657
|
-
.map((n) => (0, process_notifications_1.safeProcessNotification)(n, readIds))
|
|
658
|
-
.filter(isNotUndefined);
|
|
659
|
-
const featureAnnouncementNotifications = processAndFilter(rawFeatureAnnouncementNotifications);
|
|
660
|
-
const onChainNotifications = processAndFilter(rawOnChainNotifications);
|
|
661
580
|
// Combine Notifications
|
|
662
581
|
const metamaskNotifications = [
|
|
663
|
-
...
|
|
664
|
-
...
|
|
582
|
+
...(0, process_notifications_1.processAndFilterNotifications)(rawAnnouncements, readIds),
|
|
583
|
+
...(0, process_notifications_1.processAndFilterNotifications)(rawOnChainNotifications, readIds),
|
|
665
584
|
...snapNotifications,
|
|
666
585
|
];
|
|
667
586
|
// Sort Notifications
|
|
@@ -829,7 +748,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
829
748
|
}
|
|
830
749
|
}
|
|
831
750
|
}
|
|
832
|
-
_NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(),
|
|
751
|
+
_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() {
|
|
833
752
|
this.messagingSystem.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
|
|
834
753
|
this.messagingSystem.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
|
|
835
754
|
this.messagingSystem.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
|
|
@@ -853,42 +772,13 @@ _NotificationServicesController_keyringController = new WeakMap(), _Notification
|
|
|
853
772
|
if (!isSignedIn) {
|
|
854
773
|
await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").signIn();
|
|
855
774
|
}
|
|
856
|
-
},
|
|
775
|
+
}, _NotificationServicesController_getBearerToken = async function _NotificationServicesController_getBearerToken() {
|
|
857
776
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertAuthEnabled).call(this);
|
|
858
777
|
const bearerToken = await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").getBearerToken();
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
throw new Error('Missing BearerToken or storage key');
|
|
862
|
-
}
|
|
863
|
-
return { bearerToken, storageKey };
|
|
864
|
-
}, _NotificationServicesController_assertUserStorage = function _NotificationServicesController_assertUserStorage(storage) {
|
|
865
|
-
if (!storage) {
|
|
866
|
-
throw new Error('User Storage does not exist');
|
|
867
|
-
}
|
|
868
|
-
}, _NotificationServicesController_getUserStorage =
|
|
869
|
-
/**
|
|
870
|
-
* Retrieves and parses the user storage from the storage key.
|
|
871
|
-
*
|
|
872
|
-
* This method attempts to retrieve the user storage using the specified storage key,
|
|
873
|
-
* then parses the JSON string to an object. If the storage is not found or cannot be parsed,
|
|
874
|
-
* it throws an error.
|
|
875
|
-
*
|
|
876
|
-
* @returns The parsed user storage object or null
|
|
877
|
-
*/
|
|
878
|
-
async function _NotificationServicesController_getUserStorage() {
|
|
879
|
-
const userStorageString = await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").getNotificationStorage();
|
|
880
|
-
if (!userStorageString) {
|
|
881
|
-
return null;
|
|
882
|
-
}
|
|
883
|
-
try {
|
|
884
|
-
const userStorage = JSON.parse(userStorageString);
|
|
885
|
-
Utils.cleanUserStorage(userStorage);
|
|
886
|
-
return userStorage;
|
|
887
|
-
}
|
|
888
|
-
catch {
|
|
889
|
-
loglevel_1.default.error('Unable to parse User Storage');
|
|
890
|
-
return null;
|
|
778
|
+
if (!bearerToken) {
|
|
779
|
+
throw new Error('Missing BearerToken');
|
|
891
780
|
}
|
|
781
|
+
return { bearerToken };
|
|
892
782
|
}, _NotificationServicesController_setIsUpdatingMetamaskNotifications = function _NotificationServicesController_setIsUpdatingMetamaskNotifications(isUpdatingMetamaskNotifications) {
|
|
893
783
|
this.update((state) => {
|
|
894
784
|
state.isUpdatingMetamaskNotifications = isUpdatingMetamaskNotifications;
|