@metamask-previews/notification-services-controller 26.0.1-preview-4f4c98e → 26.0.1-preview-eb263b0ee
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 +0 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.cjs +7 -0
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.cjs.map +1 -0
- package/dist/NotificationServicesController/{NotificationServicesController-method-action-types.d.ts → NotificationServicesController-method-action-types.d.cts} +2 -2
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts.map +1 -0
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts +206 -0
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts.map +1 -0
- package/dist/NotificationServicesController/{NotificationServicesController-method-action-types.js → NotificationServicesController-method-action-types.mjs} +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.mjs.map +1 -0
- package/dist/NotificationServicesController/NotificationServicesController.cjs +1055 -0
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -0
- package/dist/NotificationServicesController/{NotificationServicesController.d.ts → NotificationServicesController.d.cts} +15 -15
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -0
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +292 -0
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -0
- package/dist/NotificationServicesController/{NotificationServicesController.js → NotificationServicesController.mjs} +26 -18
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/index.cjs +18 -0
- package/dist/NotificationServicesController/constants/index.cjs.map +1 -0
- package/dist/NotificationServicesController/constants/index.d.cts +2 -0
- package/dist/NotificationServicesController/constants/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/index.d.mts +2 -0
- package/dist/NotificationServicesController/constants/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/index.mjs +2 -0
- package/dist/NotificationServicesController/constants/index.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.cjs +46 -0
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -0
- package/dist/NotificationServicesController/constants/{notification-schema.d.ts → notification-schema.d.cts} +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +22 -0
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/{notification-schema.js → notification-schema.mjs} +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -0
- package/dist/NotificationServicesController/index.cjs +44 -0
- package/dist/NotificationServicesController/index.cjs.map +1 -0
- package/dist/NotificationServicesController/{index.d.ts → index.d.cts} +14 -14
- package/dist/NotificationServicesController/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/index.d.mts +16 -0
- package/dist/NotificationServicesController/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/index.mjs +13 -0
- package/dist/NotificationServicesController/index.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/index.cjs +21 -0
- package/dist/NotificationServicesController/mocks/index.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/index.d.cts +5 -0
- package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/index.d.mts +5 -0
- package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/index.mjs +5 -0
- package/dist/NotificationServicesController/mocks/index.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs +210 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/{mock-feature-announcements.d.ts → mock-feature-announcements.d.cts} +3 -3
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.mts +15 -0
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/{mock-feature-announcements.js → mock-feature-announcements.mjs} +2 -2
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +830 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/{mock-raw-notifications.d.ts → mock-raw-notifications.d.cts} +2 -2
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts +104 -0
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/{mock-raw-notifications.js → mock-raw-notifications.mjs} +2 -2
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs +29 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/{mock-snap-notification.d.ts → mock-snap-notification.d.cts} +2 -2
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts +8 -0
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/{mock-snap-notification.js → mock-snap-notification.mjs} +2 -2
- package/dist/NotificationServicesController/mocks/mock-snap-notification.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +53 -0
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/{mockResponses.d.ts → mockResponses.d.cts} +3 -3
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts +14 -0
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/{mockResponses.js → mockResponses.mjs} +6 -6
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/index.cjs +20 -0
- package/dist/NotificationServicesController/processors/index.cjs.map +1 -0
- package/dist/NotificationServicesController/processors/index.d.cts +4 -0
- package/dist/NotificationServicesController/processors/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/index.d.mts +4 -0
- package/dist/NotificationServicesController/processors/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/index.mjs +4 -0
- package/dist/NotificationServicesController/processors/index.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-api-notifications.cjs +24 -0
- package/dist/NotificationServicesController/processors/process-api-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/processors/{process-api-notifications.d.ts → process-api-notifications.d.cts} +3 -3
- package/dist/NotificationServicesController/processors/process-api-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-api-notifications.d.mts +10 -0
- package/dist/NotificationServicesController/processors/process-api-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/{process-api-notifications.js → process-api-notifications.mjs} +3 -3
- package/dist/NotificationServicesController/processors/process-api-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.cjs +38 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.cjs.map +1 -0
- package/dist/NotificationServicesController/processors/{process-feature-announcement.d.ts → process-feature-announcement.d.cts} +3 -3
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts +19 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/{process-feature-announcement.js → process-feature-announcement.mjs} +3 -3
- package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-notifications.cjs +60 -0
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/processors/{process-notifications.d.ts → process-notifications.d.cts} +2 -2
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +20 -0
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/{process-notifications.js → process-notifications.mjs} +5 -5
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-snap-notifications.cjs +25 -0
- package/dist/NotificationServicesController/processors/process-snap-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/processors/{process-snap-notifications.d.ts → process-snap-notifications.d.cts} +3 -3
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts +10 -0
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/{process-snap-notifications.js → process-snap-notifications.mjs} +3 -3
- package/dist/NotificationServicesController/processors/process-snap-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/services/api-notifications.cjs +128 -0
- package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/services/{api-notifications.d.ts → api-notifications.d.cts} +2 -2
- package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/api-notifications.d.mts +44 -0
- package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/{api-notifications.js → api-notifications.mjs} +12 -5
- package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/services/feature-announcements.cjs +140 -0
- package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -0
- package/dist/NotificationServicesController/services/{feature-announcements.d.ts → feature-announcements.d.cts} +4 -4
- package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/feature-announcements.d.mts +32 -0
- package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/{feature-announcements.js → feature-announcements.mjs} +5 -5
- package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -0
- package/dist/NotificationServicesController/services/notification-config-cache.cjs +61 -0
- package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -0
- package/dist/NotificationServicesController/services/{notification-config-cache.d.ts → notification-config-cache.d.cts} +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts +15 -0
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/{notification-config-cache.js → notification-config-cache.mjs} +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -0
- package/dist/NotificationServicesController/services/perp-notifications.cjs +31 -0
- package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -0
- package/dist/NotificationServicesController/services/{perp-notifications.d.ts → perp-notifications.d.cts} +2 -2
- package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/perp-notifications.d.mts +11 -0
- package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/{perp-notifications.js → perp-notifications.mjs} +2 -2
- package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/{feature-announcement.d.ts → feature-announcement.d.cts} +3 -3
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts +32 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.cts +4 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.mts +4 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.mjs +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.cjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/{type-feature-announcement.d.ts → type-feature-announcement.d.cts} +3 -3
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.mts +43 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.cjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/{type-links.d.ts → type-links.d.cts} +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.mts +29 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs.map +1 -0
- package/dist/NotificationServicesController/types/index.cjs +3 -0
- package/dist/NotificationServicesController/types/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/index.d.cts +6 -0
- package/dist/NotificationServicesController/types/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/index.d.mts +6 -0
- package/dist/NotificationServicesController/types/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/index.mjs +2 -0
- package/dist/NotificationServicesController/types/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.cjs +3 -0
- package/dist/NotificationServicesController/types/notification/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/notification/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/notification/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.mjs +2 -0
- package/dist/NotificationServicesController/types/notification/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/notification.cjs +3 -0
- package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/{notification.d.ts → notification.d.cts} +5 -5
- package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification/notification.d.mts +22 -0
- package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification/notification.mjs +2 -0
- package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/index.cjs +3 -0
- package/dist/NotificationServicesController/types/notification-api/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/index.d.cts +3 -0
- package/dist/NotificationServicesController/types/notification-api/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/index.d.mts +3 -0
- package/dist/NotificationServicesController/types/notification-api/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/index.mjs +2 -0
- package/dist/NotificationServicesController/types/notification-api/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.cjs +4 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/{notification-api.d.ts → notification-api.d.cts} +4 -4
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +59 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.mjs +2 -0
- package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/schema.cjs +6 -0
- package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/{schema.d.ts → schema.d.cts} +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/schema.d.mts +752 -0
- package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification-api/{schema.js → schema.mjs} +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -0
- package/dist/NotificationServicesController/types/perps/index.cjs +3 -0
- package/dist/NotificationServicesController/types/perps/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/perps/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/perps/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/perps/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/perps/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/perps/index.mjs +2 -0
- package/dist/NotificationServicesController/types/perps/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/perps/perp-types.cjs +3 -0
- package/dist/NotificationServicesController/types/perps/perp-types.cjs.map +1 -0
- package/dist/NotificationServicesController/types/perps/perp-types.d.cts +3 -0
- package/dist/NotificationServicesController/types/perps/perp-types.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/perps/perp-types.d.mts +3 -0
- package/dist/NotificationServicesController/types/perps/perp-types.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/perps/perp-types.mjs +2 -0
- package/dist/NotificationServicesController/types/perps/perp-types.mjs.map +1 -0
- package/dist/NotificationServicesController/types/perps/schema.cjs +6 -0
- package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -0
- package/dist/NotificationServicesController/types/perps/{schema.d.ts → schema.d.cts} +1 -1
- package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/perps/schema.d.mts +133 -0
- package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/perps/{schema.js → schema.mjs} +1 -1
- package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -0
- package/dist/NotificationServicesController/types/snaps/index.cjs +3 -0
- package/dist/NotificationServicesController/types/snaps/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/snaps/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/snaps/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/snaps/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/snaps/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/snaps/index.mjs +2 -0
- package/dist/NotificationServicesController/types/snaps/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/snaps/snaps.cjs +3 -0
- package/dist/NotificationServicesController/types/snaps/snaps.cjs.map +1 -0
- package/dist/NotificationServicesController/types/snaps/{snaps.d.ts → snaps.d.cts} +2 -2
- package/dist/NotificationServicesController/types/snaps/snaps.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/snaps/snaps.d.mts +23 -0
- package/dist/NotificationServicesController/types/snaps/snaps.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/snaps/snaps.mjs +2 -0
- package/dist/NotificationServicesController/types/snaps/snaps.mjs.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.cjs +3 -0
- package/dist/NotificationServicesController/types/type-utils.cjs.map +1 -0
- package/dist/NotificationServicesController/types/{type-utils.d.ts → type-utils.d.cts} +1 -1
- package/dist/NotificationServicesController/types/type-utils.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.d.mts +7 -0
- package/dist/NotificationServicesController/types/type-utils.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.mjs +2 -0
- package/dist/NotificationServicesController/types/type-utils.mjs.map +1 -0
- package/dist/NotificationServicesController/utils/get-notification-subtype.cjs +33 -0
- package/dist/NotificationServicesController/utils/get-notification-subtype.cjs.map +1 -0
- package/dist/NotificationServicesController/utils/{get-notification-subtype.d.ts → get-notification-subtype.d.cts} +2 -2
- package/dist/NotificationServicesController/utils/get-notification-subtype.d.cts.map +1 -0
- package/dist/NotificationServicesController/utils/get-notification-subtype.d.mts +17 -0
- package/dist/NotificationServicesController/utils/get-notification-subtype.d.mts.map +1 -0
- package/dist/NotificationServicesController/utils/{get-notification-subtype.js → get-notification-subtype.mjs} +3 -3
- package/dist/NotificationServicesController/utils/get-notification-subtype.mjs.map +1 -0
- package/dist/NotificationServicesController/utils/isVersionInBounds.cjs +37 -0
- package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -0
- package/dist/NotificationServicesController/utils/{isVersionInBounds.d.ts → isVersionInBounds.d.cts} +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -0
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts +18 -0
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -0
- package/dist/NotificationServicesController/utils/{isVersionInBounds.js → isVersionInBounds.mjs} +2 -2
- package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -0
- package/dist/NotificationServicesController/utils/should-auto-expire.cjs +12 -0
- package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -0
- package/dist/NotificationServicesController/utils/{should-auto-expire.d.ts → should-auto-expire.d.cts} +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -0
- package/dist/NotificationServicesController/utils/should-auto-expire.d.mts +2 -0
- package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -0
- package/dist/NotificationServicesController/utils/{should-auto-expire.js → should-auto-expire.mjs} +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -0
- package/dist/NotificationServicesController/utils/utils.cjs +25 -0
- package/dist/NotificationServicesController/utils/utils.cjs.map +1 -0
- package/dist/NotificationServicesController/utils/{utils.d.ts → utils.d.cts} +1 -1
- package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -0
- package/dist/NotificationServicesController/utils/utils.d.mts +11 -0
- package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -0
- package/dist/NotificationServicesController/utils/{utils.js → utils.mjs} +1 -1
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.cjs +7 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.cjs.map +1 -0
- package/dist/NotificationServicesPushController/{NotificationServicesPushController-method-action-types.d.ts → NotificationServicesPushController-method-action-types.d.cts} +2 -2
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.mts +72 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/{NotificationServicesPushController-method-action-types.js → NotificationServicesPushController-method-action-types.mjs} +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.mjs.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +342 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -0
- package/dist/NotificationServicesPushController/{NotificationServicesPushController.d.ts → NotificationServicesPushController.d.cts} +9 -9
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +123 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/{NotificationServicesPushController.js → NotificationServicesPushController.mjs} +11 -4
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -0
- package/dist/NotificationServicesPushController/index.cjs +37 -0
- package/dist/NotificationServicesPushController/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/{index.d.ts → index.d.cts} +9 -9
- package/dist/NotificationServicesPushController/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/index.d.mts +11 -0
- package/dist/NotificationServicesPushController/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/index.mjs +8 -0
- package/dist/NotificationServicesPushController/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.cjs +18 -0
- package/dist/NotificationServicesPushController/mocks/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.d.cts +2 -0
- package/dist/NotificationServicesPushController/mocks/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.d.mts +2 -0
- package/dist/NotificationServicesPushController/mocks/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/index.mjs +2 -0
- package/dist/NotificationServicesPushController/mocks/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +48 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -0
- package/dist/NotificationServicesPushController/mocks/{mockResponse.d.ts → mockResponse.d.cts} +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +22 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/mocks/{mockResponse.js → mockResponse.mjs} +2 -2
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/endpoints.cjs +13 -0
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -0
- package/dist/NotificationServicesPushController/services/{endpoints.d.ts → endpoints.d.cts} +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/endpoints.d.mts +4 -0
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/{endpoints.js → endpoints.mjs} +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/services.cjs +133 -0
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -0
- package/dist/NotificationServicesPushController/services/{services.d.ts → services.d.cts} +4 -4
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/services.d.mts +90 -0
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/{services.js → services.mjs} +2 -2
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -0
- package/dist/NotificationServicesPushController/types/firebase.cjs +3 -0
- package/dist/NotificationServicesPushController/types/firebase.cjs.map +1 -0
- package/dist/NotificationServicesPushController/types/{firebase.d.ts → firebase.d.cts} +1 -1
- package/dist/NotificationServicesPushController/types/firebase.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/firebase.d.mts +53 -0
- package/dist/NotificationServicesPushController/types/firebase.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/firebase.mjs +2 -0
- package/dist/NotificationServicesPushController/types/firebase.mjs.map +1 -0
- package/dist/NotificationServicesPushController/types/index.cjs +3 -0
- package/dist/NotificationServicesPushController/types/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/types/index.d.cts +4 -0
- package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/index.d.mts +4 -0
- package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/index.mjs +2 -0
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/types/push-analytics.cjs +5 -0
- package/dist/NotificationServicesPushController/types/push-analytics.cjs.map +1 -0
- package/dist/NotificationServicesPushController/types/{push-analytics.d.ts → push-analytics.d.cts} +1 -1
- package/dist/NotificationServicesPushController/types/push-analytics.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/push-analytics.d.mts +18 -0
- package/dist/NotificationServicesPushController/types/push-analytics.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/{push-analytics.js → push-analytics.mjs} +1 -1
- package/dist/NotificationServicesPushController/types/push-analytics.mjs.map +1 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.cjs +3 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.cjs.map +1 -0
- package/dist/NotificationServicesPushController/types/{push-service-interface.d.ts → push-service-interface.d.cts} +2 -2
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts +30 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs +2 -0
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +84 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/{get-notification-data.d.ts → get-notification-data.d.cts} +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +42 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/{get-notification-data.js → get-notification-data.mjs} +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +171 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/{get-notification-message.d.ts → get-notification-message.d.cts} +3 -3
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +62 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/{get-notification-message.js → get-notification-message.mjs} +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.cjs +20 -0
- package/dist/NotificationServicesPushController/utils/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.d.cts +4 -0
- package/dist/NotificationServicesPushController/utils/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.d.mts +4 -0
- package/dist/NotificationServicesPushController/utils/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.mjs +4 -0
- package/dist/NotificationServicesPushController/utils/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.cjs +26 -0
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.cjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/{to-push-analytics-payload.d.ts → to-push-analytics-payload.d.cts} +2 -2
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.d.mts +12 -0
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/{to-push-analytics-payload.js → to-push-analytics-payload.mjs} +1 -1
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.mjs.map +1 -0
- package/dist/NotificationServicesPushController/web/index.cjs +8 -0
- package/dist/NotificationServicesPushController/web/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/web/index.d.cts +2 -0
- package/dist/NotificationServicesPushController/web/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/web/index.d.mts +2 -0
- package/dist/NotificationServicesPushController/web/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/web/index.mjs +2 -0
- package/dist/NotificationServicesPushController/web/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/web/push-utils.cjs +169 -0
- package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -0
- package/dist/NotificationServicesPushController/web/{push-utils.d.ts → push-utils.d.cts} +5 -4
- package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/web/push-utils.d.mts +37 -0
- package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/web/{push-utils.js → push-utils.mjs} +13 -6
- package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -0
- package/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/shared/index.cjs +20 -0
- package/dist/shared/index.cjs.map +1 -0
- package/dist/shared/index.d.cts +4 -0
- package/dist/shared/index.d.cts.map +1 -0
- package/dist/shared/index.d.mts +4 -0
- package/dist/shared/index.d.mts.map +1 -0
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -0
- package/dist/shared/is-onchain-notification.cjs +15 -0
- package/dist/shared/is-onchain-notification.cjs.map +1 -0
- package/dist/shared/{is-onchain-notification.d.ts → is-onchain-notification.d.cts} +2 -2
- package/dist/shared/is-onchain-notification.d.cts.map +1 -0
- package/dist/shared/is-onchain-notification.d.mts +9 -0
- package/dist/shared/is-onchain-notification.d.mts.map +1 -0
- package/dist/shared/{is-onchain-notification.js → is-onchain-notification.mjs} +2 -2
- package/dist/shared/is-onchain-notification.mjs.map +1 -0
- package/dist/shared/notification-api-type-guards.cjs +24 -0
- package/dist/shared/notification-api-type-guards.cjs.map +1 -0
- package/dist/shared/{notification-api-type-guards.d.ts → notification-api-type-guards.d.cts} +2 -2
- package/dist/shared/notification-api-type-guards.d.cts.map +1 -0
- package/dist/shared/notification-api-type-guards.d.mts +16 -0
- package/dist/shared/notification-api-type-guards.d.mts.map +1 -0
- package/dist/shared/{notification-api-type-guards.js → notification-api-type-guards.mjs} +1 -1
- package/dist/shared/notification-api-type-guards.mjs.map +1 -0
- package/dist/shared/to-raw-notification.cjs +30 -0
- package/dist/shared/to-raw-notification.cjs.map +1 -0
- package/dist/shared/{to-raw-notification.d.ts → to-raw-notification.d.cts} +2 -2
- package/dist/shared/to-raw-notification.d.cts.map +1 -0
- package/dist/shared/to-raw-notification.d.mts +11 -0
- package/dist/shared/to-raw-notification.d.mts.map +1 -0
- package/dist/shared/{to-raw-notification.js → to-raw-notification.mjs} +3 -3
- package/dist/shared/to-raw-notification.mjs.map +1 -0
- package/package.json +58 -24
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.ts.map +0 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.js.map +0 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.ts.map +0 -1
- package/dist/NotificationServicesController/NotificationServicesController.js.map +0 -1
- package/dist/NotificationServicesController/constants/index.d.ts +0 -2
- package/dist/NotificationServicesController/constants/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/constants/index.js +0 -2
- package/dist/NotificationServicesController/constants/index.js.map +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.ts.map +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.js.map +0 -1
- package/dist/NotificationServicesController/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/index.js +0 -13
- package/dist/NotificationServicesController/index.js.map +0 -1
- package/dist/NotificationServicesController/mocks/index.d.ts +0 -5
- package/dist/NotificationServicesController/mocks/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/mocks/index.js +0 -5
- package/dist/NotificationServicesController/mocks/index.js.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.ts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-feature-announcements.js.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.ts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-raw-notifications.js.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.d.ts.map +0 -1
- package/dist/NotificationServicesController/mocks/mock-snap-notification.js.map +0 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.ts.map +0 -1
- package/dist/NotificationServicesController/mocks/mockResponses.js.map +0 -1
- package/dist/NotificationServicesController/processors/index.d.ts +0 -4
- package/dist/NotificationServicesController/processors/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/processors/index.js +0 -4
- package/dist/NotificationServicesController/processors/index.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-api-notifications.d.ts.map +0 -1
- package/dist/NotificationServicesController/processors/process-api-notifications.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.ts.map +0 -1
- package/dist/NotificationServicesController/processors/process-feature-announcement.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.ts.map +0 -1
- package/dist/NotificationServicesController/processors/process-notifications.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.ts.map +0 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.js.map +0 -1
- package/dist/NotificationServicesController/services/api-notifications.d.ts.map +0 -1
- package/dist/NotificationServicesController/services/api-notifications.js.map +0 -1
- package/dist/NotificationServicesController/services/feature-announcements.d.ts.map +0 -1
- package/dist/NotificationServicesController/services/feature-announcements.js.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.d.ts.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.js.map +0 -1
- package/dist/NotificationServicesController/services/perp-notifications.d.ts.map +0 -1
- package/dist/NotificationServicesController/services/perp-notifications.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/index.d.ts +0 -4
- package/dist/NotificationServicesController/types/feature-announcement/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/index.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/index.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/type-links.js.map +0 -1
- package/dist/NotificationServicesController/types/index.d.ts +0 -6
- package/dist/NotificationServicesController/types/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/index.js +0 -2
- package/dist/NotificationServicesController/types/index.js.map +0 -1
- package/dist/NotificationServicesController/types/notification/index.d.ts +0 -2
- package/dist/NotificationServicesController/types/notification/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/notification/index.js +0 -2
- package/dist/NotificationServicesController/types/notification/index.js.map +0 -1
- package/dist/NotificationServicesController/types/notification/notification.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/notification/notification.js +0 -2
- package/dist/NotificationServicesController/types/notification/notification.js.map +0 -1
- package/dist/NotificationServicesController/types/notification-api/index.d.ts +0 -3
- package/dist/NotificationServicesController/types/notification-api/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/notification-api/index.js +0 -2
- package/dist/NotificationServicesController/types/notification-api/index.js.map +0 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.js +0 -2
- package/dist/NotificationServicesController/types/notification-api/notification-api.js.map +0 -1
- package/dist/NotificationServicesController/types/notification-api/schema.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/notification-api/schema.js.map +0 -1
- package/dist/NotificationServicesController/types/perps/index.d.ts +0 -2
- package/dist/NotificationServicesController/types/perps/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/perps/index.js +0 -2
- package/dist/NotificationServicesController/types/perps/index.js.map +0 -1
- package/dist/NotificationServicesController/types/perps/perp-types.d.ts +0 -3
- package/dist/NotificationServicesController/types/perps/perp-types.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/perps/perp-types.js +0 -2
- package/dist/NotificationServicesController/types/perps/perp-types.js.map +0 -1
- package/dist/NotificationServicesController/types/perps/schema.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/perps/schema.js.map +0 -1
- package/dist/NotificationServicesController/types/snaps/index.d.ts +0 -2
- package/dist/NotificationServicesController/types/snaps/index.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/snaps/index.js +0 -2
- package/dist/NotificationServicesController/types/snaps/index.js.map +0 -1
- package/dist/NotificationServicesController/types/snaps/snaps.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/snaps/snaps.js +0 -2
- package/dist/NotificationServicesController/types/snaps/snaps.js.map +0 -1
- package/dist/NotificationServicesController/types/type-utils.d.ts.map +0 -1
- package/dist/NotificationServicesController/types/type-utils.js +0 -2
- package/dist/NotificationServicesController/types/type-utils.js.map +0 -1
- package/dist/NotificationServicesController/utils/get-notification-subtype.d.ts.map +0 -1
- package/dist/NotificationServicesController/utils/get-notification-subtype.js.map +0 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.ts.map +0 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.js.map +0 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.d.ts.map +0 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.js.map +0 -1
- package/dist/NotificationServicesController/utils/utils.d.ts.map +0 -1
- package/dist/NotificationServicesController/utils/utils.js.map +0 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.js.map +0 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.js.map +0 -1
- package/dist/NotificationServicesPushController/index.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/index.js +0 -8
- package/dist/NotificationServicesPushController/index.js.map +0 -1
- package/dist/NotificationServicesPushController/mocks/index.d.ts +0 -2
- package/dist/NotificationServicesPushController/mocks/index.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/mocks/index.js +0 -2
- package/dist/NotificationServicesPushController/mocks/index.js.map +0 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.js.map +0 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/services/endpoints.js.map +0 -1
- package/dist/NotificationServicesPushController/services/services.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/services/services.js.map +0 -1
- package/dist/NotificationServicesPushController/types/firebase.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/types/firebase.js +0 -2
- package/dist/NotificationServicesPushController/types/firebase.js.map +0 -1
- package/dist/NotificationServicesPushController/types/index.d.ts +0 -4
- package/dist/NotificationServicesPushController/types/index.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/types/index.js +0 -2
- package/dist/NotificationServicesPushController/types/index.js.map +0 -1
- package/dist/NotificationServicesPushController/types/push-analytics.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/types/push-analytics.js.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.js +0 -2
- package/dist/NotificationServicesPushController/types/push-service-interface.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/index.d.ts +0 -4
- package/dist/NotificationServicesPushController/utils/index.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/utils/index.js +0 -4
- package/dist/NotificationServicesPushController/utils/index.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/utils/to-push-analytics-payload.js.map +0 -1
- package/dist/NotificationServicesPushController/web/index.d.ts +0 -2
- package/dist/NotificationServicesPushController/web/index.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/web/index.js +0 -2
- package/dist/NotificationServicesPushController/web/index.js.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.ts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/index.js +0 -4
- package/dist/shared/index.js.map +0 -1
- package/dist/shared/is-onchain-notification.d.ts.map +0 -1
- package/dist/shared/is-onchain-notification.js.map +0 -1
- package/dist/shared/notification-api-type-guards.d.ts.map +0 -1
- package/dist/shared/notification-api-type-guards.js.map +0 -1
- package/dist/shared/to-raw-notification.d.ts.map +0 -1
- package/dist/shared/to-raw-notification.js.map +0 -1
|
@@ -0,0 +1,1055 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_locale, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_env, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getBearerToken, _NotificationServicesController_registerWalletActivityAddresses, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.NotificationServicesController = exports.DEFAULT_PRICE_ALERT_PREFERENCES = exports.DEFAULT_AGENTIC_CLI_PREFERENCES = exports.DEFAULT_SOCIAL_AI_PREFERENCES = exports.DEFAULT_PERPS_PREFERENCES = exports.defaultState = exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = void 0;
|
|
19
|
+
const authenticated_user_storage_1 = require("@metamask/authenticated-user-storage");
|
|
20
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
21
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
22
|
+
const utils_1 = require("@metamask/utils");
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
25
|
+
const notification_schema_js_1 = require("./constants/notification-schema.cjs");
|
|
26
|
+
const process_notifications_js_1 = require("./processors/process-notifications.cjs");
|
|
27
|
+
const api_notifications_js_1 = require("./services/api-notifications.cjs");
|
|
28
|
+
const feature_announcements_js_1 = require("./services/feature-announcements.cjs");
|
|
29
|
+
const perp_notifications_js_1 = require("./services/perp-notifications.cjs");
|
|
30
|
+
// Unique name for the controller
|
|
31
|
+
const controllerName = 'NotificationServicesController';
|
|
32
|
+
exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = 1000;
|
|
33
|
+
const metadata = {
|
|
34
|
+
subscriptionAccountsSeen: {
|
|
35
|
+
includeInStateLogs: true,
|
|
36
|
+
persist: true,
|
|
37
|
+
includeInDebugSnapshot: true,
|
|
38
|
+
usedInUi: true,
|
|
39
|
+
},
|
|
40
|
+
isMetamaskNotificationsFeatureSeen: {
|
|
41
|
+
includeInStateLogs: true,
|
|
42
|
+
persist: true,
|
|
43
|
+
includeInDebugSnapshot: false,
|
|
44
|
+
usedInUi: true,
|
|
45
|
+
},
|
|
46
|
+
isNotificationServicesEnabled: {
|
|
47
|
+
includeInStateLogs: true,
|
|
48
|
+
persist: true,
|
|
49
|
+
includeInDebugSnapshot: false,
|
|
50
|
+
usedInUi: true,
|
|
51
|
+
},
|
|
52
|
+
isFeatureAnnouncementsEnabled: {
|
|
53
|
+
includeInStateLogs: true,
|
|
54
|
+
persist: true,
|
|
55
|
+
includeInDebugSnapshot: false,
|
|
56
|
+
usedInUi: true,
|
|
57
|
+
},
|
|
58
|
+
metamaskNotificationsList: {
|
|
59
|
+
includeInStateLogs: true,
|
|
60
|
+
persist: true,
|
|
61
|
+
includeInDebugSnapshot: true,
|
|
62
|
+
usedInUi: true,
|
|
63
|
+
},
|
|
64
|
+
metamaskNotificationsReadList: {
|
|
65
|
+
includeInStateLogs: false,
|
|
66
|
+
persist: true,
|
|
67
|
+
includeInDebugSnapshot: true,
|
|
68
|
+
usedInUi: true,
|
|
69
|
+
},
|
|
70
|
+
isUpdatingMetamaskNotifications: {
|
|
71
|
+
includeInStateLogs: false,
|
|
72
|
+
persist: false,
|
|
73
|
+
includeInDebugSnapshot: false,
|
|
74
|
+
usedInUi: true,
|
|
75
|
+
},
|
|
76
|
+
isFetchingMetamaskNotifications: {
|
|
77
|
+
includeInStateLogs: false,
|
|
78
|
+
persist: false,
|
|
79
|
+
includeInDebugSnapshot: false,
|
|
80
|
+
usedInUi: true,
|
|
81
|
+
},
|
|
82
|
+
isUpdatingMetamaskNotificationsAccount: {
|
|
83
|
+
includeInStateLogs: false,
|
|
84
|
+
persist: false,
|
|
85
|
+
includeInDebugSnapshot: false,
|
|
86
|
+
usedInUi: true,
|
|
87
|
+
},
|
|
88
|
+
isCheckingAccountsPresence: {
|
|
89
|
+
includeInStateLogs: false,
|
|
90
|
+
persist: false,
|
|
91
|
+
includeInDebugSnapshot: false,
|
|
92
|
+
usedInUi: true,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
exports.defaultState = {
|
|
96
|
+
subscriptionAccountsSeen: [],
|
|
97
|
+
isMetamaskNotificationsFeatureSeen: false,
|
|
98
|
+
isNotificationServicesEnabled: false,
|
|
99
|
+
isFeatureAnnouncementsEnabled: false,
|
|
100
|
+
metamaskNotificationsList: [],
|
|
101
|
+
metamaskNotificationsReadList: [],
|
|
102
|
+
isUpdatingMetamaskNotifications: false,
|
|
103
|
+
isFetchingMetamaskNotifications: false,
|
|
104
|
+
isUpdatingMetamaskNotificationsAccount: [],
|
|
105
|
+
isCheckingAccountsPresence: false,
|
|
106
|
+
};
|
|
107
|
+
const locallyPersistedNotificationTypes = new Set([
|
|
108
|
+
notification_schema_js_1.TRIGGER_TYPES.SNAP,
|
|
109
|
+
]);
|
|
110
|
+
/**
|
|
111
|
+
* Hardcoded default Perps notification preferences. Applied when notification
|
|
112
|
+
* preferences are initialized for the first time.
|
|
113
|
+
*/
|
|
114
|
+
exports.DEFAULT_PERPS_PREFERENCES = {
|
|
115
|
+
inAppNotificationsEnabled: true,
|
|
116
|
+
pushNotificationsEnabled: true,
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Hardcoded default Social AI notification preferences. Applied when
|
|
120
|
+
* notification preferences are initialized for the first time.
|
|
121
|
+
*/
|
|
122
|
+
exports.DEFAULT_SOCIAL_AI_PREFERENCES = {
|
|
123
|
+
inAppNotificationsEnabled: true,
|
|
124
|
+
pushNotificationsEnabled: true,
|
|
125
|
+
txAmountLimit: 500,
|
|
126
|
+
mutedTraderProfileIds: [],
|
|
127
|
+
};
|
|
128
|
+
var authenticated_user_storage_2 = require("@metamask/authenticated-user-storage");
|
|
129
|
+
Object.defineProperty(exports, "DEFAULT_AGENTIC_CLI_PREFERENCES", { enumerable: true, get: function () { return authenticated_user_storage_2.DEFAULT_AGENTIC_CLI_PREFERENCES; } });
|
|
130
|
+
Object.defineProperty(exports, "DEFAULT_PRICE_ALERT_PREFERENCES", { enumerable: true, get: function () { return authenticated_user_storage_2.DEFAULT_PRICE_ALERT_PREFERENCES; } });
|
|
131
|
+
/**
|
|
132
|
+
* Builds wallet-activity preferences from the keyring's current accounts.
|
|
133
|
+
*
|
|
134
|
+
* @param accounts - The keyring accounts to build wallet-activity entries for.
|
|
135
|
+
* @returns An array of wallet-activity account entries (lower-cased addresses).
|
|
136
|
+
*/
|
|
137
|
+
const buildWalletActivityAccounts = (accounts) => accounts.map(({ address, enabled }) => {
|
|
138
|
+
const lowercased = address.toLowerCase();
|
|
139
|
+
return {
|
|
140
|
+
address: lowercased,
|
|
141
|
+
enabled,
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* Builds wallet-activity initialization from the Trigger API. If Trigger has no
|
|
146
|
+
* enabled entries for the current keyring accounts, this is a first-time
|
|
147
|
+
* notification setup and all current accounts should start enabled.
|
|
148
|
+
*
|
|
149
|
+
* @param bearerToken - JWT used to query Trigger API.
|
|
150
|
+
* @param accounts - The keyring accounts to initialize.
|
|
151
|
+
* @param env - The environment to use for the Trigger API call.
|
|
152
|
+
* @returns Wallet-activity account initialization entries.
|
|
153
|
+
*/
|
|
154
|
+
const buildWalletActivityAccountsFromTriggerConfig = async (bearerToken, accounts, env) => {
|
|
155
|
+
const triggerConfig = await (0, api_notifications_js_1.getNotificationsApiConfigCached)(bearerToken, accounts, env);
|
|
156
|
+
const triggerConfigByAddress = new Map(triggerConfig.map(({ address, enabled }) => [
|
|
157
|
+
address.toLowerCase(),
|
|
158
|
+
enabled,
|
|
159
|
+
]));
|
|
160
|
+
const hasEnabledTriggerAccount = accounts.some((address) => triggerConfigByAddress.get(address.toLowerCase()) === true);
|
|
161
|
+
return accounts.map((address) => ({
|
|
162
|
+
address,
|
|
163
|
+
enabled: hasEnabledTriggerAccount
|
|
164
|
+
? (triggerConfigByAddress.get(address.toLowerCase()) ?? false)
|
|
165
|
+
: true,
|
|
166
|
+
}));
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Builds a fresh `NotificationPreferences` blob using hardcoded defaults for
|
|
170
|
+
* Perps, Social AI, and Agentic CLI, the supplied wallet-activity accounts and
|
|
171
|
+
* the user's marketing/product-announcement flags.
|
|
172
|
+
*
|
|
173
|
+
* @param walletActivityAccounts - The wallet-activity account config to initialize.
|
|
174
|
+
* @param hasMarketingConsent - Whether marketing push notifications should be enabled.
|
|
175
|
+
* @param productAnnouncementEnabled - Whether marketing in-app notifications should be enabled.
|
|
176
|
+
* @returns A complete `NotificationPreferences` object.
|
|
177
|
+
*/
|
|
178
|
+
const buildFreshPreferences = (walletActivityAccounts, hasMarketingConsent, productAnnouncementEnabled) => ({
|
|
179
|
+
walletActivity: {
|
|
180
|
+
inAppNotificationsEnabled: true,
|
|
181
|
+
pushNotificationsEnabled: true,
|
|
182
|
+
accounts: buildWalletActivityAccounts(walletActivityAccounts),
|
|
183
|
+
},
|
|
184
|
+
marketing: {
|
|
185
|
+
inAppNotificationsEnabled: productAnnouncementEnabled,
|
|
186
|
+
pushNotificationsEnabled: hasMarketingConsent,
|
|
187
|
+
},
|
|
188
|
+
perps: { ...exports.DEFAULT_PERPS_PREFERENCES },
|
|
189
|
+
socialAI: { ...exports.DEFAULT_SOCIAL_AI_PREFERENCES },
|
|
190
|
+
agenticCli: { ...authenticated_user_storage_1.DEFAULT_AGENTIC_CLI_PREFERENCES },
|
|
191
|
+
priceAlerts: { ...authenticated_user_storage_1.DEFAULT_PRICE_ALERT_PREFERENCES },
|
|
192
|
+
});
|
|
193
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
194
|
+
'init',
|
|
195
|
+
'enablePushNotifications',
|
|
196
|
+
'disablePushNotifications',
|
|
197
|
+
'checkAccountsPresence',
|
|
198
|
+
'setFeatureAnnouncementsEnabled',
|
|
199
|
+
'createOnChainTriggers',
|
|
200
|
+
'enableMetamaskNotifications',
|
|
201
|
+
'disableNotificationServices',
|
|
202
|
+
'disableAccounts',
|
|
203
|
+
'enableAccounts',
|
|
204
|
+
'fetchAndUpdateMetamaskNotifications',
|
|
205
|
+
'getNotificationsByType',
|
|
206
|
+
'deleteNotificationById',
|
|
207
|
+
'deleteNotificationsById',
|
|
208
|
+
'markMetamaskNotificationsAsRead',
|
|
209
|
+
'updateMetamaskNotificationsList',
|
|
210
|
+
'sendPerpPlaceOrderNotification',
|
|
211
|
+
];
|
|
212
|
+
/**
|
|
213
|
+
* Controller that enables wallet notifications and feature announcements
|
|
214
|
+
*/
|
|
215
|
+
class NotificationServicesController extends base_controller_1.BaseController {
|
|
216
|
+
/**
|
|
217
|
+
* Creates a NotificationServicesController instance.
|
|
218
|
+
*
|
|
219
|
+
* @param args - The arguments to this function.
|
|
220
|
+
* @param args.messenger - Messenger used to communicate with BaseV2 controller.
|
|
221
|
+
* @param args.state - Initial state to set on this controller.
|
|
222
|
+
* @param args.env - environment variables for a given controller.
|
|
223
|
+
* @param args.env.featureAnnouncements - env variables for feature announcements.
|
|
224
|
+
* @param args.env.locale - users locale for better dynamic server notifications
|
|
225
|
+
* @param args.env.env - the environment to use for the controller
|
|
226
|
+
*/
|
|
227
|
+
constructor({ messenger, state, env, }) {
|
|
228
|
+
super({
|
|
229
|
+
messenger,
|
|
230
|
+
metadata,
|
|
231
|
+
name: controllerName,
|
|
232
|
+
state: { ...exports.defaultState, ...state },
|
|
233
|
+
});
|
|
234
|
+
_NotificationServicesController_instances.add(this);
|
|
235
|
+
_NotificationServicesController_keyringController.set(this, {
|
|
236
|
+
isUnlocked: false,
|
|
237
|
+
setupLockedStateSubscriptions: (onUnlock) => {
|
|
238
|
+
const { isUnlocked } = this.messenger.call('KeyringController:getState');
|
|
239
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = isUnlocked;
|
|
240
|
+
this.messenger.subscribe('KeyringController:unlock', () => {
|
|
241
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = true;
|
|
242
|
+
// messaging system cannot await promises
|
|
243
|
+
// we don't need to wait for a result on this.
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
245
|
+
onUnlock();
|
|
246
|
+
});
|
|
247
|
+
this.messenger.subscribe('KeyringController:lock', () => {
|
|
248
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked = false;
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
_NotificationServicesController_auth.set(this, {
|
|
253
|
+
getBearerToken: async () => {
|
|
254
|
+
return await this.messenger.call('AuthenticationController:getBearerToken');
|
|
255
|
+
},
|
|
256
|
+
isSignedIn: () => {
|
|
257
|
+
return this.messenger.call('AuthenticationController:isSignedIn');
|
|
258
|
+
},
|
|
259
|
+
signIn: async () => {
|
|
260
|
+
return await this.messenger.call('AuthenticationController:performSignIn');
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
_NotificationServicesController_pushNotifications.set(this, {
|
|
264
|
+
// Flag to check is notifications have been setup when the browser/extension is initialized.
|
|
265
|
+
// We want to re-initialize push notifications when the browser/extension is refreshed
|
|
266
|
+
// To ensure we subscribe to the most up-to-date notifications
|
|
267
|
+
isSetup: false,
|
|
268
|
+
subscribeToPushNotifications: async () => {
|
|
269
|
+
await this.messenger.call('NotificationServicesPushController:subscribeToPushNotifications');
|
|
270
|
+
},
|
|
271
|
+
enablePushNotifications: async (addresses) => {
|
|
272
|
+
try {
|
|
273
|
+
await this.messenger.call('NotificationServicesPushController:enablePushNotifications', addresses);
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Do nothing, failing silently.
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
addPushNotificationLinks: async (addresses) => {
|
|
280
|
+
try {
|
|
281
|
+
await this.messenger.call('NotificationServicesPushController:addPushNotificationLinks', addresses);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// Do nothing, failing silently.
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
disablePushNotifications: async () => {
|
|
288
|
+
try {
|
|
289
|
+
await this.messenger.call('NotificationServicesPushController:disablePushNotifications');
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
// Do nothing, failing silently.
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
deletePushNotificationLinks: async (addresses) => {
|
|
296
|
+
try {
|
|
297
|
+
await this.messenger.call('NotificationServicesPushController:deletePushNotificationLinks', addresses);
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
// Do nothing, failing silently.
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
subscribe: () => {
|
|
304
|
+
// Coalesce pushes: at most one fetch in-flight, one queued.
|
|
305
|
+
// Re-fetch after completion because the new row may not be visible yet when the push arrives.
|
|
306
|
+
let pushFetchInFlight = false;
|
|
307
|
+
let pendingPushRefetch = false;
|
|
308
|
+
const fetchOnPush = async () => {
|
|
309
|
+
pushFetchInFlight = true;
|
|
310
|
+
try {
|
|
311
|
+
await this.fetchAndUpdateMetamaskNotifications();
|
|
312
|
+
}
|
|
313
|
+
finally {
|
|
314
|
+
pushFetchInFlight = false;
|
|
315
|
+
if (pendingPushRefetch) {
|
|
316
|
+
pendingPushRefetch = false;
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
318
|
+
fetchOnPush();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
this.messenger.subscribe('NotificationServicesPushController:onNewNotifications', () => {
|
|
323
|
+
if (pushFetchInFlight) {
|
|
324
|
+
pendingPushRefetch = true;
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
328
|
+
fetchOnPush();
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
initializePushNotifications: async () => {
|
|
332
|
+
if (!this.state.isNotificationServicesEnabled) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").isSetup) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// If wallet is unlocked, we can create a fresh push subscription
|
|
339
|
+
// Otherwise we can subscribe to original subscription
|
|
340
|
+
try {
|
|
341
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked) {
|
|
342
|
+
throw new Error('Keyring is locked');
|
|
343
|
+
}
|
|
344
|
+
await this.enablePushNotifications();
|
|
345
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").isSetup = true;
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
349
|
+
.subscribeToPushNotifications()
|
|
350
|
+
.catch(() => {
|
|
351
|
+
// do nothing
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
_NotificationServicesController_accounts.set(this, {
|
|
357
|
+
// Flag to ensure we only setup once
|
|
358
|
+
isNotificationAccountsSetup: false,
|
|
359
|
+
getNotificationAccounts: () => {
|
|
360
|
+
const { keyrings } = this.messenger.call('KeyringController:getState');
|
|
361
|
+
const keyringAccounts = [
|
|
362
|
+
...new Set(keyrings
|
|
363
|
+
.flatMap((keyring) => keyring.accounts)
|
|
364
|
+
.map((address) => {
|
|
365
|
+
try {
|
|
366
|
+
return (0, controller_utils_1.toChecksumHexAddress)(address);
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
})
|
|
372
|
+
.filter((address) => address !== null && (0, controller_utils_1.isValidHexAddress)(address))),
|
|
373
|
+
];
|
|
374
|
+
return keyringAccounts.length > 0 ? keyringAccounts : null;
|
|
375
|
+
},
|
|
376
|
+
/**
|
|
377
|
+
* Used to get list of addresses from keyring (wallet addresses)
|
|
378
|
+
*
|
|
379
|
+
* @returns addresses removed, added, and latest list of addresses
|
|
380
|
+
*/
|
|
381
|
+
listAccounts: () => {
|
|
382
|
+
// Get previous and current account sets
|
|
383
|
+
const nonChecksumAccounts = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").getNotificationAccounts();
|
|
384
|
+
if (!nonChecksumAccounts) {
|
|
385
|
+
return {
|
|
386
|
+
accountsAdded: [],
|
|
387
|
+
accountsRemoved: [],
|
|
388
|
+
accounts: [],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const accounts = nonChecksumAccounts
|
|
392
|
+
.map((address) => (0, controller_utils_1.toChecksumHexAddress)(address))
|
|
393
|
+
.filter((address) => (0, controller_utils_1.isValidHexAddress)(address));
|
|
394
|
+
const currentAccountsSet = new Set(accounts);
|
|
395
|
+
const prevAccountsSet = new Set(this.state.subscriptionAccountsSeen);
|
|
396
|
+
// Invalid value you cannot have zero accounts
|
|
397
|
+
// Only occurs when the Accounts controller is initializing.
|
|
398
|
+
if (accounts.length === 0) {
|
|
399
|
+
return {
|
|
400
|
+
accountsAdded: [],
|
|
401
|
+
accountsRemoved: [],
|
|
402
|
+
accounts: [],
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
// Calculate added and removed addresses
|
|
406
|
+
const accountsAdded = accounts.filter((account) => !prevAccountsSet.has(account));
|
|
407
|
+
const accountsRemoved = [...prevAccountsSet.values()].filter((account) => !currentAccountsSet.has(account));
|
|
408
|
+
// Update accounts seen
|
|
409
|
+
this.update((state) => {
|
|
410
|
+
state.subscriptionAccountsSeen = [...currentAccountsSet];
|
|
411
|
+
});
|
|
412
|
+
return {
|
|
413
|
+
accountsAdded,
|
|
414
|
+
accountsRemoved,
|
|
415
|
+
accounts,
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
/**
|
|
419
|
+
* Initializes the cache/previous list. This is handy so we have an accurate in-mem state of the previous list of accounts.
|
|
420
|
+
*/
|
|
421
|
+
initialize: () => {
|
|
422
|
+
if (__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").isUnlocked &&
|
|
423
|
+
!__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup) {
|
|
424
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
425
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").isNotificationAccountsSetup = true;
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
/**
|
|
429
|
+
* Subscription to any state change in the keyring controller (aka wallet accounts).
|
|
430
|
+
* We can call the `listAccounts` defined above to find out about any accounts added, removed
|
|
431
|
+
* And call effects to subscribe/unsubscribe to notifications.
|
|
432
|
+
*/
|
|
433
|
+
subscribe: () => {
|
|
434
|
+
const debouncedUpdateAccountNotifications = (0, lodash_1.debounce)(async (totalAccounts, prevTotalAccounts) => {
|
|
435
|
+
const hasTotalAccountsChanged = totalAccounts !== prevTotalAccounts;
|
|
436
|
+
if (!this.state.isNotificationServicesEnabled ||
|
|
437
|
+
!hasTotalAccountsChanged) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const { accountsAdded, accountsRemoved } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
441
|
+
const promises = [];
|
|
442
|
+
if (accountsAdded.length > 0) {
|
|
443
|
+
promises.push(this.enableAccounts(accountsAdded));
|
|
444
|
+
}
|
|
445
|
+
if (accountsRemoved.length > 0) {
|
|
446
|
+
promises.push(this.disableAccounts(accountsRemoved));
|
|
447
|
+
}
|
|
448
|
+
await Promise.allSettled(promises);
|
|
449
|
+
}, exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS);
|
|
450
|
+
this.messenger.subscribe('KeyringController:stateChange',
|
|
451
|
+
// Using void return for async callback - result is intentionally ignored
|
|
452
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
453
|
+
debouncedUpdateAccountNotifications, (state) => {
|
|
454
|
+
return (state?.keyrings?.flatMap?.((keyring) => keyring.accounts)?.length ??
|
|
455
|
+
0);
|
|
456
|
+
});
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
_NotificationServicesController_locale.set(this, void 0);
|
|
460
|
+
_NotificationServicesController_featureAnnouncementEnv.set(this, void 0);
|
|
461
|
+
_NotificationServicesController_env.set(this, void 0);
|
|
462
|
+
__classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
|
|
463
|
+
__classPrivateFieldSet(this, _NotificationServicesController_locale, env.locale ?? (() => 'en'), "f");
|
|
464
|
+
__classPrivateFieldSet(this, _NotificationServicesController_env, env.env ?? 'prd', "f");
|
|
465
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
466
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
|
|
467
|
+
}
|
|
468
|
+
init() {
|
|
469
|
+
__classPrivateFieldGet(this, _NotificationServicesController_keyringController, "f").setupLockedStateSubscriptions(async () => {
|
|
470
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").initialize();
|
|
471
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").initializePushNotifications();
|
|
472
|
+
});
|
|
473
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").initialize();
|
|
474
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
475
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").initializePushNotifications();
|
|
476
|
+
__classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").subscribe();
|
|
477
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").subscribe();
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Public method to expose enabling push notifications
|
|
481
|
+
*/
|
|
482
|
+
async enablePushNotifications() {
|
|
483
|
+
try {
|
|
484
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
485
|
+
const enabledAddresses = (preferences?.walletActivity.accounts ?? [])
|
|
486
|
+
.filter((account) => account.enabled)
|
|
487
|
+
.map((account) => account.address);
|
|
488
|
+
if (enabledAddresses.length > 0) {
|
|
489
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(enabledAddresses);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
catch {
|
|
493
|
+
// Do nothing, failing silently.
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Public method to expose disabling push notifications
|
|
498
|
+
*/
|
|
499
|
+
async disablePushNotifications() {
|
|
500
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications();
|
|
501
|
+
}
|
|
502
|
+
async checkAccountsPresence(accounts) {
|
|
503
|
+
try {
|
|
504
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsCheckingAccountsPresence).call(this, true);
|
|
505
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
506
|
+
const enabledByAddress = new Map((preferences?.walletActivity.accounts ?? []).map((account) => [
|
|
507
|
+
account.address.toLowerCase(),
|
|
508
|
+
account.enabled,
|
|
509
|
+
]));
|
|
510
|
+
const result = {};
|
|
511
|
+
for (const address of accounts) {
|
|
512
|
+
result[address] = enabledByAddress.get(address.toLowerCase()) ?? false;
|
|
513
|
+
}
|
|
514
|
+
return result;
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
loglevel_1.default.error('Failed to check accounts presence', error);
|
|
518
|
+
throw error;
|
|
519
|
+
}
|
|
520
|
+
finally {
|
|
521
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsCheckingAccountsPresence).call(this, false);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Sets the enabled state of feature announcements.
|
|
526
|
+
*
|
|
527
|
+
* **Action** - used in the notification settings to enable/disable feature announcements.
|
|
528
|
+
*
|
|
529
|
+
* @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.
|
|
530
|
+
* @async
|
|
531
|
+
* @throws {Error} If fails to update
|
|
532
|
+
*/
|
|
533
|
+
async setFeatureAnnouncementsEnabled(featureAnnouncementsEnabled) {
|
|
534
|
+
try {
|
|
535
|
+
this.update((state) => {
|
|
536
|
+
state.isFeatureAnnouncementsEnabled = featureAnnouncementsEnabled;
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
loglevel_1.default.error('Unable to toggle feature announcements', error);
|
|
541
|
+
throw new Error('Unable to toggle feature announcements');
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* This creates/re-creates on-chain triggers defined in User Storage.
|
|
546
|
+
*
|
|
547
|
+
* **Action** - Used during Sign In / Enabling of notifications.
|
|
548
|
+
*
|
|
549
|
+
* Notification preferences are initialized only when
|
|
550
|
+
* {@link AuthenticatedUserStorageService} has no stored preferences yet.
|
|
551
|
+
* Existing preferences are left as-is.
|
|
552
|
+
*
|
|
553
|
+
* @param opts - optional options to mutate this functionality
|
|
554
|
+
* @param opts.hasMarketingConsent - The user's marketing-consent flag.
|
|
555
|
+
* Used only during initialization to seed marketing push notifications.
|
|
556
|
+
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
557
|
+
* Used only during initialization to seed marketing in-app notifications.
|
|
558
|
+
* @param opts.registerPushNotifications - Whether to attempt FCM/device push registration.
|
|
559
|
+
* @returns The updated or newly created user storage.
|
|
560
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
561
|
+
*/
|
|
562
|
+
async createOnChainTriggers(opts = {}) {
|
|
563
|
+
try {
|
|
564
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
565
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
566
|
+
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
567
|
+
// 1. Read existing AUS notification preferences and initialize only if absent.
|
|
568
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
569
|
+
const hasMarketingConsent = Boolean(opts?.hasMarketingConsent);
|
|
570
|
+
const productAnnouncementEnabled = Boolean(opts?.productAnnouncementEnabled);
|
|
571
|
+
let nextPreferences;
|
|
572
|
+
if (preferences === null) {
|
|
573
|
+
const walletActivityAccounts = await buildWalletActivityAccountsFromTriggerConfig(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
574
|
+
nextPreferences = buildFreshPreferences(walletActivityAccounts, hasMarketingConsent, productAnnouncementEnabled);
|
|
575
|
+
}
|
|
576
|
+
if (nextPreferences) {
|
|
577
|
+
await this.messenger.call('AuthenticatedUserStorageService:putNotificationPreferences', nextPreferences, __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform);
|
|
578
|
+
}
|
|
579
|
+
const effectivePreferences = nextPreferences ?? preferences;
|
|
580
|
+
const accountsWithNotifications = (effectivePreferences?.walletActivity.accounts ?? [])
|
|
581
|
+
.filter((account) => account.enabled)
|
|
582
|
+
.map((account) => account.address);
|
|
583
|
+
if (opts.registerPushNotifications ?? true) {
|
|
584
|
+
// Attempt FCM/device registration only; clients must request OS permission separately.
|
|
585
|
+
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
586
|
+
.enablePushNotifications(accountsWithNotifications)
|
|
587
|
+
.catch(() => {
|
|
588
|
+
// Do Nothing
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
// Update the state of the controller
|
|
592
|
+
this.update((state) => {
|
|
593
|
+
// User is re-subscribing (daily resub to get latest notifications)
|
|
594
|
+
if (state.isNotificationServicesEnabled) {
|
|
595
|
+
// Keep their existing preferences on re-subscribe
|
|
596
|
+
// No state updates needed - preserving user's current settings
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
// User is turning on notifications from a disabled state
|
|
600
|
+
state.isNotificationServicesEnabled = true;
|
|
601
|
+
state.isFeatureAnnouncementsEnabled = true;
|
|
602
|
+
state.isMetamaskNotificationsFeatureSeen = true;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
loglevel_1.default.error('Failed to create On Chain triggers', error);
|
|
608
|
+
throw new Error('Failed to create On Chain triggers');
|
|
609
|
+
}
|
|
610
|
+
finally {
|
|
611
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Enables all MetaMask notifications for the user.
|
|
616
|
+
* This is identical flow when initializing notifications for the first time.
|
|
617
|
+
*
|
|
618
|
+
* @param opts - Optional options to mutate this functionality.
|
|
619
|
+
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
620
|
+
*/
|
|
621
|
+
async enableMetamaskNotifications(opts = {}) {
|
|
622
|
+
try {
|
|
623
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
624
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
|
|
625
|
+
await this.createOnChainTriggers(opts);
|
|
626
|
+
}
|
|
627
|
+
catch (error) {
|
|
628
|
+
loglevel_1.default.error('Unable to enable notifications', error);
|
|
629
|
+
throw new Error('Unable to enable notifications');
|
|
630
|
+
}
|
|
631
|
+
finally {
|
|
632
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Disables all MetaMask notifications for the user.
|
|
637
|
+
* This method ensures that the user is authenticated, retrieves all linked accounts,
|
|
638
|
+
* and disables on-chain triggers for each account. It also sets the global notification
|
|
639
|
+
* settings for MetaMask, feature announcements to false.
|
|
640
|
+
*
|
|
641
|
+
* @throws {Error} If the user is not authenticated or if there is an error during the process.
|
|
642
|
+
*/
|
|
643
|
+
async disableNotificationServices() {
|
|
644
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
645
|
+
// Attempt Disable Push Notifications
|
|
646
|
+
try {
|
|
647
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").disablePushNotifications();
|
|
648
|
+
}
|
|
649
|
+
catch {
|
|
650
|
+
// Do nothing
|
|
651
|
+
}
|
|
652
|
+
// Update State: remove non-permitted notifications & disable flags
|
|
653
|
+
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === notification_schema_js_1.TRIGGER_TYPES.SNAP);
|
|
654
|
+
this.update((state) => {
|
|
655
|
+
state.isNotificationServicesEnabled = false;
|
|
656
|
+
state.isFeatureAnnouncementsEnabled = false;
|
|
657
|
+
// reassigning the notifications list with just snaps
|
|
658
|
+
// since the disable shouldn't affect snaps notifications
|
|
659
|
+
state.metamaskNotificationsList = snapNotifications;
|
|
660
|
+
});
|
|
661
|
+
// Finish Updating State
|
|
662
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, false);
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Deletes on-chain triggers associated with a specific account/s.
|
|
666
|
+
* This method performs several key operations:
|
|
667
|
+
* 1. Validates Auth
|
|
668
|
+
* 2. Deletes accounts
|
|
669
|
+
* (note) We do not need to look through push notifications as we've deleted triggers
|
|
670
|
+
*
|
|
671
|
+
* **Action** - When a user disables notifications for a given account in settings.
|
|
672
|
+
*
|
|
673
|
+
* @param accounts - The account for which on-chain triggers are to be deleted.
|
|
674
|
+
* @returns A promise that resolves to void or an object containing a success message.
|
|
675
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
676
|
+
*/
|
|
677
|
+
async disableAccounts(accounts) {
|
|
678
|
+
try {
|
|
679
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
680
|
+
// Sign-in gate.
|
|
681
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
682
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerWalletActivityAddresses).call(this, accounts.map((address) => ({ address, enabled: false })));
|
|
683
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").deletePushNotificationLinks(accounts);
|
|
684
|
+
}
|
|
685
|
+
catch {
|
|
686
|
+
throw new Error('Failed to delete OnChain triggers');
|
|
687
|
+
}
|
|
688
|
+
finally {
|
|
689
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearUpdatingAccountsState).call(this, accounts);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Updates/Creates on-chain triggers for a specific account.
|
|
694
|
+
*
|
|
695
|
+
* This method performs several key operations:
|
|
696
|
+
* 1. Validates Auth & Storage
|
|
697
|
+
* 2. Finds and creates any missing triggers associated with the account
|
|
698
|
+
* 3. Enables any related push notifications
|
|
699
|
+
* 4. Updates Storage to reflect new state.
|
|
700
|
+
*
|
|
701
|
+
* **Action** - When a user enables notifications for an account
|
|
702
|
+
*
|
|
703
|
+
* @param accounts - List of accounts you want to update.
|
|
704
|
+
* @returns A promise that resolves to the updated user storage.
|
|
705
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
706
|
+
*/
|
|
707
|
+
async enableAccounts(accounts) {
|
|
708
|
+
try {
|
|
709
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
710
|
+
// Sign-in gate.
|
|
711
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
712
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerWalletActivityAddresses).call(this, accounts.map((address) => ({ address, enabled: true })));
|
|
713
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").addPushNotificationLinks(accounts);
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
loglevel_1.default.error('Failed to update OnChain triggers', error);
|
|
717
|
+
throw new Error('Failed to update OnChain triggers');
|
|
718
|
+
}
|
|
719
|
+
finally {
|
|
720
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearUpdatingAccountsState).call(this, accounts);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Fetches the list of metamask notifications.
|
|
725
|
+
* This includes OnChain notifications; Feature Announcements; and Snap Notifications.
|
|
726
|
+
*
|
|
727
|
+
* **Action** - When a user views the notification list page/dropdown
|
|
728
|
+
*
|
|
729
|
+
* @param previewToken - the preview token to use if needed
|
|
730
|
+
* @returns A promise that resolves to the list of notifications.
|
|
731
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
732
|
+
*/
|
|
733
|
+
async fetchAndUpdateMetamaskNotifications(previewToken) {
|
|
734
|
+
try {
|
|
735
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, true);
|
|
736
|
+
// This is used by Feature Announcement & On Chain
|
|
737
|
+
// Not used by Snaps
|
|
738
|
+
const isGlobalNotifsEnabled = this.state.isNotificationServicesEnabled;
|
|
739
|
+
const notificationPreferences = isGlobalNotifsEnabled
|
|
740
|
+
? await this.messenger
|
|
741
|
+
.call('AuthenticatedUserStorageService:getNotificationPreferences')
|
|
742
|
+
.catch(() => null)
|
|
743
|
+
: null;
|
|
744
|
+
// Raw Feature Notifications
|
|
745
|
+
const rawAnnouncements = isGlobalNotifsEnabled &&
|
|
746
|
+
notificationPreferences?.marketing.inAppNotificationsEnabled
|
|
747
|
+
? await (0, feature_announcements_js_1.getFeatureAnnouncementNotifications)(__classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f"), previewToken).catch(() => [])
|
|
748
|
+
: [];
|
|
749
|
+
// Raw On Chain Notifications
|
|
750
|
+
const rawOnChainNotifications = [];
|
|
751
|
+
if (isGlobalNotifsEnabled) {
|
|
752
|
+
try {
|
|
753
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
754
|
+
const addressesWithNotifications = (notificationPreferences?.walletActivity.accounts ?? [])
|
|
755
|
+
.filter((account) => account.enabled)
|
|
756
|
+
.map((account) => account.address);
|
|
757
|
+
const notifications = await (0, api_notifications_js_1.getAPINotifications)(bearerToken, addressesWithNotifications, __classPrivateFieldGet(this, _NotificationServicesController_locale, "f").call(this), __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")).catch(() => []);
|
|
758
|
+
rawOnChainNotifications.push(...notifications);
|
|
759
|
+
}
|
|
760
|
+
catch {
|
|
761
|
+
// Do nothing
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
// Snap Notifications (original)
|
|
765
|
+
// We do not want to remove them
|
|
766
|
+
const snapNotifications = this.state.metamaskNotificationsList.filter((notification) => notification.type === notification_schema_js_1.TRIGGER_TYPES.SNAP);
|
|
767
|
+
const readIds = this.state.metamaskNotificationsReadList;
|
|
768
|
+
// Combine Notifications
|
|
769
|
+
const metamaskNotifications = [
|
|
770
|
+
...(0, process_notifications_js_1.processAndFilterNotifications)(rawAnnouncements, readIds),
|
|
771
|
+
...(0, process_notifications_js_1.processAndFilterNotifications)(rawOnChainNotifications, readIds),
|
|
772
|
+
...snapNotifications,
|
|
773
|
+
];
|
|
774
|
+
// Sort Notifications
|
|
775
|
+
metamaskNotifications.sort((notificationA, notificationB) => new Date(notificationB.createdAt).getTime() -
|
|
776
|
+
new Date(notificationA.createdAt).getTime());
|
|
777
|
+
// Update State
|
|
778
|
+
this.update((state) => {
|
|
779
|
+
state.metamaskNotificationsList = metamaskNotifications;
|
|
780
|
+
});
|
|
781
|
+
this.messenger.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
|
|
782
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
|
|
783
|
+
return metamaskNotifications;
|
|
784
|
+
}
|
|
785
|
+
catch (error) {
|
|
786
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsFetchingMetamaskNotifications).call(this, false);
|
|
787
|
+
loglevel_1.default.error('Failed to fetch notifications', error);
|
|
788
|
+
throw new Error('Failed to fetch notifications');
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Gets the specified type of notifications from state.
|
|
793
|
+
*
|
|
794
|
+
* @param type - The trigger type.
|
|
795
|
+
* @returns An array of notifications of the passed in type.
|
|
796
|
+
* @throws Throws an error if an invalid trigger type is passed.
|
|
797
|
+
*/
|
|
798
|
+
getNotificationsByType(type) {
|
|
799
|
+
(0, utils_1.assert)(Object.values(notification_schema_js_1.TRIGGER_TYPES).includes(type), 'Invalid trigger type.');
|
|
800
|
+
return this.state.metamaskNotificationsList.filter((notification) => notification.type === type);
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Used to delete a notification by id.
|
|
804
|
+
*
|
|
805
|
+
* Note: This function should only be used for notifications that are stored
|
|
806
|
+
* in this controller directly, currently only snaps notifications.
|
|
807
|
+
*
|
|
808
|
+
* @param id - The id of the notification to delete.
|
|
809
|
+
*/
|
|
810
|
+
async deleteNotificationById(id) {
|
|
811
|
+
const fetchedNotification = this.state.metamaskNotificationsList.find((notification) => notification.id === id);
|
|
812
|
+
(0, utils_1.assert)(fetchedNotification, 'The notification to be deleted does not exist.');
|
|
813
|
+
(0, utils_1.assert)(locallyPersistedNotificationTypes.has(fetchedNotification.type), `The notification type of "${
|
|
814
|
+
// notifications are guaranteed to have type properties which equate to strings
|
|
815
|
+
fetchedNotification.type}" is not locally persisted, only the following types can use this function: ${[
|
|
816
|
+
...locallyPersistedNotificationTypes,
|
|
817
|
+
].join(', ')}.`);
|
|
818
|
+
const newList = this.state.metamaskNotificationsList.filter((notification) => notification.id !== id);
|
|
819
|
+
this.update((state) => {
|
|
820
|
+
state.metamaskNotificationsList = newList;
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Used to batch delete notifications by id.
|
|
825
|
+
*
|
|
826
|
+
* Note: This function should only be used for notifications that are stored
|
|
827
|
+
* in this controller directly, currently only snaps notifications.
|
|
828
|
+
*
|
|
829
|
+
* @param ids - The ids of the notifications to delete.
|
|
830
|
+
*/
|
|
831
|
+
async deleteNotificationsById(ids) {
|
|
832
|
+
for (const id of ids) {
|
|
833
|
+
await this.deleteNotificationById(id);
|
|
834
|
+
}
|
|
835
|
+
this.messenger.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Marks specified metamask notifications as read.
|
|
839
|
+
*
|
|
840
|
+
* @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.
|
|
841
|
+
* @returns A promise that resolves when the operation is complete.
|
|
842
|
+
*/
|
|
843
|
+
async markMetamaskNotificationsAsRead(notifications) {
|
|
844
|
+
let onchainNotificationIds = [];
|
|
845
|
+
let featureAnnouncementNotificationIds = [];
|
|
846
|
+
let snapNotificationIds = [];
|
|
847
|
+
try {
|
|
848
|
+
const [onChainNotifications, featureAnnouncementNotifications, snapNotifications,] = notifications.reduce((allNotifications, notification) => {
|
|
849
|
+
if (!notification.isRead) {
|
|
850
|
+
switch (notification.type) {
|
|
851
|
+
case notification_schema_js_1.TRIGGER_TYPES.FEATURES_ANNOUNCEMENT:
|
|
852
|
+
allNotifications[1].push(notification);
|
|
853
|
+
break;
|
|
854
|
+
case notification_schema_js_1.TRIGGER_TYPES.SNAP:
|
|
855
|
+
allNotifications[2].push(notification);
|
|
856
|
+
break;
|
|
857
|
+
default:
|
|
858
|
+
allNotifications[0].push(notification);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return allNotifications;
|
|
862
|
+
}, [[], [], []]);
|
|
863
|
+
// Mark On-Chain Notifications as Read
|
|
864
|
+
if (onChainNotifications.length > 0) {
|
|
865
|
+
const bearerToken = await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").getBearerToken();
|
|
866
|
+
if (bearerToken) {
|
|
867
|
+
onchainNotificationIds = onChainNotifications.map((notification) => notification.id);
|
|
868
|
+
await (0, api_notifications_js_1.markNotificationsAsRead)(bearerToken, onchainNotificationIds, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")).catch(() => {
|
|
869
|
+
onchainNotificationIds = [];
|
|
870
|
+
loglevel_1.default.warn('Unable to mark onchain notifications as read');
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// Mark Off-Chain notifications as Read
|
|
875
|
+
if (featureAnnouncementNotifications.length > 0) {
|
|
876
|
+
featureAnnouncementNotificationIds =
|
|
877
|
+
featureAnnouncementNotifications.map((notification) => notification.id);
|
|
878
|
+
}
|
|
879
|
+
if (snapNotifications.length > 0) {
|
|
880
|
+
snapNotificationIds = snapNotifications.map((notification) => notification.id);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
catch (error) {
|
|
884
|
+
loglevel_1.default.warn('Something failed when marking notifications as read', error);
|
|
885
|
+
}
|
|
886
|
+
// Update the state (state is also used on counter & badge)
|
|
887
|
+
this.update((state) => {
|
|
888
|
+
const currentReadList = state.metamaskNotificationsReadList;
|
|
889
|
+
const newReadIds = [
|
|
890
|
+
...featureAnnouncementNotificationIds,
|
|
891
|
+
...snapNotificationIds,
|
|
892
|
+
];
|
|
893
|
+
state.metamaskNotificationsReadList = [
|
|
894
|
+
...new Set([...currentReadList, ...newReadIds]),
|
|
895
|
+
];
|
|
896
|
+
state.metamaskNotificationsList = state.metamaskNotificationsList.map((notification) => {
|
|
897
|
+
if (newReadIds.includes(notification.id) ||
|
|
898
|
+
onchainNotificationIds.includes(notification.id)) {
|
|
899
|
+
if (notification.type === notification_schema_js_1.TRIGGER_TYPES.SNAP) {
|
|
900
|
+
return {
|
|
901
|
+
...notification,
|
|
902
|
+
isRead: true,
|
|
903
|
+
readDate: new Date().toISOString(),
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
return { ...notification, isRead: true };
|
|
907
|
+
}
|
|
908
|
+
return notification;
|
|
909
|
+
});
|
|
910
|
+
});
|
|
911
|
+
this.messenger.publish(`${controllerName}:markNotificationsAsRead`, this.state.metamaskNotificationsList);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.
|
|
915
|
+
* This method ensures that the most recent notification is displayed first in the UI.
|
|
916
|
+
*
|
|
917
|
+
* @param notification - The new notification object to be added to the list.
|
|
918
|
+
* @returns A promise that resolves when the notification list has been successfully updated.
|
|
919
|
+
*/
|
|
920
|
+
async updateMetamaskNotificationsList(notification) {
|
|
921
|
+
if (this.state.metamaskNotificationsList.some((existingNotification) => existingNotification.id === notification.id)) {
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
const processedNotification = (0, process_notifications_js_1.safeProcessNotification)(notification);
|
|
925
|
+
if (processedNotification) {
|
|
926
|
+
this.update((state) => {
|
|
927
|
+
const existingNotificationIds = new Set(state.metamaskNotificationsList.map((existingNotification) => existingNotification.id));
|
|
928
|
+
// Add the new notification only if its ID is not already present in the list
|
|
929
|
+
if (!existingNotificationIds.has(processedNotification.id)) {
|
|
930
|
+
state.metamaskNotificationsList = [
|
|
931
|
+
processedNotification,
|
|
932
|
+
...state.metamaskNotificationsList,
|
|
933
|
+
];
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
this.messenger.publish(`${controllerName}:notificationsListUpdated`, this.state.metamaskNotificationsList);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Creates an perp order notification subscription.
|
|
941
|
+
* Requires notifications and auth to be enabled to start receiving this notifications
|
|
942
|
+
*
|
|
943
|
+
* @param input perp input
|
|
944
|
+
*/
|
|
945
|
+
async sendPerpPlaceOrderNotification(input) {
|
|
946
|
+
try {
|
|
947
|
+
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
948
|
+
await (0, perp_notifications_js_1.createPerpOrderNotification)(bearerToken, input);
|
|
949
|
+
}
|
|
950
|
+
catch {
|
|
951
|
+
// Do Nothing
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
exports.NotificationServicesController = NotificationServicesController;
|
|
956
|
+
_NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(), _NotificationServicesController_pushNotifications = new WeakMap(), _NotificationServicesController_accounts = new WeakMap(), _NotificationServicesController_locale = new WeakMap(), _NotificationServicesController_featureAnnouncementEnv = new WeakMap(), _NotificationServicesController_env = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_clearLoadingStates = function _NotificationServicesController_clearLoadingStates() {
|
|
957
|
+
this.update((state) => {
|
|
958
|
+
state.isUpdatingMetamaskNotifications = false;
|
|
959
|
+
state.isCheckingAccountsPresence = false;
|
|
960
|
+
state.isFetchingMetamaskNotifications = false;
|
|
961
|
+
state.isUpdatingMetamaskNotificationsAccount = [];
|
|
962
|
+
});
|
|
963
|
+
}, _NotificationServicesController_assertAuthEnabled = function _NotificationServicesController_assertAuthEnabled() {
|
|
964
|
+
if (!__classPrivateFieldGet(this, _NotificationServicesController_auth, "f").isSignedIn()) {
|
|
965
|
+
this.update((state) => {
|
|
966
|
+
state.isNotificationServicesEnabled = false;
|
|
967
|
+
});
|
|
968
|
+
throw new Error('User is not signed in.');
|
|
969
|
+
}
|
|
970
|
+
}, _NotificationServicesController_enableAuth = async function _NotificationServicesController_enableAuth() {
|
|
971
|
+
const isSignedIn = __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").isSignedIn();
|
|
972
|
+
if (!isSignedIn) {
|
|
973
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").signIn();
|
|
974
|
+
}
|
|
975
|
+
}, _NotificationServicesController_getBearerToken = async function _NotificationServicesController_getBearerToken() {
|
|
976
|
+
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_assertAuthEnabled).call(this);
|
|
977
|
+
const bearerToken = await __classPrivateFieldGet(this, _NotificationServicesController_auth, "f").getBearerToken();
|
|
978
|
+
if (!bearerToken) {
|
|
979
|
+
throw new Error('Missing BearerToken');
|
|
980
|
+
}
|
|
981
|
+
return { bearerToken };
|
|
982
|
+
}, _NotificationServicesController_registerWalletActivityAddresses =
|
|
983
|
+
/**
|
|
984
|
+
* Updates the `walletActivity.accounts` entries in the user's
|
|
985
|
+
* notification-preferences blob in {@link AuthenticatedUserStorageService}.
|
|
986
|
+
*
|
|
987
|
+
* `putNotificationPreferences` replaces the entire blob, so we read the
|
|
988
|
+
* current preferences, merge the supplied updates into
|
|
989
|
+
* `walletActivity.accounts`, and write the result back. This helper is only
|
|
990
|
+
* meant to be used for incremental updates (enable/disable individual
|
|
991
|
+
* accounts) after the preferences blob has already been initialized via
|
|
992
|
+
* {@link createOnChainTriggers}; callers should not rely on it to perform
|
|
993
|
+
* first-time initialization.
|
|
994
|
+
*
|
|
995
|
+
* @param updates - Addresses to register, each with the desired `enabled` flag
|
|
996
|
+
*/
|
|
997
|
+
async function _NotificationServicesController_registerWalletActivityAddresses(updates) {
|
|
998
|
+
if (updates.length === 0) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
const currentPreferences = await this.messenger
|
|
1002
|
+
.call('AuthenticatedUserStorageService:getNotificationPreferences')
|
|
1003
|
+
.catch((error) => {
|
|
1004
|
+
loglevel_1.default.error('Failed to get notification preferences. Re-initializing them instead.', error);
|
|
1005
|
+
// TODO: return null once validation error captured
|
|
1006
|
+
// return null;
|
|
1007
|
+
throw error;
|
|
1008
|
+
});
|
|
1009
|
+
if (!currentPreferences) {
|
|
1010
|
+
loglevel_1.default.warn('Preferences blob not yet initialized; run `createOnChainTriggers` first.');
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const accountsByAddress = new Map(currentPreferences.walletActivity.accounts.map((account) => [
|
|
1014
|
+
account.address.toLowerCase(),
|
|
1015
|
+
{ ...account, address: account.address.toLowerCase() },
|
|
1016
|
+
]));
|
|
1017
|
+
for (const update of updates) {
|
|
1018
|
+
const address = update.address.toLowerCase();
|
|
1019
|
+
accountsByAddress.set(address, { address, enabled: update.enabled });
|
|
1020
|
+
}
|
|
1021
|
+
const nextPreferences = {
|
|
1022
|
+
...currentPreferences,
|
|
1023
|
+
walletActivity: {
|
|
1024
|
+
...currentPreferences.walletActivity,
|
|
1025
|
+
accounts: [...accountsByAddress.values()],
|
|
1026
|
+
},
|
|
1027
|
+
};
|
|
1028
|
+
await this.messenger.call('AuthenticatedUserStorageService:putNotificationPreferences', nextPreferences, __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform);
|
|
1029
|
+
}, _NotificationServicesController_setIsUpdatingMetamaskNotifications = function _NotificationServicesController_setIsUpdatingMetamaskNotifications(isUpdatingMetamaskNotifications) {
|
|
1030
|
+
this.update((state) => {
|
|
1031
|
+
state.isUpdatingMetamaskNotifications = isUpdatingMetamaskNotifications;
|
|
1032
|
+
});
|
|
1033
|
+
}, _NotificationServicesController_setIsFetchingMetamaskNotifications = function _NotificationServicesController_setIsFetchingMetamaskNotifications(isFetchingMetamaskNotifications) {
|
|
1034
|
+
this.update((state) => {
|
|
1035
|
+
state.isFetchingMetamaskNotifications = isFetchingMetamaskNotifications;
|
|
1036
|
+
});
|
|
1037
|
+
}, _NotificationServicesController_setIsCheckingAccountsPresence = function _NotificationServicesController_setIsCheckingAccountsPresence(isCheckingAccountsPresence) {
|
|
1038
|
+
this.update((state) => {
|
|
1039
|
+
state.isCheckingAccountsPresence = isCheckingAccountsPresence;
|
|
1040
|
+
});
|
|
1041
|
+
}, _NotificationServicesController_updateUpdatingAccountsState = function _NotificationServicesController_updateUpdatingAccountsState(accounts) {
|
|
1042
|
+
this.update((state) => {
|
|
1043
|
+
const uniqueAccounts = new Set([
|
|
1044
|
+
...state.isUpdatingMetamaskNotificationsAccount,
|
|
1045
|
+
...accounts,
|
|
1046
|
+
]);
|
|
1047
|
+
state.isUpdatingMetamaskNotificationsAccount = Array.from(uniqueAccounts);
|
|
1048
|
+
});
|
|
1049
|
+
}, _NotificationServicesController_clearUpdatingAccountsState = function _NotificationServicesController_clearUpdatingAccountsState(accounts) {
|
|
1050
|
+
this.update((state) => {
|
|
1051
|
+
state.isUpdatingMetamaskNotificationsAccount =
|
|
1052
|
+
state.isUpdatingMetamaskNotificationsAccount.filter((existingAccount) => !accounts.includes(existingAccount));
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
//# sourceMappingURL=NotificationServicesController.cjs.map
|