@metamask/notification-services-controller 0.21.0 → 2.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 +34 -3
- package/README.md +35 -1
- package/dist/NotificationServicesController/NotificationServicesController.cjs +75 -80
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +10 -34
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +10 -34
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +76 -81
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/index.cjs +2 -1
- package/dist/NotificationServicesController/index.cjs.map +1 -1
- package/dist/NotificationServicesController/index.d.cts +2 -1
- package/dist/NotificationServicesController/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/index.d.mts +2 -1
- package/dist/NotificationServicesController/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/index.mjs +2 -1
- package/dist/NotificationServicesController/index.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/index.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +1 -0
- package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.cjs +1 -1
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.mjs +1 -1
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.cjs +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.mjs +2 -1
- package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.cjs +28 -2
- package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.cts +11 -1
- package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.mts +11 -1
- package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.mjs +26 -1
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +99 -57
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +21 -22
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +21 -22
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +100 -58
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/index.cjs +1 -1
- package/dist/NotificationServicesPushController/index.cjs.map +1 -1
- package/dist/NotificationServicesPushController/index.d.cts +1 -1
- package/dist/NotificationServicesPushController/index.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/index.d.mts +1 -1
- package/dist/NotificationServicesPushController/index.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/index.mjs +1 -1
- package/dist/NotificationServicesPushController/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.cjs +2 -2
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.mjs +2 -2
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/services.cjs +21 -93
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +8 -29
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +8 -29
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +20 -94
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.cjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.cts +1 -0
- package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.mts +1 -0
- package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/{services/push/index.cjs → types/push-service-interface.cjs} +1 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.cjs.map +1 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts +30 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts +30 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs +2 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +1 -19
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +0 -7
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +0 -7
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +0 -17
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/dist/NotificationServicesPushController/web/index.cjs +8 -0
- package/dist/NotificationServicesPushController/web/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/web/index.d.cts +2 -0
- package/dist/NotificationServicesPushController/web/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/web/index.d.mts +2 -0
- package/dist/NotificationServicesPushController/web/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/web/index.mjs +2 -0
- package/dist/NotificationServicesPushController/web/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/web/push-utils.cjs +170 -0
- package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -0
- package/dist/NotificationServicesPushController/web/push-utils.d.cts +37 -0
- package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/web/push-utils.d.mts +37 -0
- package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/web/push-utils.mjs +168 -0
- package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -0
- package/dist/shared/index.cjs +19 -0
- package/dist/shared/index.cjs.map +1 -0
- package/dist/shared/index.d.cts +3 -0
- package/dist/shared/index.d.cts.map +1 -0
- package/dist/shared/index.d.mts +3 -0
- package/dist/shared/index.d.mts.map +1 -0
- package/dist/shared/index.mjs +3 -0
- package/dist/shared/index.mjs.map +1 -0
- package/dist/shared/is-onchain-notification.cjs +22 -0
- package/dist/shared/is-onchain-notification.cjs.map +1 -0
- package/dist/shared/is-onchain-notification.d.cts +9 -0
- package/dist/shared/is-onchain-notification.d.cts.map +1 -0
- package/dist/shared/is-onchain-notification.d.mts +9 -0
- package/dist/shared/is-onchain-notification.d.mts.map +1 -0
- package/dist/shared/is-onchain-notification.mjs +18 -0
- package/dist/shared/is-onchain-notification.mjs.map +1 -0
- package/notification-services/mocks/package.json +2 -2
- package/package.json +24 -14
- package/push-services/mocks/package.json +2 -2
- package/push-services/web/package.json +9 -0
- package/dist/NotificationServicesController/__fixtures__/index.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockResponses.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockResponses.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockResponses.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockResponses.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockServices.cjs +0 -56
- package/dist/NotificationServicesController/__fixtures__/mockServices.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.cts +0 -12
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts +0 -12
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mockServices.mjs +0 -52
- package/dist/NotificationServicesController/__fixtures__/mockServices.mjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/test-utils.cjs +0 -31
- package/dist/NotificationServicesController/__fixtures__/test-utils.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.cts +0 -14
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts +0 -14
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/test-utils.mjs +0 -27
- package/dist/NotificationServicesController/__fixtures__/test-utils.mjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/index.cjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/index.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/index.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/index.mjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.cjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.mjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs +0 -31
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts +0 -9
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts +0 -9
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs +0 -30
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs.map +0 -1
- package/dist/NotificationServicesPushController/constants.cjs +0 -14
- package/dist/NotificationServicesPushController/constants.cjs.map +0 -1
- package/dist/NotificationServicesPushController/constants.d.cts +0 -11
- package/dist/NotificationServicesPushController/constants.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/constants.d.mts +0 -11
- package/dist/NotificationServicesPushController/constants.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/constants.mjs +0 -11
- package/dist/NotificationServicesPushController/constants.mjs.map +0 -1
- package/dist/NotificationServicesPushController/services/push/index.cjs.map +0 -1
- package/dist/NotificationServicesPushController/services/push/index.d.cts +0 -6
- package/dist/NotificationServicesPushController/services/push/index.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/services/push/index.d.mts +0 -6
- package/dist/NotificationServicesPushController/services/push/index.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/services/push/index.mjs +0 -2
- package/dist/NotificationServicesPushController/services/push/index.mjs.map +0 -1
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.cjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/index.mjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.cjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-feature-announcements.mjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.cjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-trigger.mjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-notification-user-storage.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.cjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-raw-notifications.mjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.cjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mock-snap-notification.mjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.cjs +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.d.cts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.d.mts +0 -0
- /package/dist/NotificationServicesController/{__fixtures__ → mocks}/mockResponses.mjs +0 -0
- /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.cjs +0 -0
- /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.d.cts +0 -0
- /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.d.mts +0 -0
- /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/index.mjs +0 -0
- /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.d.cts +0 -0
- /package/dist/NotificationServicesPushController/{__fixtures__ → mocks}/mockResponse.d.mts +0 -0
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _NotificationServicesController_instances,
|
|
12
|
+
var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_storage, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getValidStorageKeyAndBearerToken, _NotificationServicesController_assertUserStorage, _NotificationServicesController_getUserStorage, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
|
|
13
13
|
function $importDefault(module) {
|
|
14
14
|
if (module?.__esModule) {
|
|
15
15
|
return module.default;
|
|
@@ -17,7 +17,7 @@ function $importDefault(module) {
|
|
|
17
17
|
return module;
|
|
18
18
|
}
|
|
19
19
|
import { BaseController } from "@metamask/base-controller";
|
|
20
|
-
import { toChecksumHexAddress } from "@metamask/controller-utils";
|
|
20
|
+
import { isValidHexAddress, toChecksumHexAddress } from "@metamask/controller-utils";
|
|
21
21
|
import { assert } from "@metamask/utils";
|
|
22
22
|
import $log from "loglevel";
|
|
23
23
|
const log = $importDefault($log);
|
|
@@ -108,26 +108,20 @@ class NotificationServicesController extends BaseController {
|
|
|
108
108
|
state: { ...defaultState, ...state },
|
|
109
109
|
});
|
|
110
110
|
_NotificationServicesController_instances.add(this);
|
|
111
|
-
// Temporary boolean as push notifications are not yet enabled on mobile
|
|
112
|
-
_NotificationServicesController_isPushIntegrated.set(this, true);
|
|
113
|
-
// Flag to check is notifications have been setup when the browser/extension is initialized.
|
|
114
|
-
// We want to re-initialize push notifications when the browser/extension is refreshed
|
|
115
|
-
// To ensure we subscribe to the most up-to-date notifications
|
|
116
|
-
_NotificationServicesController_isPushNotificationsSetup.set(this, false);
|
|
117
|
-
_NotificationServicesController_isUnlocked.set(this, false);
|
|
118
111
|
_NotificationServicesController_keyringController.set(this, {
|
|
112
|
+
isUnlocked: false,
|
|
119
113
|
setupLockedStateSubscriptions: (onUnlock) => {
|
|
120
114
|
const { isUnlocked } = this.messagingSystem.call('KeyringController:getState');
|
|
121
|
-
|
|
115
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = isUnlocked;
|
|
122
116
|
this.messagingSystem.subscribe('KeyringController:unlock', () => {
|
|
123
|
-
|
|
117
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = true;
|
|
124
118
|
// messaging system cannot await promises
|
|
125
119
|
// we don't need to wait for a result on this.
|
|
126
120
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
127
121
|
onUnlock();
|
|
128
122
|
});
|
|
129
123
|
this.messagingSystem.subscribe('KeyringController:lock', () => {
|
|
130
|
-
|
|
124
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = false;
|
|
131
125
|
});
|
|
132
126
|
},
|
|
133
127
|
});
|
|
@@ -154,13 +148,14 @@ class NotificationServicesController extends BaseController {
|
|
|
154
148
|
},
|
|
155
149
|
});
|
|
156
150
|
_NotificationServicesController_pushNotifications.set(this, {
|
|
151
|
+
// Flag to check is notifications have been setup when the browser/extension is initialized.
|
|
152
|
+
// We want to re-initialize push notifications when the browser/extension is refreshed
|
|
153
|
+
// To ensure we subscribe to the most up-to-date notifications
|
|
154
|
+
isSetup: false,
|
|
157
155
|
subscribeToPushNotifications: async () => {
|
|
158
156
|
await this.messagingSystem.call('NotificationServicesPushController:subscribeToPushNotifications');
|
|
159
157
|
},
|
|
160
158
|
enablePushNotifications: async (UUIDs) => {
|
|
161
|
-
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
159
|
try {
|
|
165
160
|
await this.messagingSystem.call('NotificationServicesPushController:enablePushNotifications', UUIDs);
|
|
166
161
|
}
|
|
@@ -168,21 +163,15 @@ class NotificationServicesController extends BaseController {
|
|
|
168
163
|
log.error('Silently failed to enable push notifications', e);
|
|
169
164
|
}
|
|
170
165
|
},
|
|
171
|
-
disablePushNotifications: async (
|
|
172
|
-
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
166
|
+
disablePushNotifications: async () => {
|
|
175
167
|
try {
|
|
176
|
-
await this.messagingSystem.call('NotificationServicesPushController:disablePushNotifications'
|
|
168
|
+
await this.messagingSystem.call('NotificationServicesPushController:disablePushNotifications');
|
|
177
169
|
}
|
|
178
170
|
catch (e) {
|
|
179
171
|
log.error('Silently failed to disable push notifications', e);
|
|
180
172
|
}
|
|
181
173
|
},
|
|
182
174
|
updatePushNotifications: async (UUIDs) => {
|
|
183
|
-
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
175
|
try {
|
|
187
176
|
await this.messagingSystem.call('NotificationServicesPushController:updateTriggerPushNotifications', UUIDs);
|
|
188
177
|
}
|
|
@@ -191,37 +180,33 @@ class NotificationServicesController extends BaseController {
|
|
|
191
180
|
}
|
|
192
181
|
},
|
|
193
182
|
subscribe: () => {
|
|
194
|
-
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
183
|
this.messagingSystem.subscribe('NotificationServicesPushController:onNewNotifications', (notification) => {
|
|
198
184
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
199
185
|
this.updateMetamaskNotificationsList(notification);
|
|
200
186
|
});
|
|
201
187
|
},
|
|
202
188
|
initializePushNotifications: async () => {
|
|
203
|
-
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
189
|
if (!this.state.isNotificationServicesEnabled) {
|
|
207
190
|
return;
|
|
208
191
|
}
|
|
209
|
-
if (__classPrivateFieldGet(this,
|
|
192
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").isSetup) {
|
|
210
193
|
return;
|
|
211
194
|
}
|
|
212
195
|
// If wallet is unlocked, we can create a fresh push subscription
|
|
213
196
|
// Otherwise we can subscribe to original subscription
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return;
|
|
197
|
+
try {
|
|
198
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked) {
|
|
199
|
+
throw new Error('Keyring is locked');
|
|
218
200
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
__classPrivateFieldSet(this, _NotificationServicesController_isPushNotificationsSetup, true, "f");
|
|
201
|
+
await this.enablePushNotifications();
|
|
202
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").isSetup = true;
|
|
222
203
|
}
|
|
223
|
-
|
|
224
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
204
|
+
catch {
|
|
205
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
206
|
+
.subscribeToPushNotifications()
|
|
207
|
+
.catch(() => {
|
|
208
|
+
// do nothing
|
|
209
|
+
});
|
|
225
210
|
}
|
|
226
211
|
},
|
|
227
212
|
});
|
|
@@ -236,7 +221,9 @@ class NotificationServicesController extends BaseController {
|
|
|
236
221
|
listAccounts: async () => {
|
|
237
222
|
// Get previous and current account sets
|
|
238
223
|
const nonChecksumAccounts = await this.messagingSystem.call('KeyringController:getAccounts');
|
|
239
|
-
const accounts = nonChecksumAccounts
|
|
224
|
+
const accounts = nonChecksumAccounts
|
|
225
|
+
.map((a) => toChecksumHexAddress(a))
|
|
226
|
+
.filter((a) => isValidHexAddress(a));
|
|
240
227
|
const currentAccountsSet = new Set(accounts);
|
|
241
228
|
const prevAccountsSet = new Set(this.state.subscriptionAccountsSeen);
|
|
242
229
|
// Invalid value you cannot have zero accounts
|
|
@@ -267,7 +254,8 @@ class NotificationServicesController extends BaseController {
|
|
|
267
254
|
* @returns result from list accounts
|
|
268
255
|
*/
|
|
269
256
|
initialize: async () => {
|
|
270
|
-
if (__classPrivateFieldGet(this,
|
|
257
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked &&
|
|
258
|
+
!__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup) {
|
|
271
259
|
await __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
272
260
|
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup = true;
|
|
273
261
|
}
|
|
@@ -295,7 +283,6 @@ class NotificationServicesController extends BaseController {
|
|
|
295
283
|
},
|
|
296
284
|
});
|
|
297
285
|
_NotificationServicesController_featureAnnouncementEnv.set(this, void 0);
|
|
298
|
-
__classPrivateFieldSet(this, _NotificationServicesController_isPushIntegrated, env.isPushIntegrated ?? true, "f");
|
|
299
286
|
__classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
|
|
300
287
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerMessageHandlers).call(this);
|
|
301
288
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
|
|
@@ -311,15 +298,22 @@ class NotificationServicesController extends BaseController {
|
|
|
311
298
|
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").subscribe();
|
|
312
299
|
}
|
|
313
300
|
/**
|
|
314
|
-
*
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
301
|
+
* Public method to expose enabling push notifications
|
|
302
|
+
*/
|
|
303
|
+
async enablePushNotifications() {
|
|
304
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
|
|
305
|
+
const storage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
306
|
+
if (!storage) {
|
|
307
|
+
throw new Error('Unable to get triggers');
|
|
308
|
+
}
|
|
309
|
+
const uuids = Utils.getAllUUIDs(storage);
|
|
310
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(uuids);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Public method to expose disabling push notifications
|
|
320
314
|
*/
|
|
321
|
-
|
|
322
|
-
|
|
315
|
+
async disablePushNotifications() {
|
|
316
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications();
|
|
323
317
|
}
|
|
324
318
|
async checkAccountsPresence(accounts) {
|
|
325
319
|
try {
|
|
@@ -391,9 +385,12 @@ class NotificationServicesController extends BaseController {
|
|
|
391
385
|
// Create the triggers
|
|
392
386
|
const triggers = Utils.traverseUserStorageTriggers(userStorage);
|
|
393
387
|
await OnChainNotifications.createOnChainTriggers(userStorage, storageKey, bearerToken, triggers);
|
|
394
|
-
// Create push notifications triggers
|
|
388
|
+
// Create push notifications triggers in background
|
|
395
389
|
const allUUIDS = Utils.getAllUUIDs(userStorage);
|
|
396
|
-
|
|
390
|
+
// We do not want to wait for this request as it may take a while (e.g. for Firebase to setup)
|
|
391
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(allUUIDS).catch(() => {
|
|
392
|
+
// Do Nothing
|
|
393
|
+
});
|
|
397
394
|
// Write the new userStorage (triggers are now "enabled")
|
|
398
395
|
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
399
396
|
// Update the state of the controller
|
|
@@ -425,10 +422,7 @@ class NotificationServicesController extends BaseController {
|
|
|
425
422
|
async enableMetamaskNotifications() {
|
|
426
423
|
try {
|
|
427
424
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
428
|
-
|
|
429
|
-
if (!isSignedIn) {
|
|
430
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").signIn();
|
|
431
|
-
}
|
|
425
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
|
|
432
426
|
await this.createOnChainTriggers();
|
|
433
427
|
}
|
|
434
428
|
catch (e) {
|
|
@@ -448,30 +442,25 @@ class NotificationServicesController extends BaseController {
|
|
|
448
442
|
* @throws {Error} If the user is not authenticated or if there is an error during the process.
|
|
449
443
|
*/
|
|
450
444
|
async disableNotificationServices() {
|
|
445
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
446
|
+
// Attempt Disable Push Notifications
|
|
451
447
|
try {
|
|
452
|
-
__classPrivateFieldGet(this,
|
|
453
|
-
// Disable Push Notifications
|
|
454
|
-
const userStorage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
455
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertUserStorage).call(this, userStorage);
|
|
456
|
-
const UUIDs = Utils.getAllUUIDs(userStorage);
|
|
457
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications(UUIDs);
|
|
458
|
-
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === TRIGGER_TYPES.SNAP);
|
|
459
|
-
// Clear Notification States (toggles and list)
|
|
460
|
-
this.update((state) => {
|
|
461
|
-
state.isNotificationServicesEnabled = false;
|
|
462
|
-
state.isFeatureAnnouncementsEnabled = false;
|
|
463
|
-
// reassigning the notifications list with just snaps
|
|
464
|
-
// since the disable shouldn't affect snaps notifications
|
|
465
|
-
state.metamaskNotificationsList = snapNotifications;
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
catch (e) {
|
|
469
|
-
log.error('Unable to disable notifications', e);
|
|
470
|
-
throw new Error('Unable to disable notifications');
|
|
448
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications();
|
|
471
449
|
}
|
|
472
|
-
|
|
473
|
-
|
|
450
|
+
catch {
|
|
451
|
+
// Do nothing
|
|
474
452
|
}
|
|
453
|
+
// Update State: remove non-permitted notifications & disable flags
|
|
454
|
+
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === TRIGGER_TYPES.SNAP);
|
|
455
|
+
this.update((state) => {
|
|
456
|
+
state.isNotificationServicesEnabled = false;
|
|
457
|
+
state.isFeatureAnnouncementsEnabled = false;
|
|
458
|
+
// reassigning the notifications list with just snaps
|
|
459
|
+
// since the disable shouldn't affect snaps notifications
|
|
460
|
+
state.metamaskNotificationsList = snapNotifications;
|
|
461
|
+
});
|
|
462
|
+
// Finish Updating State
|
|
463
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
475
464
|
}
|
|
476
465
|
/**
|
|
477
466
|
* Deletes on-chain triggers associated with a specific account.
|
|
@@ -504,8 +493,9 @@ class NotificationServicesController extends BaseController {
|
|
|
504
493
|
}
|
|
505
494
|
// Delete these UUIDs (Mutates User Storage)
|
|
506
495
|
await OnChainNotifications.deleteOnChainTriggers(userStorage, storageKey, bearerToken, UUIDs);
|
|
507
|
-
//
|
|
508
|
-
|
|
496
|
+
// Update Push Notifications with new list of IDs
|
|
497
|
+
const remainingTriggerIds = Utils.getAllUUIDs(userStorage);
|
|
498
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").updatePushNotifications(remainingTriggerIds);
|
|
509
499
|
// Update User Storage
|
|
510
500
|
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
511
501
|
return userStorage;
|
|
@@ -796,10 +786,9 @@ class NotificationServicesController extends BaseController {
|
|
|
796
786
|
}
|
|
797
787
|
}
|
|
798
788
|
}
|
|
799
|
-
|
|
789
|
+
_NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(), _NotificationServicesController_storage = new WeakMap(), _NotificationServicesController_pushNotifications = new WeakMap(), _NotificationServicesController_accounts = new WeakMap(), _NotificationServicesController_featureAnnouncementEnv = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_registerMessageHandlers = function _NotificationServicesController_registerMessageHandlers() {
|
|
800
790
|
this.messagingSystem.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
|
|
801
791
|
this.messagingSystem.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
|
|
802
|
-
this.messagingSystem.registerActionHandler(`${controllerName}:selectIsNotificationServicesEnabled`, this.selectIsNotificationServicesEnabled.bind(this));
|
|
803
792
|
this.messagingSystem.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
|
|
804
793
|
this.messagingSystem.registerActionHandler(`${controllerName}:deleteNotificationsById`, this.deleteNotificationsById.bind(this));
|
|
805
794
|
}, _NotificationServicesController_clearLoadingStates = function _NotificationServicesController_clearLoadingStates() {
|
|
@@ -816,6 +805,11 @@ _NotificationServicesController_isPushIntegrated = new WeakMap(), _NotificationS
|
|
|
816
805
|
});
|
|
817
806
|
throw new Error('User is not signed in.');
|
|
818
807
|
}
|
|
808
|
+
}, _NotificationServicesController_enableAuth = async function _NotificationServicesController_enableAuth() {
|
|
809
|
+
const isSignedIn = __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").isSignedIn();
|
|
810
|
+
if (!isSignedIn) {
|
|
811
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").signIn();
|
|
812
|
+
}
|
|
819
813
|
}, _NotificationServicesController_getValidStorageKeyAndBearerToken = async function _NotificationServicesController_getValidStorageKeyAndBearerToken() {
|
|
820
814
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertAuthEnabled).call(this);
|
|
821
815
|
const bearerToken = await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").getBearerToken();
|
|
@@ -845,6 +839,7 @@ async function _NotificationServicesController_getUserStorage() {
|
|
|
845
839
|
}
|
|
846
840
|
try {
|
|
847
841
|
const userStorage = JSON.parse(userStorageString);
|
|
842
|
+
Utils.cleanUserStorage(userStorage);
|
|
848
843
|
return userStorage;
|
|
849
844
|
}
|
|
850
845
|
catch {
|