@metamask-previews/notification-services-controller 0.21.0-preview-5575cd05 → 0.21.0-preview-a1eb992b
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/dist/NotificationServicesController/NotificationServicesController.cjs +74 -62
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +34 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +34 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +74 -62
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/index.cjs +0 -1
- 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/NotificationServicesPushController/NotificationServicesPushController.cjs +56 -56
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +24 -18
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +24 -18
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +57 -57
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs +13 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs +12 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs.map +1 -1
- package/dist/NotificationServicesPushController/constants.cjs +14 -0
- package/dist/NotificationServicesPushController/constants.cjs.map +1 -0
- package/dist/NotificationServicesPushController/constants.d.cts +11 -0
- package/dist/NotificationServicesPushController/constants.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/constants.d.mts +11 -0
- package/dist/NotificationServicesPushController/constants.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/constants.mjs +11 -0
- package/dist/NotificationServicesPushController/constants.mjs.map +1 -0
- package/dist/NotificationServicesPushController/{types/push-service-interface.cjs → services/push/index.cjs} +1 -1
- package/dist/NotificationServicesPushController/services/push/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.d.cts +6 -0
- package/dist/NotificationServicesPushController/services/push/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.d.mts +6 -0
- package/dist/NotificationServicesPushController/services/push/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs +2 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/services.cjs +93 -15
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +27 -4
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +27 -4
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +94 -14
- 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 +0 -1
- package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.mts +0 -1
- package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +19 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +7 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +7 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +17 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/package.json +1 -11
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.cjs +0 -14
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.cjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.cts +0 -3
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.mts +0 -3
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.mjs +0 -10
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.mjs.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.cjs.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts +0 -30
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts +0 -30
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs +0 -2
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs.map +0 -1
- package/dist/NotificationServicesPushController/web/index.cjs +0 -8
- package/dist/NotificationServicesPushController/web/index.cjs.map +0 -1
- package/dist/NotificationServicesPushController/web/index.d.cts +0 -2
- package/dist/NotificationServicesPushController/web/index.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/web/index.d.mts +0 -2
- package/dist/NotificationServicesPushController/web/index.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/web/index.mjs +0 -2
- package/dist/NotificationServicesPushController/web/index.mjs.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.cjs +0 -170
- package/dist/NotificationServicesPushController/web/push-utils.cjs.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.cts +0 -37
- package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.mts +0 -37
- package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.mjs +0 -168
- package/dist/NotificationServicesPushController/web/push-utils.mjs.map +0 -1
- package/dist/shared/index.cjs +0 -19
- package/dist/shared/index.cjs.map +0 -1
- package/dist/shared/index.d.cts +0 -3
- package/dist/shared/index.d.cts.map +0 -1
- package/dist/shared/index.d.mts +0 -3
- package/dist/shared/index.d.mts.map +0 -1
- package/dist/shared/index.mjs +0 -3
- package/dist/shared/index.mjs.map +0 -1
- package/dist/shared/is-onchain-notification.cjs +0 -22
- package/dist/shared/is-onchain-notification.cjs.map +0 -1
- package/dist/shared/is-onchain-notification.d.cts +0 -9
- package/dist/shared/is-onchain-notification.d.cts.map +0 -1
- package/dist/shared/is-onchain-notification.d.mts +0 -9
- package/dist/shared/is-onchain-notification.d.mts.map +0 -1
- package/dist/shared/is-onchain-notification.mjs +0 -18
- package/dist/shared/is-onchain-notification.mjs.map +0 -1
- package/push-services/web/package.json +0 -150
|
@@ -5,7 +5,26 @@ import type { AuthenticationController, UserStorageController } from "@metamask/
|
|
|
5
5
|
import { TRIGGER_TYPES } from "./constants/notification-schema.cjs";
|
|
6
6
|
import type { INotification, MarkAsReadNotificationsParam } from "./types/notification/notification.cjs";
|
|
7
7
|
import type { UserStorage } from "./types/user-storage/user-storage.cjs";
|
|
8
|
-
|
|
8
|
+
export type NotificationServicesPushControllerEnablePushNotifications = {
|
|
9
|
+
type: `NotificationServicesPushController:enablePushNotifications`;
|
|
10
|
+
handler: (UUIDs: string[]) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export type NotificationServicesPushControllerDisablePushNotifications = {
|
|
13
|
+
type: `NotificationServicesPushController:disablePushNotifications`;
|
|
14
|
+
handler: (UUIDs: string[]) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export type NotificationServicesPushControllerUpdateTriggerPushNotifications = {
|
|
17
|
+
type: `NotificationServicesPushController:updateTriggerPushNotifications`;
|
|
18
|
+
handler: (UUIDs: string[]) => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export type NotificationServicesPushControllerSubscribeToNotifications = {
|
|
21
|
+
type: `NotificationServicesPushController:subscribeToPushNotifications`;
|
|
22
|
+
handler: () => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export type NotificationServicesPushControllerOnNewNotification = {
|
|
25
|
+
type: `NotificationServicesPushController:onNewNotifications`;
|
|
26
|
+
payload: [INotification];
|
|
27
|
+
};
|
|
9
28
|
declare const controllerName = "NotificationServicesController";
|
|
10
29
|
/**
|
|
11
30
|
* State shape for NotificationServicesController
|
|
@@ -65,6 +84,10 @@ export type NotificationServicesControllerDisableNotificationServices = {
|
|
|
65
84
|
type: `${typeof controllerName}:disableNotificationServices`;
|
|
66
85
|
handler: NotificationServicesController['disableNotificationServices'];
|
|
67
86
|
};
|
|
87
|
+
export type NotificationServicesControllerSelectIsNotificationServicesEnabled = {
|
|
88
|
+
type: `${typeof controllerName}:selectIsNotificationServicesEnabled`;
|
|
89
|
+
handler: NotificationServicesController['selectIsNotificationServicesEnabled'];
|
|
90
|
+
};
|
|
68
91
|
export type NotificationServicesControllerGetNotificationsByType = {
|
|
69
92
|
type: `${typeof controllerName}:getNotificationsByType`;
|
|
70
93
|
handler: NotificationServicesController['getNotificationsByType'];
|
|
@@ -73,8 +96,8 @@ export type NotificationServicesControllerDeleteNotificationsById = {
|
|
|
73
96
|
type: `${typeof controllerName}:deleteNotificationsById`;
|
|
74
97
|
handler: NotificationServicesController['deleteNotificationsById'];
|
|
75
98
|
};
|
|
76
|
-
export type Actions = NotificationServicesControllerGetStateAction | NotificationServicesControllerUpdateMetamaskNotificationsList | NotificationServicesControllerDisableNotificationServices | NotificationServicesControllerGetNotificationsByType | NotificationServicesControllerDeleteNotificationsById;
|
|
77
|
-
export type AllowedActions = KeyringControllerGetAccountsAction | KeyringControllerGetStateAction | AuthenticationController.AuthenticationControllerGetBearerToken | AuthenticationController.AuthenticationControllerIsSignedIn | AuthenticationController.AuthenticationControllerPerformSignIn | UserStorageController.UserStorageControllerGetStorageKey | UserStorageController.UserStorageControllerPerformGetStorage | UserStorageController.UserStorageControllerPerformSetStorage |
|
|
99
|
+
export type Actions = NotificationServicesControllerGetStateAction | NotificationServicesControllerUpdateMetamaskNotificationsList | NotificationServicesControllerDisableNotificationServices | NotificationServicesControllerSelectIsNotificationServicesEnabled | NotificationServicesControllerGetNotificationsByType | NotificationServicesControllerDeleteNotificationsById;
|
|
100
|
+
export type AllowedActions = KeyringControllerGetAccountsAction | KeyringControllerGetStateAction | AuthenticationController.AuthenticationControllerGetBearerToken | AuthenticationController.AuthenticationControllerIsSignedIn | AuthenticationController.AuthenticationControllerPerformSignIn | UserStorageController.UserStorageControllerGetStorageKey | UserStorageController.UserStorageControllerPerformGetStorage | UserStorageController.UserStorageControllerPerformSetStorage | NotificationServicesPushControllerEnablePushNotifications | NotificationServicesPushControllerDisablePushNotifications | NotificationServicesPushControllerUpdateTriggerPushNotifications | NotificationServicesPushControllerSubscribeToNotifications;
|
|
78
101
|
export type NotificationServicesControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, NotificationServicesControllerState>;
|
|
79
102
|
export type NotificationListUpdatedEvent = {
|
|
80
103
|
type: `${typeof controllerName}:notificationsListUpdated`;
|
|
@@ -85,7 +108,7 @@ export type MarkNotificationsAsReadEvent = {
|
|
|
85
108
|
payload: [INotification[]];
|
|
86
109
|
};
|
|
87
110
|
export type Events = NotificationServicesControllerStateChangeEvent | NotificationListUpdatedEvent | MarkNotificationsAsReadEvent;
|
|
88
|
-
export type AllowedEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent |
|
|
111
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | NotificationServicesPushControllerOnNewNotification;
|
|
89
112
|
export type NotificationServicesControllerMessenger = RestrictedMessenger<typeof controllerName, Actions | AllowedActions, Events | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
90
113
|
type FeatureAnnouncementEnv = {
|
|
91
114
|
spaceId: string;
|
|
@@ -116,13 +139,14 @@ export default class NotificationServicesController extends BaseController<typeo
|
|
|
116
139
|
};
|
|
117
140
|
});
|
|
118
141
|
/**
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
142
|
+
* Retrieves the current enabled state of MetaMask notifications.
|
|
143
|
+
*
|
|
144
|
+
* This method directly returns the boolean value of `isMetamaskNotificationsEnabled`
|
|
145
|
+
* from the controller's state, indicating whether MetaMask notifications are currently enabled.
|
|
146
|
+
*
|
|
147
|
+
* @returns The enabled state of MetaMask notifications.
|
|
124
148
|
*/
|
|
125
|
-
|
|
149
|
+
selectIsNotificationServicesEnabled(): boolean;
|
|
126
150
|
checkAccountsPresence(accounts: string[]): Promise<Record<string, boolean>>;
|
|
127
151
|
/**
|
|
128
152
|
* Sets the enabled state of feature announcements.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,KAAK,EACV,kCAAkC,EAClC,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,0CAA0C;AAK3C,OAAO,EAAE,aAAa,EAAE,4CAAwC;AAIhE,OAAO,KAAK,EACV,aAAa,EACb,4BAA4B,EAE7B,8CAA0C;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,8CAA0C;
|
|
1
|
+
{"version":3,"file":"NotificationServicesController.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,KAAK,EACV,kCAAkC,EAClC,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,0CAA0C;AAK3C,OAAO,EAAE,aAAa,EAAE,4CAAwC;AAIhE,OAAO,KAAK,EACV,aAAa,EACb,4BAA4B,EAE7B,8CAA0C;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,8CAA0C;AAKrE,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,4DAA4D,CAAC;IACnE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,6DAA6D,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mFxC,qBAAqB,CAChC,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAkBnC;;;;;;;;OAQG;IACU,8BAA8B,CACzC,2BAA2B,EAAE,OAAO;IAYtC;;;;;;;;;;OAUG;IACU,qBAAqB,CAAC,IAAI,CAAC,EAAE;QACxC,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC,WAAW,CAAC;IA6DxB;;;;;;;;;OASG;IACU,2BAA2B;IAkBxC;;;;;;;OAOG;IACU,2BAA2B;IA8BxC;;;;;;;;;;;;;OAaG;IACU,8BAA8B,CACzC,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,WAAW,CAAC;IA0CvB;;;;;;;;;;;;;;OAcG;IACU,8BAA8B,CACzC,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,WAAW,CAAC;IA8DvB;;;;;;;;;OASG;IACU,mCAAmC,CAC9C,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC;IAuF3B;;;;;;OAMG;IACI,sBAAsB,CAAC,IAAI,EAAE,aAAa;IAUjD;;;;;;;OAOG;IACU,sBAAsB,CAAC,EAAE,EAAE,MAAM;IA6B9C;;;;;;;OAOG;IACU,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE;IAWlD;;;;;OAKG;IACU,+BAA+B,CAC1C,aAAa,EAAE,4BAA4B,GAC1C,OAAO,CAAC,IAAI,CAAC;IA2GhB;;;;;;OAMG;IACU,+BAA+B,CAC1C,YAAY,EAAE,aAAa,GAC1B,OAAO,CAAC,IAAI,CAAC;CA6BjB"}
|
|
@@ -5,7 +5,26 @@ import type { AuthenticationController, UserStorageController } from "@metamask/
|
|
|
5
5
|
import { TRIGGER_TYPES } from "./constants/notification-schema.mjs";
|
|
6
6
|
import type { INotification, MarkAsReadNotificationsParam } from "./types/notification/notification.mjs";
|
|
7
7
|
import type { UserStorage } from "./types/user-storage/user-storage.mjs";
|
|
8
|
-
|
|
8
|
+
export type NotificationServicesPushControllerEnablePushNotifications = {
|
|
9
|
+
type: `NotificationServicesPushController:enablePushNotifications`;
|
|
10
|
+
handler: (UUIDs: string[]) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export type NotificationServicesPushControllerDisablePushNotifications = {
|
|
13
|
+
type: `NotificationServicesPushController:disablePushNotifications`;
|
|
14
|
+
handler: (UUIDs: string[]) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export type NotificationServicesPushControllerUpdateTriggerPushNotifications = {
|
|
17
|
+
type: `NotificationServicesPushController:updateTriggerPushNotifications`;
|
|
18
|
+
handler: (UUIDs: string[]) => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export type NotificationServicesPushControllerSubscribeToNotifications = {
|
|
21
|
+
type: `NotificationServicesPushController:subscribeToPushNotifications`;
|
|
22
|
+
handler: () => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export type NotificationServicesPushControllerOnNewNotification = {
|
|
25
|
+
type: `NotificationServicesPushController:onNewNotifications`;
|
|
26
|
+
payload: [INotification];
|
|
27
|
+
};
|
|
9
28
|
declare const controllerName = "NotificationServicesController";
|
|
10
29
|
/**
|
|
11
30
|
* State shape for NotificationServicesController
|
|
@@ -65,6 +84,10 @@ export type NotificationServicesControllerDisableNotificationServices = {
|
|
|
65
84
|
type: `${typeof controllerName}:disableNotificationServices`;
|
|
66
85
|
handler: NotificationServicesController['disableNotificationServices'];
|
|
67
86
|
};
|
|
87
|
+
export type NotificationServicesControllerSelectIsNotificationServicesEnabled = {
|
|
88
|
+
type: `${typeof controllerName}:selectIsNotificationServicesEnabled`;
|
|
89
|
+
handler: NotificationServicesController['selectIsNotificationServicesEnabled'];
|
|
90
|
+
};
|
|
68
91
|
export type NotificationServicesControllerGetNotificationsByType = {
|
|
69
92
|
type: `${typeof controllerName}:getNotificationsByType`;
|
|
70
93
|
handler: NotificationServicesController['getNotificationsByType'];
|
|
@@ -73,8 +96,8 @@ export type NotificationServicesControllerDeleteNotificationsById = {
|
|
|
73
96
|
type: `${typeof controllerName}:deleteNotificationsById`;
|
|
74
97
|
handler: NotificationServicesController['deleteNotificationsById'];
|
|
75
98
|
};
|
|
76
|
-
export type Actions = NotificationServicesControllerGetStateAction | NotificationServicesControllerUpdateMetamaskNotificationsList | NotificationServicesControllerDisableNotificationServices | NotificationServicesControllerGetNotificationsByType | NotificationServicesControllerDeleteNotificationsById;
|
|
77
|
-
export type AllowedActions = KeyringControllerGetAccountsAction | KeyringControllerGetStateAction | AuthenticationController.AuthenticationControllerGetBearerToken | AuthenticationController.AuthenticationControllerIsSignedIn | AuthenticationController.AuthenticationControllerPerformSignIn | UserStorageController.UserStorageControllerGetStorageKey | UserStorageController.UserStorageControllerPerformGetStorage | UserStorageController.UserStorageControllerPerformSetStorage |
|
|
99
|
+
export type Actions = NotificationServicesControllerGetStateAction | NotificationServicesControllerUpdateMetamaskNotificationsList | NotificationServicesControllerDisableNotificationServices | NotificationServicesControllerSelectIsNotificationServicesEnabled | NotificationServicesControllerGetNotificationsByType | NotificationServicesControllerDeleteNotificationsById;
|
|
100
|
+
export type AllowedActions = KeyringControllerGetAccountsAction | KeyringControllerGetStateAction | AuthenticationController.AuthenticationControllerGetBearerToken | AuthenticationController.AuthenticationControllerIsSignedIn | AuthenticationController.AuthenticationControllerPerformSignIn | UserStorageController.UserStorageControllerGetStorageKey | UserStorageController.UserStorageControllerPerformGetStorage | UserStorageController.UserStorageControllerPerformSetStorage | NotificationServicesPushControllerEnablePushNotifications | NotificationServicesPushControllerDisablePushNotifications | NotificationServicesPushControllerUpdateTriggerPushNotifications | NotificationServicesPushControllerSubscribeToNotifications;
|
|
78
101
|
export type NotificationServicesControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, NotificationServicesControllerState>;
|
|
79
102
|
export type NotificationListUpdatedEvent = {
|
|
80
103
|
type: `${typeof controllerName}:notificationsListUpdated`;
|
|
@@ -85,7 +108,7 @@ export type MarkNotificationsAsReadEvent = {
|
|
|
85
108
|
payload: [INotification[]];
|
|
86
109
|
};
|
|
87
110
|
export type Events = NotificationServicesControllerStateChangeEvent | NotificationListUpdatedEvent | MarkNotificationsAsReadEvent;
|
|
88
|
-
export type AllowedEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent |
|
|
111
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | NotificationServicesPushControllerOnNewNotification;
|
|
89
112
|
export type NotificationServicesControllerMessenger = RestrictedMessenger<typeof controllerName, Actions | AllowedActions, Events | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
90
113
|
type FeatureAnnouncementEnv = {
|
|
91
114
|
spaceId: string;
|
|
@@ -116,13 +139,14 @@ export default class NotificationServicesController extends BaseController<typeo
|
|
|
116
139
|
};
|
|
117
140
|
});
|
|
118
141
|
/**
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
142
|
+
* Retrieves the current enabled state of MetaMask notifications.
|
|
143
|
+
*
|
|
144
|
+
* This method directly returns the boolean value of `isMetamaskNotificationsEnabled`
|
|
145
|
+
* from the controller's state, indicating whether MetaMask notifications are currently enabled.
|
|
146
|
+
*
|
|
147
|
+
* @returns The enabled state of MetaMask notifications.
|
|
124
148
|
*/
|
|
125
|
-
|
|
149
|
+
selectIsNotificationServicesEnabled(): boolean;
|
|
126
150
|
checkAccountsPresence(accounts: string[]): Promise<Record<string, boolean>>;
|
|
127
151
|
/**
|
|
128
152
|
* Sets the enabled state of feature announcements.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,KAAK,EACV,kCAAkC,EAClC,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,0CAA0C;AAK3C,OAAO,EAAE,aAAa,EAAE,4CAAwC;AAIhE,OAAO,KAAK,EACV,aAAa,EACb,4BAA4B,EAE7B,8CAA0C;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,8CAA0C;
|
|
1
|
+
{"version":3,"file":"NotificationServicesController.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,KAAK,EACV,kCAAkC,EAClC,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,0CAA0C;AAK3C,OAAO,EAAE,aAAa,EAAE,4CAAwC;AAIhE,OAAO,KAAK,EACV,aAAa,EACb,4BAA4B,EAE7B,8CAA0C;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,8CAA0C;AAKrE,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,4DAA4D,CAAC;IACnE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,6DAA6D,CAAC;IACpE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,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;OAQG;IACU,8BAA8B,CACzC,2BAA2B,EAAE,OAAO;IAYtC;;;;;;;;;;OAUG;IACU,qBAAqB,CAAC,IAAI,CAAC,EAAE;QACxC,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC,WAAW,CAAC;IA6DxB;;;;;;;;;OASG;IACU,2BAA2B;IAkBxC;;;;;;;OAOG;IACU,2BAA2B;IA8BxC;;;;;;;;;;;;;OAaG;IACU,8BAA8B,CACzC,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,WAAW,CAAC;IA0CvB;;;;;;;;;;;;;;OAcG;IACU,8BAA8B,CACzC,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,WAAW,CAAC;IA8DvB;;;;;;;;;OASG;IACU,mCAAmC,CAC9C,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC;IAuF3B;;;;;;OAMG;IACI,sBAAsB,CAAC,IAAI,EAAE,aAAa;IAUjD;;;;;;;OAOG;IACU,sBAAsB,CAAC,EAAE,EAAE,MAAM;IA6B9C;;;;;;;OAOG;IACU,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE;IAWlD;;;;;OAKG;IACU,+BAA+B,CAC1C,aAAa,EAAE,4BAA4B,GAC1C,OAAO,CAAC,IAAI,CAAC;IA2GhB;;;;;;OAMG;IACU,+BAA+B,CAC1C,YAAY,EAAE,aAAa,GAC1B,OAAO,CAAC,IAAI,CAAC;CA6BjB"}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_storage, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_getValidStorageKeyAndBearerToken, _NotificationServicesController_assertUserStorage, _NotificationServicesController_getUserStorage, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
|
|
12
|
+
var _NotificationServicesController_instances, _NotificationServicesController_isPushIntegrated, _NotificationServicesController_isPushNotificationsSetup, _NotificationServicesController_isUnlocked, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_storage, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _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;
|
|
@@ -108,20 +108,26 @@ 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);
|
|
111
118
|
_NotificationServicesController_keyringController.set(this, {
|
|
112
|
-
isUnlocked: false,
|
|
113
119
|
setupLockedStateSubscriptions: (onUnlock) => {
|
|
114
120
|
const { isUnlocked } = this.messagingSystem.call('KeyringController:getState');
|
|
115
|
-
|
|
121
|
+
__classPrivateFieldSet(this, _NotificationServicesController_isUnlocked, isUnlocked, "f");
|
|
116
122
|
this.messagingSystem.subscribe('KeyringController:unlock', () => {
|
|
117
|
-
|
|
123
|
+
__classPrivateFieldSet(this, _NotificationServicesController_isUnlocked, true, "f");
|
|
118
124
|
// messaging system cannot await promises
|
|
119
125
|
// we don't need to wait for a result on this.
|
|
120
126
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
121
127
|
onUnlock();
|
|
122
128
|
});
|
|
123
129
|
this.messagingSystem.subscribe('KeyringController:lock', () => {
|
|
124
|
-
|
|
130
|
+
__classPrivateFieldSet(this, _NotificationServicesController_isUnlocked, false, "f");
|
|
125
131
|
});
|
|
126
132
|
},
|
|
127
133
|
});
|
|
@@ -148,14 +154,13 @@ class NotificationServicesController extends BaseController {
|
|
|
148
154
|
},
|
|
149
155
|
});
|
|
150
156
|
_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,
|
|
155
157
|
subscribeToPushNotifications: async () => {
|
|
156
158
|
await this.messagingSystem.call('NotificationServicesPushController:subscribeToPushNotifications');
|
|
157
159
|
},
|
|
158
160
|
enablePushNotifications: async (UUIDs) => {
|
|
161
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
159
164
|
try {
|
|
160
165
|
await this.messagingSystem.call('NotificationServicesPushController:enablePushNotifications', UUIDs);
|
|
161
166
|
}
|
|
@@ -163,15 +168,21 @@ class NotificationServicesController extends BaseController {
|
|
|
163
168
|
log.error('Silently failed to enable push notifications', e);
|
|
164
169
|
}
|
|
165
170
|
},
|
|
166
|
-
disablePushNotifications: async () => {
|
|
171
|
+
disablePushNotifications: async (UUIDs) => {
|
|
172
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
167
175
|
try {
|
|
168
|
-
await this.messagingSystem.call('NotificationServicesPushController:disablePushNotifications');
|
|
176
|
+
await this.messagingSystem.call('NotificationServicesPushController:disablePushNotifications', UUIDs);
|
|
169
177
|
}
|
|
170
178
|
catch (e) {
|
|
171
179
|
log.error('Silently failed to disable push notifications', e);
|
|
172
180
|
}
|
|
173
181
|
},
|
|
174
182
|
updatePushNotifications: async (UUIDs) => {
|
|
183
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
175
186
|
try {
|
|
176
187
|
await this.messagingSystem.call('NotificationServicesPushController:updateTriggerPushNotifications', UUIDs);
|
|
177
188
|
}
|
|
@@ -180,33 +191,37 @@ class NotificationServicesController extends BaseController {
|
|
|
180
191
|
}
|
|
181
192
|
},
|
|
182
193
|
subscribe: () => {
|
|
194
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
183
197
|
this.messagingSystem.subscribe('NotificationServicesPushController:onNewNotifications', (notification) => {
|
|
184
198
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
185
199
|
this.updateMetamaskNotificationsList(notification);
|
|
186
200
|
});
|
|
187
201
|
},
|
|
188
202
|
initializePushNotifications: async () => {
|
|
203
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
189
206
|
if (!this.state.isNotificationServicesEnabled) {
|
|
190
207
|
return;
|
|
191
208
|
}
|
|
192
|
-
if (__classPrivateFieldGet(this,
|
|
209
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_isPushNotificationsSetup, "f")) {
|
|
193
210
|
return;
|
|
194
211
|
}
|
|
195
212
|
// If wallet is unlocked, we can create a fresh push subscription
|
|
196
213
|
// Otherwise we can subscribe to original subscription
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
214
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_isUnlocked, "f")) {
|
|
215
|
+
const storage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
216
|
+
if (!storage) {
|
|
217
|
+
return;
|
|
200
218
|
}
|
|
201
|
-
|
|
202
|
-
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").
|
|
219
|
+
const uuids = Utils.getAllUUIDs(storage);
|
|
220
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(uuids);
|
|
221
|
+
__classPrivateFieldSet(this, _NotificationServicesController_isPushNotificationsSetup, true, "f");
|
|
203
222
|
}
|
|
204
|
-
|
|
205
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
206
|
-
.subscribeToPushNotifications()
|
|
207
|
-
.catch(() => {
|
|
208
|
-
// do nothing
|
|
209
|
-
});
|
|
223
|
+
else {
|
|
224
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").subscribeToPushNotifications();
|
|
210
225
|
}
|
|
211
226
|
},
|
|
212
227
|
});
|
|
@@ -254,8 +269,7 @@ class NotificationServicesController extends BaseController {
|
|
|
254
269
|
* @returns result from list accounts
|
|
255
270
|
*/
|
|
256
271
|
initialize: async () => {
|
|
257
|
-
if (__classPrivateFieldGet(this,
|
|
258
|
-
!__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup) {
|
|
272
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_isUnlocked, "f") && !__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup) {
|
|
259
273
|
await __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
260
274
|
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup = true;
|
|
261
275
|
}
|
|
@@ -266,9 +280,7 @@ class NotificationServicesController extends BaseController {
|
|
|
266
280
|
* And call effects to subscribe/unsubscribe to notifications.
|
|
267
281
|
*/
|
|
268
282
|
subscribe: () => {
|
|
269
|
-
this.messagingSystem.subscribe('KeyringController:stateChange',
|
|
270
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
271
|
-
async () => {
|
|
283
|
+
this.messagingSystem.subscribe('KeyringController:stateChange', async () => {
|
|
272
284
|
if (!this.state.isNotificationServicesEnabled) {
|
|
273
285
|
return;
|
|
274
286
|
}
|
|
@@ -285,6 +297,7 @@ class NotificationServicesController extends BaseController {
|
|
|
285
297
|
},
|
|
286
298
|
});
|
|
287
299
|
_NotificationServicesController_featureAnnouncementEnv.set(this, void 0);
|
|
300
|
+
__classPrivateFieldSet(this, _NotificationServicesController_isPushIntegrated, env.isPushIntegrated ?? true, "f");
|
|
288
301
|
__classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
|
|
289
302
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerMessageHandlers).call(this);
|
|
290
303
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
|
|
@@ -300,21 +313,15 @@ class NotificationServicesController extends BaseController {
|
|
|
300
313
|
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").subscribe();
|
|
301
314
|
}
|
|
302
315
|
/**
|
|
303
|
-
*
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
const uuids = Utils.getAllUUIDs(storage);
|
|
311
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(uuids);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Public method to expose disabling push notifications
|
|
316
|
+
* Retrieves the current enabled state of MetaMask notifications.
|
|
317
|
+
*
|
|
318
|
+
* This method directly returns the boolean value of `isMetamaskNotificationsEnabled`
|
|
319
|
+
* from the controller's state, indicating whether MetaMask notifications are currently enabled.
|
|
320
|
+
*
|
|
321
|
+
* @returns The enabled state of MetaMask notifications.
|
|
315
322
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
323
|
+
selectIsNotificationServicesEnabled() {
|
|
324
|
+
return this.state.isNotificationServicesEnabled;
|
|
318
325
|
}
|
|
319
326
|
async checkAccountsPresence(accounts) {
|
|
320
327
|
try {
|
|
@@ -443,25 +450,30 @@ class NotificationServicesController extends BaseController {
|
|
|
443
450
|
* @throws {Error} If the user is not authenticated or if there is an error during the process.
|
|
444
451
|
*/
|
|
445
452
|
async disableNotificationServices() {
|
|
446
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
447
|
-
// Attempt Disable Push Notifications
|
|
448
453
|
try {
|
|
449
|
-
|
|
454
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
455
|
+
// Disable Push Notifications
|
|
456
|
+
const userStorage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
457
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertUserStorage).call(this, userStorage);
|
|
458
|
+
const UUIDs = Utils.getAllUUIDs(userStorage);
|
|
459
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications(UUIDs);
|
|
460
|
+
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === TRIGGER_TYPES.SNAP);
|
|
461
|
+
// Clear Notification States (toggles and list)
|
|
462
|
+
this.update((state) => {
|
|
463
|
+
state.isNotificationServicesEnabled = false;
|
|
464
|
+
state.isFeatureAnnouncementsEnabled = false;
|
|
465
|
+
// reassigning the notifications list with just snaps
|
|
466
|
+
// since the disable shouldn't affect snaps notifications
|
|
467
|
+
state.metamaskNotificationsList = snapNotifications;
|
|
468
|
+
});
|
|
450
469
|
}
|
|
451
|
-
catch {
|
|
452
|
-
|
|
470
|
+
catch (e) {
|
|
471
|
+
log.error('Unable to disable notifications', e);
|
|
472
|
+
throw new Error('Unable to disable notifications');
|
|
473
|
+
}
|
|
474
|
+
finally {
|
|
475
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
453
476
|
}
|
|
454
|
-
// Update State: remove non-permitted notifications & disable flags
|
|
455
|
-
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === TRIGGER_TYPES.SNAP);
|
|
456
|
-
this.update((state) => {
|
|
457
|
-
state.isNotificationServicesEnabled = false;
|
|
458
|
-
state.isFeatureAnnouncementsEnabled = false;
|
|
459
|
-
// reassigning the notifications list with just snaps
|
|
460
|
-
// since the disable shouldn't affect snaps notifications
|
|
461
|
-
state.metamaskNotificationsList = snapNotifications;
|
|
462
|
-
});
|
|
463
|
-
// Finish Updating State
|
|
464
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
465
477
|
}
|
|
466
478
|
/**
|
|
467
479
|
* Deletes on-chain triggers associated with a specific account.
|
|
@@ -494,9 +506,8 @@ class NotificationServicesController extends BaseController {
|
|
|
494
506
|
}
|
|
495
507
|
// Delete these UUIDs (Mutates User Storage)
|
|
496
508
|
await OnChainNotifications.deleteOnChainTriggers(userStorage, storageKey, bearerToken, UUIDs);
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").updatePushNotifications(remainingTriggerIds);
|
|
509
|
+
// Delete these UUIDs from the push notifications
|
|
510
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications(UUIDs);
|
|
500
511
|
// Update User Storage
|
|
501
512
|
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").setNotificationStorage(JSON.stringify(userStorage));
|
|
502
513
|
return userStorage;
|
|
@@ -787,9 +798,10 @@ class NotificationServicesController extends BaseController {
|
|
|
787
798
|
}
|
|
788
799
|
}
|
|
789
800
|
}
|
|
790
|
-
_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() {
|
|
801
|
+
_NotificationServicesController_isPushIntegrated = new WeakMap(), _NotificationServicesController_isPushNotificationsSetup = new WeakMap(), _NotificationServicesController_isUnlocked = new WeakMap(), _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() {
|
|
791
802
|
this.messagingSystem.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
|
|
792
803
|
this.messagingSystem.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
|
|
804
|
+
this.messagingSystem.registerActionHandler(`${controllerName}:selectIsNotificationServicesEnabled`, this.selectIsNotificationServicesEnabled.bind(this));
|
|
793
805
|
this.messagingSystem.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
|
|
794
806
|
this.messagingSystem.registerActionHandler(`${controllerName}:deleteNotificationsById`, this.deleteNotificationsById.bind(this));
|
|
795
807
|
}, _NotificationServicesController_clearLoadingStates = function _NotificationServicesController_clearLoadingStates() {
|