diff --git a/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts b/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts index ff4d242a33..480ecbb23b 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts @@ -210,27 +210,27 @@ export type AllowedActions = | NotificationServicesPushControllerUpdateTriggerPushNotifications; // Events -export type NotificationServicesControllerChangeEvent = +export type NotificationServicesControllerStateChangeEvent = ControllerStateChangeEvent< typeof controllerName, NotificationServicesControllerState >; -export type MetamaskNotificationsControllerNotificationsListUpdatedEvent = { +export type NotificationListUpdatedEvent = { type: `${typeof controllerName}:notificationsListUpdated`; payload: [INotification[]]; }; -export type MetamaskNotificationsControllerMarkNotificationsAsRead = { +export type MarkNotificationsAsReadEvent = { type: `${typeof controllerName}:markNotificationsAsRead`; payload: [INotification[]]; }; // Events export type Events = - | NotificationServicesControllerChangeEvent - | MetamaskNotificationsControllerNotificationsListUpdatedEvent - | MetamaskNotificationsControllerMarkNotificationsAsRead; + | NotificationServicesControllerStateChangeEvent + | NotificationListUpdatedEvent + | MarkNotificationsAsReadEvent; // Allowed Events export type AllowedEvents = diff --git a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts index 69db8fde3c..18d7fbd626 100644 --- a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts +++ b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts @@ -14,16 +14,16 @@ export const MOCK_USER_STORAGE_NOTIFICATIONS_ENDPOINT = `${USER_STORAGE_ENDPOINT MOCK_STORAGE_KEY, )}`; -const MOCK_GET_USER_STORAGE_RESPONSE: GetUserStorageResponse = { +const MOCK_GET_USER_STORAGE_RESPONSE = (): GetUserStorageResponse => ({ HashedKey: 'HASHED_KEY', - Data: MOCK_ENCRYPTED_STORAGE_DATA, -}; + Data: MOCK_ENCRYPTED_STORAGE_DATA(), +}); export const getMockUserStorageGetResponse = () => { return { url: MOCK_USER_STORAGE_NOTIFICATIONS_ENDPOINT, requestMethod: 'GET', - response: MOCK_GET_USER_STORAGE_RESPONSE, + response: MOCK_GET_USER_STORAGE_RESPONSE(), } satisfies MockResponse; }; diff --git a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockStorage.ts b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockStorage.ts index 4a43a80556..1f6a87b9f6 100644 --- a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockStorage.ts +++ b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockStorage.ts @@ -3,7 +3,8 @@ import encryption, { createSHA256Hash } from '../encryption'; export const MOCK_STORAGE_KEY_SIGNATURE = 'mockStorageKey'; export const MOCK_STORAGE_KEY = createSHA256Hash(MOCK_STORAGE_KEY_SIGNATURE); export const MOCK_STORAGE_DATA = JSON.stringify({ hello: 'world' }); -export const MOCK_ENCRYPTED_STORAGE_DATA = encryption.encryptString( - MOCK_STORAGE_DATA, - MOCK_STORAGE_KEY, -); + +// NOTE - using encryption.encryptString directly in fixtures causes issues on mobile. +// This is because this fixture is getting added in at run time. Will be improved once we support multiple exports +export const MOCK_ENCRYPTED_STORAGE_DATA = () => + encryption.encryptString(MOCK_STORAGE_DATA, MOCK_STORAGE_KEY); diff --git a/packages/profile-sync-controller/src/controllers/user-storage/services.test.ts b/packages/profile-sync-controller/src/controllers/user-storage/services.test.ts index fe7b96573d..b788ec7bf5 100644 --- a/packages/profile-sync-controller/src/controllers/user-storage/services.test.ts +++ b/packages/profile-sync-controller/src/controllers/user-storage/services.test.ts @@ -60,8 +60,9 @@ describe('user-storage/services.ts - getUserStorage() tests', () => { }); describe('user-storage/services.ts - upsertUserStorage() tests', () => { + const encryptedData = MOCK_ENCRYPTED_STORAGE_DATA(); const actCallUpsertUserStorage = () => { - return upsertUserStorage(MOCK_ENCRYPTED_STORAGE_DATA, { + return upsertUserStorage(encryptedData, { bearerToken: 'MOCK_BEARER_TOKEN', path: 'notifications.notificationSettings', storageKey: MOCK_STORAGE_KEY,