@metamask-previews/notification-services-controller 0.18.0-preview-c96fc296 → 0.18.0-preview-9a5238f
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 +41 -54
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +4 -4
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +4 -4
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +41 -54
- 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 +40 -37
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +21 -19
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +21 -19
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +41 -38
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- 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/{web/push-helpers.cjs → services/push/push-web.cjs} +8 -37
- package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +1 -0
- package/dist/NotificationServicesPushController/services/push/push-web.d.cts +33 -0
- package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/push-web.d.mts +33 -0
- package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/{web/push-helpers.mjs → services/push/push-web.mjs} +7 -37
- package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/services.cjs +28 -3
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +15 -1
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +15 -1
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +26 -2
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.cjs +15 -0
- package/dist/NotificationServicesPushController/types/index.cjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.cts +1 -2
- package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.mts +1 -2
- package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.mjs +1 -1
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
- package/package.json +2 -12
- 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-helpers.cjs.map +0 -1
- package/dist/NotificationServicesPushController/web/push-helpers.d.cts +0 -37
- package/dist/NotificationServicesPushController/web/push-helpers.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-helpers.d.mts +0 -37
- package/dist/NotificationServicesPushController/web/push-helpers.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-helpers.mjs.map +0 -1
- package/push-services/web/package.json +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,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,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,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,EA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
|
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
|
-
import type { NotificationServicesPushControllerGetStateAction, NotificationServicesPushControllerStateChangeEvent } from "../NotificationServicesPushController/index.mjs";
|
|
9
8
|
export type NotificationServicesPushControllerEnablePushNotifications = {
|
|
10
9
|
type: `NotificationServicesPushController:enablePushNotifications`;
|
|
11
10
|
handler: (UUIDs: string[]) => Promise<void>;
|
|
@@ -98,7 +97,7 @@ export type NotificationServicesControllerDeleteNotificationsById = {
|
|
|
98
97
|
handler: NotificationServicesController['deleteNotificationsById'];
|
|
99
98
|
};
|
|
100
99
|
export type Actions = NotificationServicesControllerGetStateAction | NotificationServicesControllerUpdateMetamaskNotificationsList | NotificationServicesControllerDisableNotificationServices | NotificationServicesControllerSelectIsNotificationServicesEnabled | NotificationServicesControllerGetNotificationsByType | NotificationServicesControllerDeleteNotificationsById;
|
|
101
|
-
export type AllowedActions = KeyringControllerGetAccountsAction | KeyringControllerGetStateAction | AuthenticationController.AuthenticationControllerGetBearerToken | AuthenticationController.AuthenticationControllerIsSignedIn | UserStorageController.UserStorageControllerEnableProfileSyncing | UserStorageController.UserStorageControllerGetStorageKey | UserStorageController.UserStorageControllerPerformGetStorage | UserStorageController.UserStorageControllerPerformSetStorage |
|
|
100
|
+
export type AllowedActions = KeyringControllerGetAccountsAction | KeyringControllerGetStateAction | AuthenticationController.AuthenticationControllerGetBearerToken | AuthenticationController.AuthenticationControllerIsSignedIn | UserStorageController.UserStorageControllerEnableProfileSyncing | UserStorageController.UserStorageControllerGetStorageKey | UserStorageController.UserStorageControllerPerformGetStorage | UserStorageController.UserStorageControllerPerformSetStorage | NotificationServicesPushControllerEnablePushNotifications | NotificationServicesPushControllerDisablePushNotifications | NotificationServicesPushControllerUpdateTriggerPushNotifications | NotificationServicesPushControllerSubscribeToNotifications;
|
|
102
101
|
export type NotificationServicesControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, NotificationServicesControllerState>;
|
|
103
102
|
export type NotificationListUpdatedEvent = {
|
|
104
103
|
type: `${typeof controllerName}:notificationsListUpdated`;
|
|
@@ -109,7 +108,7 @@ export type MarkNotificationsAsReadEvent = {
|
|
|
109
108
|
payload: [INotification[]];
|
|
110
109
|
};
|
|
111
110
|
export type Events = NotificationServicesControllerStateChangeEvent | NotificationListUpdatedEvent | MarkNotificationsAsReadEvent;
|
|
112
|
-
export type AllowedEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | NotificationServicesPushControllerOnNewNotification
|
|
111
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | NotificationServicesPushControllerOnNewNotification;
|
|
113
112
|
export type NotificationServicesControllerMessenger = RestrictedControllerMessenger<typeof controllerName, Actions | AllowedActions, Events | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
114
113
|
type FeatureAnnouncementEnv = {
|
|
115
114
|
spaceId: string;
|
|
@@ -129,12 +128,14 @@ export default class NotificationServicesController extends BaseController<typeo
|
|
|
129
128
|
* @param args.state - Initial state to set on this controller.
|
|
130
129
|
* @param args.env - environment variables for a given controller.
|
|
131
130
|
* @param args.env.featureAnnouncements - env variables for feature announcements.
|
|
131
|
+
* @param args.env.isPushIntegrated - toggle push notifications on/off if client has integrated them.
|
|
132
132
|
*/
|
|
133
133
|
constructor({ messenger, state, env, }: {
|
|
134
134
|
messenger: NotificationServicesControllerMessenger;
|
|
135
135
|
state?: Partial<NotificationServicesControllerState>;
|
|
136
136
|
env: {
|
|
137
137
|
featureAnnouncements: FeatureAnnouncementEnv;
|
|
138
|
+
isPushIntegrated?: boolean;
|
|
138
139
|
};
|
|
139
140
|
});
|
|
140
141
|
/**
|
|
@@ -230,7 +231,6 @@ export default class NotificationServicesController extends BaseController<typeo
|
|
|
230
231
|
*
|
|
231
232
|
* @param previewToken - the preview token to use if needed
|
|
232
233
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
233
|
-
* @returns updated notification list
|
|
234
234
|
*/
|
|
235
235
|
fetchAndUpdateMetamaskNotifications(previewToken?: string): Promise<INotification[]>;
|
|
236
236
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,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,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,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,EAE7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,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_isPushNotificationsSetup, _NotificationServicesController_isUnlocked, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_storage, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_registerMessageHandlers, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_getValidStorageKeyAndBearerToken, _NotificationServicesController_performEnableProfileSyncing, _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_performEnableProfileSyncing, _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;
|
|
@@ -98,6 +98,7 @@ class NotificationServicesController extends BaseController {
|
|
|
98
98
|
* @param args.state - Initial state to set on this controller.
|
|
99
99
|
* @param args.env - environment variables for a given controller.
|
|
100
100
|
* @param args.env.featureAnnouncements - env variables for feature announcements.
|
|
101
|
+
* @param args.env.isPushIntegrated - toggle push notifications on/off if client has integrated them.
|
|
101
102
|
*/
|
|
102
103
|
constructor({ messenger, state, env, }) {
|
|
103
104
|
super({
|
|
@@ -107,6 +108,8 @@ class NotificationServicesController extends BaseController {
|
|
|
107
108
|
state: { ...defaultState, ...state },
|
|
108
109
|
});
|
|
109
110
|
_NotificationServicesController_instances.add(this);
|
|
111
|
+
// Temporary boolean as push notifications are not yet enabled on mobile
|
|
112
|
+
_NotificationServicesController_isPushIntegrated.set(this, true);
|
|
110
113
|
// Flag to check is notifications have been setup when the browser/extension is initialized.
|
|
111
114
|
// We want to re-initialize push notifications when the browser/extension is refreshed
|
|
112
115
|
// To ensure we subscribe to the most up-to-date notifications
|
|
@@ -151,33 +154,11 @@ class NotificationServicesController extends BaseController {
|
|
|
151
154
|
},
|
|
152
155
|
});
|
|
153
156
|
_NotificationServicesController_pushNotifications.set(this, {
|
|
154
|
-
isEnabled: () => this.messagingSystem.call('NotificationServicesPushController:getState')
|
|
155
|
-
?.isPushEnabled ?? false,
|
|
156
|
-
subscribeToPushEnabled: async () => {
|
|
157
|
-
this.messagingSystem.subscribe('NotificationServicesPushController:stateChange',
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
159
|
-
async (newVal, prevVal) => {
|
|
160
|
-
try {
|
|
161
|
-
// Push notifications were enabled
|
|
162
|
-
if (prevVal === false && newVal) {
|
|
163
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").initializePushNotifications();
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
// Push notifications were disabled
|
|
167
|
-
if (prevVal === true && !newVal) {
|
|
168
|
-
__classPrivateFieldSet(this, _NotificationServicesController_isPushNotificationsSetup, false, "f");
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
// Do nothing, silently fail push notifications
|
|
173
|
-
}
|
|
174
|
-
}, (state) => state.isPushEnabled);
|
|
175
|
-
},
|
|
176
157
|
subscribeToPushNotifications: async () => {
|
|
177
158
|
await this.messagingSystem.call('NotificationServicesPushController:subscribeToPushNotifications');
|
|
178
159
|
},
|
|
179
160
|
enablePushNotifications: async (UUIDs) => {
|
|
180
|
-
if (!__classPrivateFieldGet(this,
|
|
161
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
181
162
|
return;
|
|
182
163
|
}
|
|
183
164
|
try {
|
|
@@ -188,7 +169,7 @@ class NotificationServicesController extends BaseController {
|
|
|
188
169
|
}
|
|
189
170
|
},
|
|
190
171
|
disablePushNotifications: async (UUIDs) => {
|
|
191
|
-
if (!__classPrivateFieldGet(this,
|
|
172
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
192
173
|
return;
|
|
193
174
|
}
|
|
194
175
|
try {
|
|
@@ -199,7 +180,7 @@ class NotificationServicesController extends BaseController {
|
|
|
199
180
|
}
|
|
200
181
|
},
|
|
201
182
|
updatePushNotifications: async (UUIDs) => {
|
|
202
|
-
if (!__classPrivateFieldGet(this,
|
|
183
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
203
184
|
return;
|
|
204
185
|
}
|
|
205
186
|
try {
|
|
@@ -210,7 +191,7 @@ class NotificationServicesController extends BaseController {
|
|
|
210
191
|
}
|
|
211
192
|
},
|
|
212
193
|
subscribe: () => {
|
|
213
|
-
if (!__classPrivateFieldGet(this,
|
|
194
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
214
195
|
return;
|
|
215
196
|
}
|
|
216
197
|
this.messagingSystem.subscribe('NotificationServicesPushController:onNewNotifications', (notification) => {
|
|
@@ -219,6 +200,9 @@ class NotificationServicesController extends BaseController {
|
|
|
219
200
|
});
|
|
220
201
|
},
|
|
221
202
|
initializePushNotifications: async () => {
|
|
203
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_isPushIntegrated, "f")) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
222
206
|
if (!this.state.isNotificationServicesEnabled) {
|
|
223
207
|
return;
|
|
224
208
|
}
|
|
@@ -308,6 +292,16 @@ class NotificationServicesController extends BaseController {
|
|
|
308
292
|
},
|
|
309
293
|
});
|
|
310
294
|
_NotificationServicesController_featureAnnouncementEnv.set(this, void 0);
|
|
295
|
+
_NotificationServicesController_performEnableProfileSyncing.set(this, async () => {
|
|
296
|
+
try {
|
|
297
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").enableProfileSyncing();
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
log.error('Failed to enable profile syncing', e);
|
|
301
|
+
throw new Error('Failed to enable profile syncing');
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
__classPrivateFieldSet(this, _NotificationServicesController_isPushIntegrated, env.isPushIntegrated ?? true, "f");
|
|
311
305
|
__classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
|
|
312
306
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerMessageHandlers).call(this);
|
|
313
307
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
|
|
@@ -381,7 +375,7 @@ class NotificationServicesController extends BaseController {
|
|
|
381
375
|
async createOnChainTriggers(opts) {
|
|
382
376
|
try {
|
|
383
377
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
384
|
-
await __classPrivateFieldGet(this,
|
|
378
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_performEnableProfileSyncing, "f").call(this);
|
|
385
379
|
const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getValidStorageKeyAndBearerToken).call(this);
|
|
386
380
|
const { accounts } = await __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
387
381
|
// Attempt Get User Storage
|
|
@@ -454,28 +448,30 @@ class NotificationServicesController extends BaseController {
|
|
|
454
448
|
* @throws {Error} If the user is not authenticated or if there is an error during the process.
|
|
455
449
|
*/
|
|
456
450
|
async disableNotificationServices() {
|
|
457
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
458
|
-
// Attempt Disable Push Notifications
|
|
459
451
|
try {
|
|
452
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
453
|
+
// Disable Push Notifications
|
|
460
454
|
const userStorage = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getUserStorage).call(this);
|
|
461
455
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertUserStorage).call(this, userStorage);
|
|
462
456
|
const UUIDs = Utils.getAllUUIDs(userStorage);
|
|
463
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
|
+
});
|
|
464
467
|
}
|
|
465
|
-
catch {
|
|
466
|
-
|
|
468
|
+
catch (e) {
|
|
469
|
+
log.error('Unable to disable notifications', e);
|
|
470
|
+
throw new Error('Unable to disable notifications');
|
|
471
|
+
}
|
|
472
|
+
finally {
|
|
473
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
467
474
|
}
|
|
468
|
-
// Update State: remove non-permitted notifications & disable flags
|
|
469
|
-
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === TRIGGER_TYPES.SNAP);
|
|
470
|
-
this.update((state) => {
|
|
471
|
-
state.isNotificationServicesEnabled = false;
|
|
472
|
-
state.isFeatureAnnouncementsEnabled = false;
|
|
473
|
-
// reassigning the notifications list with just snaps
|
|
474
|
-
// since the disable shouldn't affect snaps notifications
|
|
475
|
-
state.metamaskNotificationsList = snapNotifications;
|
|
476
|
-
});
|
|
477
|
-
// Finish Updating State
|
|
478
|
-
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
479
475
|
}
|
|
480
476
|
/**
|
|
481
477
|
* Deletes on-chain triggers associated with a specific account.
|
|
@@ -593,7 +589,6 @@ class NotificationServicesController extends BaseController {
|
|
|
593
589
|
*
|
|
594
590
|
* @param previewToken - the preview token to use if needed
|
|
595
591
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
596
|
-
* @returns updated notification list
|
|
597
592
|
*/
|
|
598
593
|
async fetchAndUpdateMetamaskNotifications(previewToken) {
|
|
599
594
|
try {
|
|
@@ -800,7 +795,7 @@ class NotificationServicesController extends BaseController {
|
|
|
800
795
|
}
|
|
801
796
|
}
|
|
802
797
|
}
|
|
803
|
-
_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() {
|
|
798
|
+
_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_performEnableProfileSyncing = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_registerMessageHandlers = function _NotificationServicesController_registerMessageHandlers() {
|
|
804
799
|
this.messagingSystem.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
|
|
805
800
|
this.messagingSystem.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
|
|
806
801
|
this.messagingSystem.registerActionHandler(`${controllerName}:selectIsNotificationServicesEnabled`, this.selectIsNotificationServicesEnabled.bind(this));
|
|
@@ -828,14 +823,6 @@ _NotificationServicesController_isPushNotificationsSetup = new WeakMap(), _Notif
|
|
|
828
823
|
throw new Error('Missing BearerToken or storage key');
|
|
829
824
|
}
|
|
830
825
|
return { bearerToken, storageKey };
|
|
831
|
-
}, _NotificationServicesController_performEnableProfileSyncing = async function _NotificationServicesController_performEnableProfileSyncing() {
|
|
832
|
-
try {
|
|
833
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_storage, "f").enableProfileSyncing();
|
|
834
|
-
}
|
|
835
|
-
catch (e) {
|
|
836
|
-
log.error('Failed to enable profile syncing', e);
|
|
837
|
-
throw new Error('Failed to enable profile syncing');
|
|
838
|
-
}
|
|
839
826
|
}, _NotificationServicesController_assertUserStorage = function _NotificationServicesController_assertUserStorage(storage) {
|
|
840
827
|
if (!storage) {
|
|
841
828
|
throw new Error('User Storage does not exist');
|
|
@@ -859,7 +846,7 @@ async function _NotificationServicesController_getUserStorage() {
|
|
|
859
846
|
const userStorage = JSON.parse(userStorageString);
|
|
860
847
|
return userStorage;
|
|
861
848
|
}
|
|
862
|
-
catch {
|
|
849
|
+
catch (error) {
|
|
863
850
|
log.error('Unable to parse User Storage');
|
|
864
851
|
return null;
|
|
865
852
|
}
|