@metamask-previews/notification-services-controller 24.0.0-preview-fe92f4bb3 → 24.1.0-preview-9b6bf0851
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 +9 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts +2 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts +2 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.mjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.cjs +12 -9
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +14 -3
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +14 -3
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +12 -9
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +16 -7
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +8 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +8 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +16 -7
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +2 -0
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +5 -1
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +5 -1
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +2 -0
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [24.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `registerPushNotifications` to `NotificationServicesControllerEnableNotificationsOptions` so clients can enable MetaMask notifications without registering push notifications. ([#8782](https://github.com/MetaMask/core/pull/8782))
|
|
15
|
+
- Add optional mobile OS and app version metadata to push token registrations so clients can provide Firebase error attribution data. ([#8782](https://github.com/MetaMask/core/pull/8782))
|
|
16
|
+
|
|
10
17
|
## [24.0.0]
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -743,7 +750,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
743
750
|
|
|
744
751
|
- Initial release
|
|
745
752
|
|
|
746
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@24.
|
|
753
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@24.1.0...HEAD
|
|
754
|
+
[24.1.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@24.0.0...@metamask/notification-services-controller@24.1.0
|
|
747
755
|
[24.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.1.1...@metamask/notification-services-controller@24.0.0
|
|
748
756
|
[23.1.1]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.1.0...@metamask/notification-services-controller@23.1.1
|
|
749
757
|
[23.1.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.0.1...@metamask/notification-services-controller@23.1.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.cjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * Notification preferences are initialized only when\n * {@link AuthenticatedUserStorageService} has no stored preferences yet.\n * Existing preferences are left as-is.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.hasMarketingConsent - The user's marketing-consent flag.\n * Used only during initialization to seed marketing push notifications.\n * @param opts.productAnnouncementEnabled - The user's product-announcement flag.\n * Used only during initialization to seed marketing in-app notifications.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @param opts - Optional settings for first-time AUS notification preferences initialization.\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.cjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * Notification preferences are initialized only when\n * {@link AuthenticatedUserStorageService} has no stored preferences yet.\n * Existing preferences are left as-is.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.hasMarketingConsent - The user's marketing-consent flag.\n * Used only during initialization to seed marketing push notifications.\n * @param opts.productAnnouncementEnabled - The user's product-announcement flag.\n * Used only during initialization to seed marketing in-app notifications.\n * @param opts.registerPushNotifications - Whether to attempt FCM/device push registration.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @param opts - Optional options to mutate this functionality.\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts
CHANGED
|
@@ -52,6 +52,7 @@ export type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =
|
|
|
52
52
|
* Used only during initialization to seed marketing push notifications.
|
|
53
53
|
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
54
54
|
* Used only during initialization to seed marketing in-app notifications.
|
|
55
|
+
* @param opts.registerPushNotifications - Whether to attempt FCM/device push registration.
|
|
55
56
|
* @returns The updated or newly created user storage.
|
|
56
57
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
57
58
|
*/
|
|
@@ -63,7 +64,7 @@ export type NotificationServicesControllerCreateOnChainTriggersAction = {
|
|
|
63
64
|
* Enables all MetaMask notifications for the user.
|
|
64
65
|
* This is identical flow when initializing notifications for the first time.
|
|
65
66
|
*
|
|
66
|
-
* @param opts - Optional
|
|
67
|
+
* @param opts - Optional options to mutate this functionality.
|
|
67
68
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
68
69
|
*/
|
|
69
70
|
export type NotificationServicesControllerEnableMetamaskNotificationsAction = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,6CAAyC;AAEvF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4DAA4D,GAAG;IACzE,IAAI,EAAE,yDAAyD,CAAC;IAChE,OAAO,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,6CAAyC;AAEvF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4DAA4D,GAAG;IACzE,IAAI,EAAE,yDAAyD,CAAC;IAChE,OAAO,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+DAA+D,GAAG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E,CAAC;IACvE,OAAO,EAAE,8BAA8B,CAAC,iCAAiC,CAAC,CAAC;CAC5E,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,MAAM,mEAAmE,GAC7E;IACE,IAAI,EAAE,gEAAgE,CAAC;IACvE,OAAO,EAAE,8BAA8B,CAAC,iCAAiC,CAAC,CAAC;CAC5E,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACnD,wCAAwC,GACxC,2DAA2D,GAC3D,4DAA4D,GAC5D,yDAAyD,GACzD,kEAAkE,GAClE,yDAAyD,GACzD,+DAA+D,GAC/D,+DAA+D,GAC/D,mDAAmD,GACnD,kDAAkD,GAClD,uEAAuE,GACvE,0DAA0D,GAC1D,0DAA0D,GAC1D,2DAA2D,GAC3D,mEAAmE,GACnE,mEAAmE,GACnE,kEAAkE,CAAC"}
|
package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts
CHANGED
|
@@ -52,6 +52,7 @@ export type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =
|
|
|
52
52
|
* Used only during initialization to seed marketing push notifications.
|
|
53
53
|
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
54
54
|
* Used only during initialization to seed marketing in-app notifications.
|
|
55
|
+
* @param opts.registerPushNotifications - Whether to attempt FCM/device push registration.
|
|
55
56
|
* @returns The updated or newly created user storage.
|
|
56
57
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
57
58
|
*/
|
|
@@ -63,7 +64,7 @@ export type NotificationServicesControllerCreateOnChainTriggersAction = {
|
|
|
63
64
|
* Enables all MetaMask notifications for the user.
|
|
64
65
|
* This is identical flow when initializing notifications for the first time.
|
|
65
66
|
*
|
|
66
|
-
* @param opts - Optional
|
|
67
|
+
* @param opts - Optional options to mutate this functionality.
|
|
67
68
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
68
69
|
*/
|
|
69
70
|
export type NotificationServicesControllerEnableMetamaskNotificationsAction = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,6CAAyC;AAEvF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4DAA4D,GAAG;IACzE,IAAI,EAAE,yDAAyD,CAAC;IAChE,OAAO,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,6CAAyC;AAEvF,MAAM,MAAM,wC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,CAAC,CAAC;CAC3E,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACnD,wCAAwC,GACxC,2DAA2D,GAC3D,4DAA4D,GAC5D,yDAAyD,GACzD,kEAAkE,GAClE,yDAAyD,GACzD,+DAA+D,GAC/D,+DAA+D,GAC/D,mDAAmD,GACnD,kDAAkD,GAClD,uEAAuE,GACvE,0DAA0D,GAC1D,0DAA0D,GAC1D,2DAA2D,GAC3D,mEAAmE,GACnE,mEAAmE,GACnE,kEAAkE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.mjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * Notification preferences are initialized only when\n * {@link AuthenticatedUserStorageService} has no stored preferences yet.\n * Existing preferences are left as-is.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.hasMarketingConsent - The user's marketing-consent flag.\n * Used only during initialization to seed marketing push notifications.\n * @param opts.productAnnouncementEnabled - The user's product-announcement flag.\n * Used only during initialization to seed marketing in-app notifications.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @param opts - Optional settings for first-time AUS notification preferences initialization.\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.mjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * Notification preferences are initialized only when\n * {@link AuthenticatedUserStorageService} has no stored preferences yet.\n * Existing preferences are left as-is.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.hasMarketingConsent - The user's marketing-consent flag.\n * Used only during initialization to seed marketing push notifications.\n * @param opts.productAnnouncementEnabled - The user's product-announcement flag.\n * Used only during initialization to seed marketing in-app notifications.\n * @param opts.registerPushNotifications - Whether to attempt FCM/device push registration.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @param opts - Optional options to mutate this functionality.\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
|
@@ -527,10 +527,11 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
527
527
|
* Used only during initialization to seed marketing push notifications.
|
|
528
528
|
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
529
529
|
* Used only during initialization to seed marketing in-app notifications.
|
|
530
|
+
* @param opts.registerPushNotifications - Whether to attempt FCM/device push registration.
|
|
530
531
|
* @returns The updated or newly created user storage.
|
|
531
532
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
532
533
|
*/
|
|
533
|
-
async createOnChainTriggers(opts) {
|
|
534
|
+
async createOnChainTriggers(opts = {}) {
|
|
534
535
|
try {
|
|
535
536
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
536
537
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
@@ -551,12 +552,14 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
551
552
|
const accountsWithNotifications = (effectivePreferences?.walletActivity.accounts ?? [])
|
|
552
553
|
.filter((account) => account.enabled)
|
|
553
554
|
.map((account) => account.address);
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
555
|
+
if (opts.registerPushNotifications ?? true) {
|
|
556
|
+
// Attempt FCM/device registration only; clients must request OS permission separately.
|
|
557
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
558
|
+
.enablePushNotifications(accountsWithNotifications)
|
|
559
|
+
.catch(() => {
|
|
560
|
+
// Do Nothing
|
|
561
|
+
});
|
|
562
|
+
}
|
|
560
563
|
// Update the state of the controller
|
|
561
564
|
this.update((state) => {
|
|
562
565
|
// User is re-subscribing (daily resub to get latest notifications)
|
|
@@ -584,10 +587,10 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
584
587
|
* Enables all MetaMask notifications for the user.
|
|
585
588
|
* This is identical flow when initializing notifications for the first time.
|
|
586
589
|
*
|
|
587
|
-
* @param opts - Optional
|
|
590
|
+
* @param opts - Optional options to mutate this functionality.
|
|
588
591
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
589
592
|
*/
|
|
590
|
-
async enableMetamaskNotifications(opts) {
|
|
593
|
+
async enableMetamaskNotifications(opts = {}) {
|
|
591
594
|
try {
|
|
592
595
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
593
596
|
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
|