@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 @@
|
|
|
1
|
+
{"version":3,"file":"api-notifications.cjs","sourceRoot":"","sources":["../../../src/N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CAAC,EAC/C,MAAM,EACN,IAAI,CACL,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kBAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAzBD,0DAyBC","sourcesContent":["import log from 'loglevel';\n\nimport { toRawAPINotification } from '../../shared/to-raw-notification.js';\nimport type {\n NormalisedAPINotification,\n Schema,\n UnprocessedRawNotification,\n} from '../types/notification-api/index.js';\nimport { makeApiCall } from '../utils/utils.js';\nimport { notificationsConfigCache } from './notification-config-cache.js';\n\nexport type ENV = 'prd' | 'uat' | 'dev';\n\nconst TRIGGER_API_ENV = {\n dev: 'https://trigger.dev-api.cx.metamask.io',\n uat: 'https://trigger.uat-api.cx.metamask.io',\n prd: 'https://trigger.api.cx.metamask.io',\n} satisfies Record<ENV, string>;\n\nexport const TRIGGER_API = (env: ENV = 'prd'): string =>\n TRIGGER_API_ENV[env] ?? TRIGGER_API_ENV.prd;\n\nconst NOTIFICATION_API_ENV = {\n dev: 'https://notification.dev-api.cx.metamask.io',\n uat: 'https://notification.uat-api.cx.metamask.io',\n prd: 'https://notification.api.cx.metamask.io',\n};\n\nexport const NOTIFICATION_API = (env: ENV = 'prd'): string =>\n NOTIFICATION_API_ENV[env] ?? NOTIFICATION_API_ENV.prd;\n\n// Gets notification settings for each account provided\nexport const TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT = (\n env: ENV = 'prd',\n): string => `${TRIGGER_API(env)}/api/v2/notifications/query`;\n\n// Lists notifications for each address provided\nexport const NOTIFICATION_API_LIST_ENDPOINT = (env: ENV = 'prd'): string =>\n `${NOTIFICATION_API(env)}/api/v4/notifications`;\n\n// Marks notifications as read\nexport const NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT = (\n env: ENV = 'prd',\n): string => `${NOTIFICATION_API(env)}/api/v4/notifications/mark-as-read`;\n\n/**\n * fetches notification config (accounts enabled vs disabled)\n *\n * @param bearerToken - jwt\n * @param addresses - list of addresses to check\n * @param env - the environment to use for the API call\n * NOTE the API will return addresses config with false if they have not been created before.\n * NOTE this is cached for 1s to prevent multiple update calls\n * @returns object of notification config, or null if missing\n */\nexport async function getNotificationsApiConfigCached(\n bearerToken: string,\n addresses: string[],\n env: ENV = 'prd',\n): Promise<{ address: string; enabled: boolean }[]> {\n if (addresses.length === 0) {\n return [];\n }\n\n const normalizedAddresses = addresses.map((addr) => addr.toLowerCase());\n\n const cached = notificationsConfigCache.get(normalizedAddresses);\n if (cached) {\n return cached;\n }\n\n type RequestBody = { address: string }[];\n type Response = { address: string; enabled: boolean }[];\n const body: RequestBody = normalizedAddresses.map((address) => ({ address }));\n const apiResponse = await makeApiCall(\n bearerToken,\n TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT(env),\n 'POST',\n body,\n )\n .then<Response | null>((response) => (response.ok ? response.json() : null))\n .catch(() => null);\n\n const result = apiResponse ?? [];\n\n if (result.length > 0) {\n notificationsConfigCache.set(result);\n }\n\n return result;\n}\n\n/**\n * Fetches on-chain notifications for the given addresses\n *\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param addresses - List of addresses\n * @param locale - to generate translated notifications\n * @param platform - filter notifications for specific platforms ('extension' | 'mobile')\n * @param env - the environment to use for the API call\n * @returns An array of {@link NormalisedAPINotification}. Returns an empty array on transport or parse errors.\n */\nexport async function getAPINotifications(\n bearerToken: string,\n addresses: string[],\n locale: string,\n platform: 'extension' | 'mobile',\n env: ENV = 'prd',\n): Promise<NormalisedAPINotification[]> {\n if (addresses.length === 0) {\n return [];\n }\n\n type RequestBody =\n Schema.paths['/api/v4/notifications']['post']['requestBody']['content']['application/json'];\n type APIResponse =\n Schema.paths['/api/v4/notifications']['post']['responses']['200']['content']['application/json'];\n\n const body: RequestBody = {\n addresses: addresses.map((addr) => addr.toLowerCase()),\n locale,\n platform,\n };\n const notifications = await makeApiCall(\n bearerToken,\n NOTIFICATION_API_LIST_ENDPOINT(env),\n 'POST',\n body,\n )\n .then<APIResponse | null>((response) =>\n response.ok ? response.json() : null,\n )\n .catch(() => null);\n\n // Transform and sort notifications\n const transformedNotifications = notifications\n ?.map((notification): UnprocessedRawNotification | undefined => {\n if (!notification.notification_type) {\n return undefined;\n }\n\n try {\n return toRawAPINotification(notification);\n } catch {\n return undefined;\n }\n })\n .filter((item): item is NormalisedAPINotification => Boolean(item));\n\n return transformedNotifications ?? [];\n}\n\n/**\n * Marks the specified notifications as read.\n * This method sends a POST request to the notifications service to mark the provided notification IDs as read.\n * If the operation is successful, it completes without error. If the operation fails, it throws an error with details.\n *\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param notificationIds - An array of notification IDs to be marked as read.\n * @param env - the environment to use for the API call\n * @returns A promise that resolves to void. The promise will reject if there's an error during the API call or if the response status is not 200.\n */\nexport async function markNotificationsAsRead(\n bearerToken: string,\n notificationIds: string[],\n env: ENV = 'prd',\n): Promise<void> {\n if (notificationIds.length === 0) {\n return;\n }\n\n type ResponseBody =\n Schema.paths['/api/v4/notifications/mark-as-read']['post']['requestBody']['content']['application/json'];\n const body: ResponseBody = {\n ids: notificationIds,\n };\n\n try {\n await makeApiCall(\n bearerToken,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT(env),\n 'POST',\n body,\n );\n } catch (error) {\n log.error('Error marking notifications as read:', error);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NormalisedAPINotification } from
|
|
1
|
+
import type { NormalisedAPINotification } from "../types/notification-api/index.cjs";
|
|
2
2
|
export type ENV = 'prd' | 'uat' | 'dev';
|
|
3
3
|
export declare const TRIGGER_API: (env?: ENV) => string;
|
|
4
4
|
export declare const NOTIFICATION_API: (env?: ENV) => string;
|
|
@@ -41,4 +41,4 @@ export declare function getAPINotifications(bearerToken: string, addresses: stri
|
|
|
41
41
|
* @returns A promise that resolves to void. The promise will reject if there's an error during the API call or if the response status is not 200.
|
|
42
42
|
*/
|
|
43
43
|
export declare function markNotificationsAsRead(bearerToken: string, notificationIds: string[], env?: ENV): Promise<void>;
|
|
44
|
-
//# sourceMappingURL=api-notifications.d.
|
|
44
|
+
//# sourceMappingURL=api-notifications.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-notifications.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/api-notifications.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EAG1B,4CAA2C;AAI5C,MAAM,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAQxC,eAAO,MAAM,WAAW,SAAS,GAAG,KAAW,MACF,CAAC;AAQ9C,eAAO,MAAM,gBAAgB,SAAS,GAAG,KAAW,MACG,CAAC;AAGxD,eAAO,MAAM,wCAAwC,SAC9C,GAAG,KACP,MAA0D,CAAC;AAG9D,eAAO,MAAM,8BAA8B,SAAS,GAAG,KAAW,MACjB,CAAC;AAGlD,eAAO,MAAM,0CAA0C,SAChD,GAAG,KACP,MAAsE,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CACnD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,GAAE,GAAW,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,CAAC,CA+BlD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,EAChC,GAAG,GAAE,GAAW,GACf,OAAO,CAAC,yBAAyB,EAAE,CAAC,CA0CtC;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EAAE,EACzB,GAAG,GAAE,GAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { NormalisedAPINotification } from "../types/notification-api/index.mjs";
|
|
2
|
+
export type ENV = 'prd' | 'uat' | 'dev';
|
|
3
|
+
export declare const TRIGGER_API: (env?: ENV) => string;
|
|
4
|
+
export declare const NOTIFICATION_API: (env?: ENV) => string;
|
|
5
|
+
export declare const TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT: (env?: ENV) => string;
|
|
6
|
+
export declare const NOTIFICATION_API_LIST_ENDPOINT: (env?: ENV) => string;
|
|
7
|
+
export declare const NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT: (env?: ENV) => string;
|
|
8
|
+
/**
|
|
9
|
+
* fetches notification config (accounts enabled vs disabled)
|
|
10
|
+
*
|
|
11
|
+
* @param bearerToken - jwt
|
|
12
|
+
* @param addresses - list of addresses to check
|
|
13
|
+
* @param env - the environment to use for the API call
|
|
14
|
+
* NOTE the API will return addresses config with false if they have not been created before.
|
|
15
|
+
* NOTE this is cached for 1s to prevent multiple update calls
|
|
16
|
+
* @returns object of notification config, or null if missing
|
|
17
|
+
*/
|
|
18
|
+
export declare function getNotificationsApiConfigCached(bearerToken: string, addresses: string[], env?: ENV): Promise<{
|
|
19
|
+
address: string;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
}[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Fetches on-chain notifications for the given addresses
|
|
24
|
+
*
|
|
25
|
+
* @param bearerToken - The JSON Web Token used for authentication in the API call.
|
|
26
|
+
* @param addresses - List of addresses
|
|
27
|
+
* @param locale - to generate translated notifications
|
|
28
|
+
* @param platform - filter notifications for specific platforms ('extension' | 'mobile')
|
|
29
|
+
* @param env - the environment to use for the API call
|
|
30
|
+
* @returns An array of {@link NormalisedAPINotification}. Returns an empty array on transport or parse errors.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAPINotifications(bearerToken: string, addresses: string[], locale: string, platform: 'extension' | 'mobile', env?: ENV): Promise<NormalisedAPINotification[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Marks the specified notifications as read.
|
|
35
|
+
* This method sends a POST request to the notifications service to mark the provided notification IDs as read.
|
|
36
|
+
* If the operation is successful, it completes without error. If the operation fails, it throws an error with details.
|
|
37
|
+
*
|
|
38
|
+
* @param bearerToken - The JSON Web Token used for authentication in the API call.
|
|
39
|
+
* @param notificationIds - An array of notification IDs to be marked as read.
|
|
40
|
+
* @param env - the environment to use for the API call
|
|
41
|
+
* @returns A promise that resolves to void. The promise will reject if there's an error during the API call or if the response status is not 200.
|
|
42
|
+
*/
|
|
43
|
+
export declare function markNotificationsAsRead(bearerToken: string, notificationIds: string[], env?: ENV): Promise<void>;
|
|
44
|
+
//# sourceMappingURL=api-notifications.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/api-notifications.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EAG1B,4CAA2C;AAI5C,MAAM,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAQxC,eAAO,MAAM,WAAW,SAAS,GAAG,KAAW,MACF,CAAC;AAQ9C,eAAO,MAAM,gBAAgB,SAAS,GAAG,KAAW,MACG,CAAC;AAGxD,eAAO,MAAM,wCAAwC,SAC9C,GAAG,KACP,MAA0D,CAAC;AAG9D,eAAO,MAAM,8BAA8B,SAAS,GAAG,KAAW,MACjB,CAAC;AAGlD,eAAO,MAAM,0CAA0C,SAChD,GAAG,KACP,MAAsE,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CACnD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,GAAE,GAAW,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,CAAC,CA+BlD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,EAChC,GAAG,GAAE,GAAW,GACf,OAAO,CAAC,yBAAyB,EAAE,CAAC,CA0CtC;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EAAE,EACzB,GAAG,GAAE,GAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
package/dist/NotificationServicesController/services/{api-notifications.js → api-notifications.mjs}
RENAMED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function $importDefault(module) {
|
|
2
|
+
if (module?.__esModule) {
|
|
3
|
+
return module.default;
|
|
4
|
+
}
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
import $log from "loglevel";
|
|
8
|
+
const log = $importDefault($log);
|
|
9
|
+
import { toRawAPINotification } from "../../shared/to-raw-notification.mjs";
|
|
10
|
+
import { makeApiCall } from "../utils/utils.mjs";
|
|
11
|
+
import { notificationsConfigCache } from "./notification-config-cache.mjs";
|
|
5
12
|
const TRIGGER_API_ENV = {
|
|
6
13
|
dev: 'https://trigger.dev-api.cx.metamask.io',
|
|
7
14
|
uat: 'https://trigger.uat-api.cx.metamask.io',
|
|
@@ -111,4 +118,4 @@ export async function markNotificationsAsRead(bearerToken, notificationIds, env
|
|
|
111
118
|
log.error('Error marking notifications as read:', error);
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
|
-
//# sourceMappingURL=api-notifications.
|
|
121
|
+
//# sourceMappingURL=api-notifications.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-notifications.mjs","sourceRoot":"","sources":["../../../src/Not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AAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import log from 'loglevel';\n\nimport { toRawAPINotification } from '../../shared/to-raw-notification.js';\nimport type {\n NormalisedAPINotification,\n Schema,\n UnprocessedRawNotification,\n} from '../types/notification-api/index.js';\nimport { makeApiCall } from '../utils/utils.js';\nimport { notificationsConfigCache } from './notification-config-cache.js';\n\nexport type ENV = 'prd' | 'uat' | 'dev';\n\nconst TRIGGER_API_ENV = {\n dev: 'https://trigger.dev-api.cx.metamask.io',\n uat: 'https://trigger.uat-api.cx.metamask.io',\n prd: 'https://trigger.api.cx.metamask.io',\n} satisfies Record<ENV, string>;\n\nexport const TRIGGER_API = (env: ENV = 'prd'): string =>\n TRIGGER_API_ENV[env] ?? TRIGGER_API_ENV.prd;\n\nconst NOTIFICATION_API_ENV = {\n dev: 'https://notification.dev-api.cx.metamask.io',\n uat: 'https://notification.uat-api.cx.metamask.io',\n prd: 'https://notification.api.cx.metamask.io',\n};\n\nexport const NOTIFICATION_API = (env: ENV = 'prd'): string =>\n NOTIFICATION_API_ENV[env] ?? NOTIFICATION_API_ENV.prd;\n\n// Gets notification settings for each account provided\nexport const TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT = (\n env: ENV = 'prd',\n): string => `${TRIGGER_API(env)}/api/v2/notifications/query`;\n\n// Lists notifications for each address provided\nexport const NOTIFICATION_API_LIST_ENDPOINT = (env: ENV = 'prd'): string =>\n `${NOTIFICATION_API(env)}/api/v4/notifications`;\n\n// Marks notifications as read\nexport const NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT = (\n env: ENV = 'prd',\n): string => `${NOTIFICATION_API(env)}/api/v4/notifications/mark-as-read`;\n\n/**\n * fetches notification config (accounts enabled vs disabled)\n *\n * @param bearerToken - jwt\n * @param addresses - list of addresses to check\n * @param env - the environment to use for the API call\n * NOTE the API will return addresses config with false if they have not been created before.\n * NOTE this is cached for 1s to prevent multiple update calls\n * @returns object of notification config, or null if missing\n */\nexport async function getNotificationsApiConfigCached(\n bearerToken: string,\n addresses: string[],\n env: ENV = 'prd',\n): Promise<{ address: string; enabled: boolean }[]> {\n if (addresses.length === 0) {\n return [];\n }\n\n const normalizedAddresses = addresses.map((addr) => addr.toLowerCase());\n\n const cached = notificationsConfigCache.get(normalizedAddresses);\n if (cached) {\n return cached;\n }\n\n type RequestBody = { address: string }[];\n type Response = { address: string; enabled: boolean }[];\n const body: RequestBody = normalizedAddresses.map((address) => ({ address }));\n const apiResponse = await makeApiCall(\n bearerToken,\n TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT(env),\n 'POST',\n body,\n )\n .then<Response | null>((response) => (response.ok ? response.json() : null))\n .catch(() => null);\n\n const result = apiResponse ?? [];\n\n if (result.length > 0) {\n notificationsConfigCache.set(result);\n }\n\n return result;\n}\n\n/**\n * Fetches on-chain notifications for the given addresses\n *\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param addresses - List of addresses\n * @param locale - to generate translated notifications\n * @param platform - filter notifications for specific platforms ('extension' | 'mobile')\n * @param env - the environment to use for the API call\n * @returns An array of {@link NormalisedAPINotification}. Returns an empty array on transport or parse errors.\n */\nexport async function getAPINotifications(\n bearerToken: string,\n addresses: string[],\n locale: string,\n platform: 'extension' | 'mobile',\n env: ENV = 'prd',\n): Promise<NormalisedAPINotification[]> {\n if (addresses.length === 0) {\n return [];\n }\n\n type RequestBody =\n Schema.paths['/api/v4/notifications']['post']['requestBody']['content']['application/json'];\n type APIResponse =\n Schema.paths['/api/v4/notifications']['post']['responses']['200']['content']['application/json'];\n\n const body: RequestBody = {\n addresses: addresses.map((addr) => addr.toLowerCase()),\n locale,\n platform,\n };\n const notifications = await makeApiCall(\n bearerToken,\n NOTIFICATION_API_LIST_ENDPOINT(env),\n 'POST',\n body,\n )\n .then<APIResponse | null>((response) =>\n response.ok ? response.json() : null,\n )\n .catch(() => null);\n\n // Transform and sort notifications\n const transformedNotifications = notifications\n ?.map((notification): UnprocessedRawNotification | undefined => {\n if (!notification.notification_type) {\n return undefined;\n }\n\n try {\n return toRawAPINotification(notification);\n } catch {\n return undefined;\n }\n })\n .filter((item): item is NormalisedAPINotification => Boolean(item));\n\n return transformedNotifications ?? [];\n}\n\n/**\n * Marks the specified notifications as read.\n * This method sends a POST request to the notifications service to mark the provided notification IDs as read.\n * If the operation is successful, it completes without error. If the operation fails, it throws an error with details.\n *\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param notificationIds - An array of notification IDs to be marked as read.\n * @param env - the environment to use for the API call\n * @returns A promise that resolves to void. The promise will reject if there's an error during the API call or if the response status is not 200.\n */\nexport async function markNotificationsAsRead(\n bearerToken: string,\n notificationIds: string[],\n env: ENV = 'prd',\n): Promise<void> {\n if (notificationIds.length === 0) {\n return;\n }\n\n type ResponseBody =\n Schema.paths['/api/v4/notifications/mark-as-read']['post']['requestBody']['content']['application/json'];\n const body: ResponseBody = {\n ids: notificationIds,\n };\n\n try {\n await makeApiCall(\n bearerToken,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT(env),\n 'POST',\n body,\n );\n } catch (error) {\n log.error('Error marking notifications as read:', error);\n }\n}\n"]}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFeatureAnnouncementNotifications = exports.getFeatureAnnouncementUrl = exports.FEATURE_ANNOUNCEMENT_URL = exports.FEATURE_ANNOUNCEMENT_API = void 0;
|
|
4
|
+
const rich_text_html_renderer_1 = require("@contentful/rich-text-html-renderer");
|
|
5
|
+
const notification_schema_js_1 = require("../constants/notification-schema.cjs");
|
|
6
|
+
const process_feature_announcement_js_1 = require("../processors/process-feature-announcement.cjs");
|
|
7
|
+
const isVersionInBounds_js_1 = require("../utils/isVersionInBounds.cjs");
|
|
8
|
+
// Feature announcements older than this (by sys.updatedAt) are excluded from the feed.
|
|
9
|
+
const FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS = 3;
|
|
10
|
+
const DEFAULT_SPACE_ID = ':space_id';
|
|
11
|
+
const DEFAULT_ACCESS_TOKEN = ':access_token';
|
|
12
|
+
const DEFAULT_CLIENT_ID = ':client_id';
|
|
13
|
+
const DEFAULT_DOMAIN = 'cdn.contentful.com';
|
|
14
|
+
const PREVIEW_DOMAIN = 'preview.contentful.com';
|
|
15
|
+
exports.FEATURE_ANNOUNCEMENT_API = `https://${DEFAULT_DOMAIN}/spaces/${DEFAULT_SPACE_ID}/environments/master/entries`;
|
|
16
|
+
exports.FEATURE_ANNOUNCEMENT_URL = `${exports.FEATURE_ANNOUNCEMENT_API}?access_token=${DEFAULT_ACCESS_TOKEN}&content_type=productAnnouncement&include=10&fields.clients[in]=${DEFAULT_CLIENT_ID}`;
|
|
17
|
+
const getFeatureAnnouncementUrl = (env, previewToken) => {
|
|
18
|
+
const domain = previewToken ? PREVIEW_DOMAIN : DEFAULT_DOMAIN;
|
|
19
|
+
const replacedUrl = exports.FEATURE_ANNOUNCEMENT_URL.replace(DEFAULT_SPACE_ID, env.spaceId)
|
|
20
|
+
.replace(DEFAULT_ACCESS_TOKEN, previewToken ?? env.accessToken)
|
|
21
|
+
.replace(DEFAULT_CLIENT_ID, env.platform)
|
|
22
|
+
.replace(DEFAULT_DOMAIN, domain);
|
|
23
|
+
return encodeURI(replacedUrl);
|
|
24
|
+
};
|
|
25
|
+
exports.getFeatureAnnouncementUrl = getFeatureAnnouncementUrl;
|
|
26
|
+
const fetchFeatureAnnouncementNotifications = async (env, previewToken) => {
|
|
27
|
+
const url = (0, exports.getFeatureAnnouncementUrl)(env, previewToken);
|
|
28
|
+
const data = await fetch(url)
|
|
29
|
+
.then((response) => response.json())
|
|
30
|
+
.catch(() => null);
|
|
31
|
+
if (!data) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const findIncludedItem = (sysId) => {
|
|
35
|
+
const typedData = data;
|
|
36
|
+
const item = typedData?.includes?.Entry?.find((entry) => entry?.sys?.id === sysId) ??
|
|
37
|
+
typedData?.includes?.Asset?.find((asset) => asset?.sys?.id === sysId);
|
|
38
|
+
return item ? item?.fields : null;
|
|
39
|
+
};
|
|
40
|
+
const contentfulNotifications = data?.items ?? [];
|
|
41
|
+
const rawNotifications = contentfulNotifications
|
|
42
|
+
.filter((item) => {
|
|
43
|
+
const updatedAt = new Date(item.sys.updatedAt);
|
|
44
|
+
const limitDate = new Date();
|
|
45
|
+
limitDate.setMonth(limitDate.getMonth() - FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS);
|
|
46
|
+
return updatedAt > limitDate;
|
|
47
|
+
})
|
|
48
|
+
.map((item) => {
|
|
49
|
+
const { fields } = item;
|
|
50
|
+
const imageFields = fields.image
|
|
51
|
+
? findIncludedItem(fields.image.sys.id)
|
|
52
|
+
: undefined;
|
|
53
|
+
const externalLinkFields = fields.externalLink
|
|
54
|
+
? findIncludedItem(fields.externalLink.sys.id)
|
|
55
|
+
: undefined;
|
|
56
|
+
const portfolioLinkFields = fields.portfolioLink
|
|
57
|
+
? findIncludedItem(fields.portfolioLink.sys.id)
|
|
58
|
+
: undefined;
|
|
59
|
+
const extensionLinkFields = fields.extensionLink
|
|
60
|
+
? findIncludedItem(fields.extensionLink.sys.id)
|
|
61
|
+
: undefined;
|
|
62
|
+
const mobileLinkFields = fields.mobileLink
|
|
63
|
+
? findIncludedItem(fields.mobileLink.sys.id)
|
|
64
|
+
: undefined;
|
|
65
|
+
const notification = {
|
|
66
|
+
type: notification_schema_js_1.TRIGGER_TYPES.FEATURES_ANNOUNCEMENT,
|
|
67
|
+
createdAt: new Date(item.sys.createdAt).toString(),
|
|
68
|
+
data: {
|
|
69
|
+
id: fields.id,
|
|
70
|
+
category: fields.category,
|
|
71
|
+
title: fields.title,
|
|
72
|
+
longDescription: (0, rich_text_html_renderer_1.documentToHtmlString)(fields.longDescription),
|
|
73
|
+
shortDescription: fields.shortDescription,
|
|
74
|
+
image: {
|
|
75
|
+
title: imageFields?.title,
|
|
76
|
+
description: imageFields?.description,
|
|
77
|
+
url: imageFields?.file?.url ?? '',
|
|
78
|
+
},
|
|
79
|
+
externalLink: externalLinkFields && {
|
|
80
|
+
externalLinkText: externalLinkFields?.externalLinkText,
|
|
81
|
+
externalLinkUrl: externalLinkFields?.externalLinkUrl,
|
|
82
|
+
},
|
|
83
|
+
portfolioLink: portfolioLinkFields && {
|
|
84
|
+
portfolioLinkText: portfolioLinkFields?.portfolioLinkText,
|
|
85
|
+
portfolioLinkUrl: portfolioLinkFields?.portfolioLinkUrl,
|
|
86
|
+
},
|
|
87
|
+
extensionLink: extensionLinkFields && {
|
|
88
|
+
extensionLinkText: extensionLinkFields?.extensionLinkText,
|
|
89
|
+
extensionLinkRoute: extensionLinkFields?.extensionLinkRoute,
|
|
90
|
+
},
|
|
91
|
+
mobileLink: mobileLinkFields && {
|
|
92
|
+
mobileLinkText: mobileLinkFields?.mobileLinkText,
|
|
93
|
+
mobileLinkUrl: mobileLinkFields?.mobileLinkUrl,
|
|
94
|
+
},
|
|
95
|
+
extensionMinimumVersionNumber: fields.extensionMinimumVersionNumber,
|
|
96
|
+
mobileMinimumVersionNumber: fields.mobileMinimumVersionNumber,
|
|
97
|
+
extensionMaximumVersionNumber: fields.extensionMaximumVersionNumber,
|
|
98
|
+
mobileMaximumVersionNumber: fields.mobileMaximumVersionNumber,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
return notification;
|
|
102
|
+
});
|
|
103
|
+
const versionKeys = {
|
|
104
|
+
extension: {
|
|
105
|
+
min: 'extensionMinimumVersionNumber',
|
|
106
|
+
max: 'extensionMaximumVersionNumber',
|
|
107
|
+
},
|
|
108
|
+
mobile: {
|
|
109
|
+
min: 'mobileMinimumVersionNumber',
|
|
110
|
+
max: 'mobileMaximumVersionNumber',
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const filteredRawNotifications = rawNotifications.filter((rawNotification) => {
|
|
114
|
+
const minVersion = rawNotification.data?.[versionKeys[env.platform].min];
|
|
115
|
+
const maxVersion = rawNotification.data?.[versionKeys[env.platform].max];
|
|
116
|
+
return (0, isVersionInBounds_js_1.isVersionInBounds)({
|
|
117
|
+
currentVersion: env.platformVersion,
|
|
118
|
+
minVersion,
|
|
119
|
+
maxVersion,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return filteredRawNotifications;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Gets Feature Announcement from our services
|
|
126
|
+
*
|
|
127
|
+
* @param env - environment for feature announcements
|
|
128
|
+
* @param previewToken - the preview token to use if needed
|
|
129
|
+
* @returns Raw Feature Announcements
|
|
130
|
+
*/
|
|
131
|
+
async function getFeatureAnnouncementNotifications(env, previewToken) {
|
|
132
|
+
if (env?.accessToken && env?.spaceId && env?.platform) {
|
|
133
|
+
const rawNotifications = await fetchFeatureAnnouncementNotifications(env, previewToken);
|
|
134
|
+
const notifications = rawNotifications.map((notification) => (0, process_feature_announcement_js_1.processFeatureAnnouncement)(notification));
|
|
135
|
+
return notifications;
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
exports.getFeatureAnnouncementNotifications = getFeatureAnnouncementNotifications;
|
|
140
|
+
//# sourceMappingURL=feature-announcements.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-announcements.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/feature-announcements.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAG3E,iFAAoE;AACpE,oGAA2F;AAa3F,yEAAkE;AAElE,uFAAuF;AACvF,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAE9C,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAC7C,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,cAAc,GAA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,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC;QACtD,MAAM,gBAAgB,GAAG,MAAM,qCAAqC,CAClE,GAAG,EACH,YAAY,CACb,CAAC;QACF,MAAM,aAAa,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAC1D,IAAA,4DAA0B,EAAC,YAAY,CAAC,CACzC,CAAC;QAEF,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAjBD,kFAiBC","sourcesContent":["import { documentToHtmlString } from '@contentful/rich-text-html-renderer';\nimport type { Entry, Asset, EntryCollection } from 'contentful';\n\nimport { TRIGGER_TYPES } from '../constants/notification-schema.js';\nimport { processFeatureAnnouncement } from '../processors/process-feature-announcement.js';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement.js';\nimport type {\n ImageFields,\n TypeFeatureAnnouncement,\n} from '../types/feature-announcement/type-feature-announcement.js';\nimport type {\n TypeExternalLinkFields,\n TypePortfolioLinkFields,\n TypeExtensionLinkFields,\n TypeMobileLinkFields,\n} from '../types/feature-announcement/type-links.js';\nimport type { INotification } from '../types/notification/notification.js';\nimport { isVersionInBounds } from '../utils/isVersionInBounds.js';\n\n// Feature announcements older than this (by sys.updatedAt) are excluded from the feed.\nconst FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS = 3;\n\nconst DEFAULT_SPACE_ID = ':space_id';\nconst DEFAULT_ACCESS_TOKEN = ':access_token';\nconst DEFAULT_CLIENT_ID = ':client_id';\nconst DEFAULT_DOMAIN = 'cdn.contentful.com';\nconst PREVIEW_DOMAIN = 'preview.contentful.com';\nexport const FEATURE_ANNOUNCEMENT_API = `https://${DEFAULT_DOMAIN}/spaces/${DEFAULT_SPACE_ID}/environments/master/entries`;\nexport const FEATURE_ANNOUNCEMENT_URL = `${FEATURE_ANNOUNCEMENT_API}?access_token=${DEFAULT_ACCESS_TOKEN}&content_type=productAnnouncement&include=10&fields.clients[in]=${DEFAULT_CLIENT_ID}`;\n\ntype Env = {\n spaceId: string;\n accessToken: string;\n platform: 'extension' | 'mobile';\n platformVersion?: string;\n};\n\n/**\n * Contentful API Response Shape\n */\nexport type ContentfulResult = {\n includes?: {\n // Property names match Contentful API response structure\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Entry?: Entry[];\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Asset?: Asset[];\n };\n items?: TypeFeatureAnnouncement[];\n};\n\nexport const getFeatureAnnouncementUrl = (\n env: Env,\n previewToken?: string,\n): string => {\n const domain = previewToken ? PREVIEW_DOMAIN : DEFAULT_DOMAIN;\n const replacedUrl = FEATURE_ANNOUNCEMENT_URL.replace(\n DEFAULT_SPACE_ID,\n env.spaceId,\n )\n .replace(DEFAULT_ACCESS_TOKEN, previewToken ?? env.accessToken)\n .replace(DEFAULT_CLIENT_ID, env.platform)\n .replace(DEFAULT_DOMAIN, domain);\n return encodeURI(replacedUrl);\n};\n\nconst fetchFeatureAnnouncementNotifications = async (\n env: Env,\n previewToken?: string,\n): Promise<FeatureAnnouncementRawNotification[]> => {\n const url = getFeatureAnnouncementUrl(env, previewToken);\n\n const data = await fetch(url)\n .then((response) => response.json())\n .catch(() => null);\n\n if (!data) {\n return [];\n }\n\n const findIncludedItem = (\n sysId: string,\n ):\n | ImageFields['fields']\n | TypeExtensionLinkFields['fields']\n | TypePortfolioLinkFields['fields']\n | TypeMobileLinkFields['fields']\n | TypeExternalLinkFields['fields']\n | null => {\n const typedData: EntryCollection<\n | ImageFields\n | TypeExtensionLinkFields\n | TypePortfolioLinkFields\n | TypeMobileLinkFields\n | TypeExternalLinkFields\n > = data;\n const item =\n typedData?.includes?.Entry?.find(\n (entry: Entry) => entry?.sys?.id === sysId,\n ) ??\n typedData?.includes?.Asset?.find(\n (asset: Asset) => asset?.sys?.id === sysId,\n );\n return item ? item?.fields : null;\n };\n\n const contentfulNotifications = data?.items ?? [];\n const rawNotifications: FeatureAnnouncementRawNotification[] =\n contentfulNotifications\n .filter((item: TypeFeatureAnnouncement) => {\n const updatedAt = new Date(item.sys.updatedAt);\n const limitDate = new Date();\n limitDate.setMonth(\n limitDate.getMonth() - FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS,\n );\n return updatedAt > limitDate;\n })\n .map((item: TypeFeatureAnnouncement) => {\n const { fields } = item;\n const imageFields = fields.image\n ? (findIncludedItem(fields.image.sys.id) as ImageFields['fields'])\n : undefined;\n\n const externalLinkFields = fields.externalLink\n ? (findIncludedItem(\n fields.externalLink.sys.id,\n ) as TypeExternalLinkFields['fields'])\n : undefined;\n const portfolioLinkFields = fields.portfolioLink\n ? (findIncludedItem(\n fields.portfolioLink.sys.id,\n ) as TypePortfolioLinkFields['fields'])\n : undefined;\n const extensionLinkFields = fields.extensionLink\n ? (findIncludedItem(\n fields.extensionLink.sys.id,\n ) as TypeExtensionLinkFields['fields'])\n : undefined;\n const mobileLinkFields = fields.mobileLink\n ? (findIncludedItem(\n fields.mobileLink.sys.id,\n ) as TypeMobileLinkFields['fields'])\n : undefined;\n\n const notification: FeatureAnnouncementRawNotification = {\n type: TRIGGER_TYPES.FEATURES_ANNOUNCEMENT,\n createdAt: new Date(item.sys.createdAt).toString(),\n data: {\n id: fields.id,\n category: fields.category,\n title: fields.title,\n longDescription: documentToHtmlString(fields.longDescription),\n shortDescription: fields.shortDescription,\n image: {\n title: imageFields?.title,\n description: imageFields?.description,\n url: imageFields?.file?.url ?? '',\n },\n externalLink: externalLinkFields && {\n externalLinkText: externalLinkFields?.externalLinkText,\n externalLinkUrl: externalLinkFields?.externalLinkUrl,\n },\n portfolioLink: portfolioLinkFields && {\n portfolioLinkText: portfolioLinkFields?.portfolioLinkText,\n portfolioLinkUrl: portfolioLinkFields?.portfolioLinkUrl,\n },\n extensionLink: extensionLinkFields && {\n extensionLinkText: extensionLinkFields?.extensionLinkText,\n extensionLinkRoute: extensionLinkFields?.extensionLinkRoute,\n },\n mobileLink: mobileLinkFields && {\n mobileLinkText: mobileLinkFields?.mobileLinkText,\n mobileLinkUrl: mobileLinkFields?.mobileLinkUrl,\n },\n extensionMinimumVersionNumber: fields.extensionMinimumVersionNumber,\n mobileMinimumVersionNumber: fields.mobileMinimumVersionNumber,\n extensionMaximumVersionNumber: fields.extensionMaximumVersionNumber,\n mobileMaximumVersionNumber: fields.mobileMaximumVersionNumber,\n },\n };\n\n return notification;\n });\n\n const versionKeys = {\n extension: {\n min: 'extensionMinimumVersionNumber',\n max: 'extensionMaximumVersionNumber',\n },\n mobile: {\n min: 'mobileMinimumVersionNumber',\n max: 'mobileMaximumVersionNumber',\n },\n } as const;\n\n const filteredRawNotifications = rawNotifications.filter(\n (rawNotification) => {\n const minVersion = rawNotification.data?.[versionKeys[env.platform].min];\n const maxVersion = rawNotification.data?.[versionKeys[env.platform].max];\n return isVersionInBounds({\n currentVersion: env.platformVersion,\n minVersion,\n maxVersion,\n });\n },\n );\n\n return filteredRawNotifications;\n};\n\n/**\n * Gets Feature Announcement from our services\n *\n * @param env - environment for feature announcements\n * @param previewToken - the preview token to use if needed\n * @returns Raw Feature Announcements\n */\nexport async function getFeatureAnnouncementNotifications(\n env: Env,\n previewToken?: string,\n): Promise<INotification[]> {\n if (env?.accessToken && env?.spaceId && env?.platform) {\n const rawNotifications = await fetchFeatureAnnouncementNotifications(\n env,\n previewToken,\n );\n const notifications = rawNotifications.map((notification) =>\n processFeatureAnnouncement(notification),\n );\n\n return notifications;\n }\n\n return [];\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Entry, Asset } from
|
|
2
|
-
import type { TypeFeatureAnnouncement } from
|
|
3
|
-
import type { INotification } from
|
|
1
|
+
import type { Entry, Asset } from "contentful";
|
|
2
|
+
import type { TypeFeatureAnnouncement } from "../types/feature-announcement/type-feature-announcement.cjs";
|
|
3
|
+
import type { INotification } from "../types/notification/notification.cjs";
|
|
4
4
|
export declare const FEATURE_ANNOUNCEMENT_API = "https://cdn.contentful.com/spaces/:space_id/environments/master/entries";
|
|
5
5
|
export declare const FEATURE_ANNOUNCEMENT_URL = "https://cdn.contentful.com/spaces/:space_id/environments/master/entries?access_token=:access_token&content_type=productAnnouncement&include=10&fields.clients[in]=:client_id";
|
|
6
6
|
type Env = {
|
|
@@ -29,4 +29,4 @@ export declare const getFeatureAnnouncementUrl: (env: Env, previewToken?: string
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function getFeatureAnnouncementNotifications(env: Env, previewToken?: string): Promise<INotification[]>;
|
|
31
31
|
export {};
|
|
32
|
-
//# sourceMappingURL=feature-announcements.d.
|
|
32
|
+
//# sourceMappingURL=feature-announcements.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-announcements.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/feature-announcements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAmB,mBAAmB;AAKhE,OAAO,KAAK,EAEV,uBAAuB,EACxB,oEAAmE;AAOpE,OAAO,KAAK,EAAE,aAAa,EAAE,+CAA8C;AAW3E,eAAO,MAAM,wBAAwB,4EAAqF,CAAC;AAC3H,eAAO,MAAM,wBAAwB,iLAAyJ,CAAC;AAE/L,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,GAAG,QAAQ,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE;QAGT,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;QAEhB,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;KACjB,CAAC;IACF,KAAK,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAC/B,GAAG,iBACO,MAAM,KACpB,MAUF,CAAC;AAkJF;;;;;;GAMG;AACH,wBAAsB,mCAAmC,CACvD,GAAG,EAAE,GAAG,EACR,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC,CAc1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Entry, Asset } from "contentful";
|
|
2
|
+
import type { TypeFeatureAnnouncement } from "../types/feature-announcement/type-feature-announcement.mjs";
|
|
3
|
+
import type { INotification } from "../types/notification/notification.mjs";
|
|
4
|
+
export declare const FEATURE_ANNOUNCEMENT_API = "https://cdn.contentful.com/spaces/:space_id/environments/master/entries";
|
|
5
|
+
export declare const FEATURE_ANNOUNCEMENT_URL = "https://cdn.contentful.com/spaces/:space_id/environments/master/entries?access_token=:access_token&content_type=productAnnouncement&include=10&fields.clients[in]=:client_id";
|
|
6
|
+
type Env = {
|
|
7
|
+
spaceId: string;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
platform: 'extension' | 'mobile';
|
|
10
|
+
platformVersion?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Contentful API Response Shape
|
|
14
|
+
*/
|
|
15
|
+
export type ContentfulResult = {
|
|
16
|
+
includes?: {
|
|
17
|
+
Entry?: Entry[];
|
|
18
|
+
Asset?: Asset[];
|
|
19
|
+
};
|
|
20
|
+
items?: TypeFeatureAnnouncement[];
|
|
21
|
+
};
|
|
22
|
+
export declare const getFeatureAnnouncementUrl: (env: Env, previewToken?: string) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Gets Feature Announcement from our services
|
|
25
|
+
*
|
|
26
|
+
* @param env - environment for feature announcements
|
|
27
|
+
* @param previewToken - the preview token to use if needed
|
|
28
|
+
* @returns Raw Feature Announcements
|
|
29
|
+
*/
|
|
30
|
+
export declare function getFeatureAnnouncementNotifications(env: Env, previewToken?: string): Promise<INotification[]>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=feature-announcements.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-announcements.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/feature-announcements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAmB,mBAAmB;AAKhE,OAAO,KAAK,EAEV,uBAAuB,EACxB,oEAAmE;AAOpE,OAAO,KAAK,EAAE,aAAa,EAAE,+CAA8C;AAW3E,eAAO,MAAM,wBAAwB,4EAAqF,CAAC;AAC3H,eAAO,MAAM,wBAAwB,iLAAyJ,CAAC;AAE/L,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,GAAG,QAAQ,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE;QAGT,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;QAEhB,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;KACjB,CAAC;IACF,KAAK,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAC/B,GAAG,iBACO,MAAM,KACpB,MAUF,CAAC;AAkJF;;;;;;GAMG;AACH,wBAAsB,mCAAmC,CACvD,GAAG,EAAE,GAAG,EACR,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC,CAc1B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { documentToHtmlString } from
|
|
2
|
-
import { TRIGGER_TYPES } from
|
|
3
|
-
import { processFeatureAnnouncement } from
|
|
4
|
-
import { isVersionInBounds } from
|
|
1
|
+
import { documentToHtmlString } from "@contentful/rich-text-html-renderer";
|
|
2
|
+
import { TRIGGER_TYPES } from "../constants/notification-schema.mjs";
|
|
3
|
+
import { processFeatureAnnouncement } from "../processors/process-feature-announcement.mjs";
|
|
4
|
+
import { isVersionInBounds } from "../utils/isVersionInBounds.mjs";
|
|
5
5
|
// Feature announcements older than this (by sys.updatedAt) are excluded from the feed.
|
|
6
6
|
const FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS = 3;
|
|
7
7
|
const DEFAULT_SPACE_ID = ':space_id';
|
|
@@ -132,4 +132,4 @@ export async function getFeatureAnnouncementNotifications(env, previewToken) {
|
|
|
132
132
|
}
|
|
133
133
|
return [];
|
|
134
134
|
}
|
|
135
|
-
//# sourceMappingURL=feature-announcements.
|
|
135
|
+
//# sourceMappingURL=feature-announcements.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-announcements.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/feature-announcements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,4CAA4C;AAG3E,OAAO,EAAE,aAAa,EAAE,6CAA4C;AACpE,OAAO,EAAE,0BAA0B,EAAE,uDAAsD;AAa3F,OAAO,EAAE,iBAAiB,EAAE,uCAAsC;AAElE,uFAAuF;AACvF,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAE9C,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAC7C,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAC5C,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAChD,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,cAAc,WAAW,gBAAgB,8BAA8B,CAAC;AAC3H,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,wBAAwB,iBAAiB,oBAAoB,mEAAmE,iBAAiB,EAAE,CAAC;AAuB/L,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,GAAQ,EACR,YAAqB,EACb,EAAE;IACV,MAAM,MAAM,GAAG,YAAY,CAAC,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lString } from '@contentful/rich-text-html-renderer';\nimport type { Entry, Asset, EntryCollection } from 'contentful';\n\nimport { TRIGGER_TYPES } from '../constants/notification-schema.js';\nimport { processFeatureAnnouncement } from '../processors/process-feature-announcement.js';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement.js';\nimport type {\n ImageFields,\n TypeFeatureAnnouncement,\n} from '../types/feature-announcement/type-feature-announcement.js';\nimport type {\n TypeExternalLinkFields,\n TypePortfolioLinkFields,\n TypeExtensionLinkFields,\n TypeMobileLinkFields,\n} from '../types/feature-announcement/type-links.js';\nimport type { INotification } from '../types/notification/notification.js';\nimport { isVersionInBounds } from '../utils/isVersionInBounds.js';\n\n// Feature announcements older than this (by sys.updatedAt) are excluded from the feed.\nconst FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS = 3;\n\nconst DEFAULT_SPACE_ID = ':space_id';\nconst DEFAULT_ACCESS_TOKEN = ':access_token';\nconst DEFAULT_CLIENT_ID = ':client_id';\nconst DEFAULT_DOMAIN = 'cdn.contentful.com';\nconst PREVIEW_DOMAIN = 'preview.contentful.com';\nexport const FEATURE_ANNOUNCEMENT_API = `https://${DEFAULT_DOMAIN}/spaces/${DEFAULT_SPACE_ID}/environments/master/entries`;\nexport const FEATURE_ANNOUNCEMENT_URL = `${FEATURE_ANNOUNCEMENT_API}?access_token=${DEFAULT_ACCESS_TOKEN}&content_type=productAnnouncement&include=10&fields.clients[in]=${DEFAULT_CLIENT_ID}`;\n\ntype Env = {\n spaceId: string;\n accessToken: string;\n platform: 'extension' | 'mobile';\n platformVersion?: string;\n};\n\n/**\n * Contentful API Response Shape\n */\nexport type ContentfulResult = {\n includes?: {\n // Property names match Contentful API response structure\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Entry?: Entry[];\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Asset?: Asset[];\n };\n items?: TypeFeatureAnnouncement[];\n};\n\nexport const getFeatureAnnouncementUrl = (\n env: Env,\n previewToken?: string,\n): string => {\n const domain = previewToken ? PREVIEW_DOMAIN : DEFAULT_DOMAIN;\n const replacedUrl = FEATURE_ANNOUNCEMENT_URL.replace(\n DEFAULT_SPACE_ID,\n env.spaceId,\n )\n .replace(DEFAULT_ACCESS_TOKEN, previewToken ?? env.accessToken)\n .replace(DEFAULT_CLIENT_ID, env.platform)\n .replace(DEFAULT_DOMAIN, domain);\n return encodeURI(replacedUrl);\n};\n\nconst fetchFeatureAnnouncementNotifications = async (\n env: Env,\n previewToken?: string,\n): Promise<FeatureAnnouncementRawNotification[]> => {\n const url = getFeatureAnnouncementUrl(env, previewToken);\n\n const data = await fetch(url)\n .then((response) => response.json())\n .catch(() => null);\n\n if (!data) {\n return [];\n }\n\n const findIncludedItem = (\n sysId: string,\n ):\n | ImageFields['fields']\n | TypeExtensionLinkFields['fields']\n | TypePortfolioLinkFields['fields']\n | TypeMobileLinkFields['fields']\n | TypeExternalLinkFields['fields']\n | null => {\n const typedData: EntryCollection<\n | ImageFields\n | TypeExtensionLinkFields\n | TypePortfolioLinkFields\n | TypeMobileLinkFields\n | TypeExternalLinkFields\n > = data;\n const item =\n typedData?.includes?.Entry?.find(\n (entry: Entry) => entry?.sys?.id === sysId,\n ) ??\n typedData?.includes?.Asset?.find(\n (asset: Asset) => asset?.sys?.id === sysId,\n );\n return item ? item?.fields : null;\n };\n\n const contentfulNotifications = data?.items ?? [];\n const rawNotifications: FeatureAnnouncementRawNotification[] =\n contentfulNotifications\n .filter((item: TypeFeatureAnnouncement) => {\n const updatedAt = new Date(item.sys.updatedAt);\n const limitDate = new Date();\n limitDate.setMonth(\n limitDate.getMonth() - FEATURE_ANNOUNCEMENT_MAX_AGE_MONTHS,\n );\n return updatedAt > limitDate;\n })\n .map((item: TypeFeatureAnnouncement) => {\n const { fields } = item;\n const imageFields = fields.image\n ? (findIncludedItem(fields.image.sys.id) as ImageFields['fields'])\n : undefined;\n\n const externalLinkFields = fields.externalLink\n ? (findIncludedItem(\n fields.externalLink.sys.id,\n ) as TypeExternalLinkFields['fields'])\n : undefined;\n const portfolioLinkFields = fields.portfolioLink\n ? (findIncludedItem(\n fields.portfolioLink.sys.id,\n ) as TypePortfolioLinkFields['fields'])\n : undefined;\n const extensionLinkFields = fields.extensionLink\n ? (findIncludedItem(\n fields.extensionLink.sys.id,\n ) as TypeExtensionLinkFields['fields'])\n : undefined;\n const mobileLinkFields = fields.mobileLink\n ? (findIncludedItem(\n fields.mobileLink.sys.id,\n ) as TypeMobileLinkFields['fields'])\n : undefined;\n\n const notification: FeatureAnnouncementRawNotification = {\n type: TRIGGER_TYPES.FEATURES_ANNOUNCEMENT,\n createdAt: new Date(item.sys.createdAt).toString(),\n data: {\n id: fields.id,\n category: fields.category,\n title: fields.title,\n longDescription: documentToHtmlString(fields.longDescription),\n shortDescription: fields.shortDescription,\n image: {\n title: imageFields?.title,\n description: imageFields?.description,\n url: imageFields?.file?.url ?? '',\n },\n externalLink: externalLinkFields && {\n externalLinkText: externalLinkFields?.externalLinkText,\n externalLinkUrl: externalLinkFields?.externalLinkUrl,\n },\n portfolioLink: portfolioLinkFields && {\n portfolioLinkText: portfolioLinkFields?.portfolioLinkText,\n portfolioLinkUrl: portfolioLinkFields?.portfolioLinkUrl,\n },\n extensionLink: extensionLinkFields && {\n extensionLinkText: extensionLinkFields?.extensionLinkText,\n extensionLinkRoute: extensionLinkFields?.extensionLinkRoute,\n },\n mobileLink: mobileLinkFields && {\n mobileLinkText: mobileLinkFields?.mobileLinkText,\n mobileLinkUrl: mobileLinkFields?.mobileLinkUrl,\n },\n extensionMinimumVersionNumber: fields.extensionMinimumVersionNumber,\n mobileMinimumVersionNumber: fields.mobileMinimumVersionNumber,\n extensionMaximumVersionNumber: fields.extensionMaximumVersionNumber,\n mobileMaximumVersionNumber: fields.mobileMaximumVersionNumber,\n },\n };\n\n return notification;\n });\n\n const versionKeys = {\n extension: {\n min: 'extensionMinimumVersionNumber',\n max: 'extensionMaximumVersionNumber',\n },\n mobile: {\n min: 'mobileMinimumVersionNumber',\n max: 'mobileMaximumVersionNumber',\n },\n } as const;\n\n const filteredRawNotifications = rawNotifications.filter(\n (rawNotification) => {\n const minVersion = rawNotification.data?.[versionKeys[env.platform].min];\n const maxVersion = rawNotification.data?.[versionKeys[env.platform].max];\n return isVersionInBounds({\n currentVersion: env.platformVersion,\n minVersion,\n maxVersion,\n });\n },\n );\n\n return filteredRawNotifications;\n};\n\n/**\n * Gets Feature Announcement from our services\n *\n * @param env - environment for feature announcements\n * @param previewToken - the preview token to use if needed\n * @returns Raw Feature Announcements\n */\nexport async function getFeatureAnnouncementNotifications(\n env: Env,\n previewToken?: string,\n): Promise<INotification[]> {\n if (env?.accessToken && env?.spaceId && env?.platform) {\n const rawNotifications = await fetchFeatureAnnouncementNotifications(\n env,\n previewToken,\n );\n const notifications = rawNotifications.map((notification) =>\n processFeatureAnnouncement(notification),\n );\n\n return notifications;\n }\n\n return [];\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
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");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var _OnChainNotificationsCache_instances, _OnChainNotificationsCache_cache, _OnChainNotificationsCache_ttl, _OnChainNotificationsCache_isExpired, _OnChainNotificationsCache_hasAllAddresses;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.notificationsConfigCache = exports.OnChainNotificationsCache = exports.NotificationConfigCacheTTL = void 0;
|
|
16
|
+
exports.NotificationConfigCacheTTL = 1000 * 60; // 60 seconds
|
|
17
|
+
class OnChainNotificationsCache {
|
|
18
|
+
constructor() {
|
|
19
|
+
_OnChainNotificationsCache_instances.add(this);
|
|
20
|
+
_OnChainNotificationsCache_cache.set(this, null);
|
|
21
|
+
_OnChainNotificationsCache_ttl.set(this, exports.NotificationConfigCacheTTL);
|
|
22
|
+
}
|
|
23
|
+
get(addresses) {
|
|
24
|
+
if (__classPrivateFieldGet(this, _OnChainNotificationsCache_instances, "m", _OnChainNotificationsCache_isExpired).call(this) || !__classPrivateFieldGet(this, _OnChainNotificationsCache_instances, "m", _OnChainNotificationsCache_hasAllAddresses).call(this, addresses)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return addresses.map((address) => ({
|
|
28
|
+
address,
|
|
29
|
+
enabled: __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")?.data.get(address) ?? false,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
set(data) {
|
|
33
|
+
let map = new Map();
|
|
34
|
+
// If we have existing cache, preserve it and update with new data
|
|
35
|
+
if (__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f") && !__classPrivateFieldGet(this, _OnChainNotificationsCache_instances, "m", _OnChainNotificationsCache_isExpired).call(this)) {
|
|
36
|
+
map = new Map(__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f").data);
|
|
37
|
+
}
|
|
38
|
+
// Update with new data
|
|
39
|
+
data.forEach(({ address, enabled }) => {
|
|
40
|
+
map.set(address, enabled);
|
|
41
|
+
});
|
|
42
|
+
__classPrivateFieldSet(this, _OnChainNotificationsCache_cache, {
|
|
43
|
+
data: map,
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
}, "f");
|
|
46
|
+
}
|
|
47
|
+
clear() {
|
|
48
|
+
__classPrivateFieldSet(this, _OnChainNotificationsCache_cache, null, "f");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.OnChainNotificationsCache = OnChainNotificationsCache;
|
|
52
|
+
_OnChainNotificationsCache_cache = new WeakMap(), _OnChainNotificationsCache_ttl = new WeakMap(), _OnChainNotificationsCache_instances = new WeakSet(), _OnChainNotificationsCache_isExpired = function _OnChainNotificationsCache_isExpired() {
|
|
53
|
+
return !__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f") || Date.now() - __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f").timestamp > __classPrivateFieldGet(this, _OnChainNotificationsCache_ttl, "f");
|
|
54
|
+
}, _OnChainNotificationsCache_hasAllAddresses = function _OnChainNotificationsCache_hasAllAddresses(addresses) {
|
|
55
|
+
if (!__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return addresses.every((address) => __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")?.data.has(address));
|
|
59
|
+
};
|
|
60
|
+
exports.notificationsConfigCache = new OnChainNotificationsCache();
|
|
61
|
+
//# sourceMappingURL=notification-config-cache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-config-cache.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/notification-config-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKa,QAAA,0BAA0B,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,aAAa;AAElE,MAAa,yBAAyB;IAAtC;;QACE,2CAAyC,IAAI,EAAC;QAErC,yCAAO,kCAA0B,EAAC;IA8C7C,CAAC;IAjCC,GAAG,CAAC,SAAmB;QACrB,IA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AAO,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,uBAAA,IAAI,wCAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAqCU,QAAA,wBAAwB,GAAG,IAAI,yBAAyB,EAAE,CAAC","sourcesContent":["type NotificationConfigCache = {\n data: Map<string, boolean>;\n timestamp: number;\n};\n\nexport const NotificationConfigCacheTTL = 1000 * 60; // 60 seconds\n\nexport class OnChainNotificationsCache {\n #cache: NotificationConfigCache | null = null;\n\n readonly #ttl = NotificationConfigCacheTTL;\n\n #isExpired(): boolean {\n return !this.#cache || Date.now() - this.#cache.timestamp > this.#ttl;\n }\n\n #hasAllAddresses(addresses: string[]): boolean {\n if (!this.#cache) {\n return false;\n }\n return addresses.every((address) => this.#cache?.data.has(address));\n }\n\n get(addresses: string[]): { address: string; enabled: boolean }[] | null {\n if (this.#isExpired() || !this.#hasAllAddresses(addresses)) {\n return null;\n }\n\n return addresses.map((address) => ({\n address,\n enabled: this.#cache?.data.get(address) ?? false,\n }));\n }\n\n set(data: { address: string; enabled: boolean }[]): void {\n let map: Map<string, boolean> = new Map<string, boolean>();\n\n // If we have existing cache, preserve it and update with new data\n if (this.#cache && !this.#isExpired()) {\n map = new Map(this.#cache.data);\n }\n\n // Update with new data\n data.forEach(({ address, enabled }) => {\n map.set(address, enabled);\n });\n\n this.#cache = {\n data: map,\n timestamp: Date.now(),\n };\n }\n\n clear(): void {\n this.#cache = null;\n }\n}\n\nexport const notificationsConfigCache = new OnChainNotificationsCache();\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-config-cache.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/notification-config-cache.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,0BAA0B,QAAY,CAAC;AAEpD,qBAAa,yBAAyB;;IAgBpC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,IAAI;IAWxE,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,IAAI;IAmBxD,KAAK,IAAI,IAAI;CAGd;AAED,eAAO,MAAM,wBAAwB,2BAAkC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const NotificationConfigCacheTTL: number;
|
|
2
|
+
export declare class OnChainNotificationsCache {
|
|
3
|
+
#private;
|
|
4
|
+
get(addresses: string[]): {
|
|
5
|
+
address: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
}[] | null;
|
|
8
|
+
set(data: {
|
|
9
|
+
address: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
}[]): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const notificationsConfigCache: OnChainNotificationsCache;
|
|
15
|
+
//# sourceMappingURL=notification-config-cache.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-config-cache.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/notification-config-cache.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,0BAA0B,QAAY,CAAC;AAEpD,qBAAa,yBAAyB;;IAgBpC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,IAAI;IAWxE,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,IAAI;IAmBxD,KAAK,IAAI,IAAI;CAGd;AAED,eAAO,MAAM,wBAAwB,2BAAkC,CAAC"}
|
|
@@ -54,4 +54,4 @@ _OnChainNotificationsCache_cache = new WeakMap(), _OnChainNotificationsCache_ttl
|
|
|
54
54
|
return addresses.every((address) => __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")?.data.has(address));
|
|
55
55
|
};
|
|
56
56
|
export const notificationsConfigCache = new OnChainNotificationsCache();
|
|
57
|
-
//# sourceMappingURL=notification-config-cache.
|
|
57
|
+
//# sourceMappingURL=notification-config-cache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-config-cache.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/notification-config-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,aAAa;AAElE,MAAM,OAAO,yBAAyB;IAAtC;;QACE,2CAAyC,IAAI,EAAC;QAErC,yCAAO,0BAA0B,EAAC;IA8C7C,CAAC;IAjCC,GAAG,CAAC,SAAmB;QACrB,IAAI,uBAAA,IAAI,kFAAW,MAAf,IAAI,CAAa,IAAI,CAAC,uBAAA,IAAI,wFAAiB,MAArB,IAAI,EAAkB,SAAS,CAAC,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACjC,OAAO;YACP,OAAO,EAAE,uBAAA,IAAI,wCAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK;SACjD,CAAC,CAAC,CAAC;IACN,CAAC;IAED,GAAG,CAAC,IAA6C;QAC/C,IAAI,GAAG,GAAyB,IAAI,GAAG,EAAmB,CAAC;QAE3D,kEAAkE;QAClE,IAAI,uBAAA,IAAI,wCAAO,IAAI,CAAC,uBAAA,IAAI,kFAAW,MAAf,IAAI,CAAa,EAAE,CAAC;YACtC,GAAG,GAAG,IAAI,GAAG,CAAC,uBAAA,IAAI,wCAAO,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YACpC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,uBAAA,IAAI,oCAAU;YACZ,IAAI,EAAE,GAAG;YACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,MAAA,CAAC;IACJ,CAAC;IAED,KAAK;QACH,uBAAA,IAAI,oCAAU,IAAI,MAAA,CAAC;IACrB,CAAC;CACF;;IA3CG,OAAO,CAAC,uBAAA,IAAI,wCAAO,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,uBAAA,IAAI,wCAAO,CAAC,SAAS,GAAG,uBAAA,IAAI,sCAAK,CAAC;AACxE,CAAC,mGAEgB,SAAmB;IAClC,IAAI,CAAC,uBAAA,IAAI,wCAAO,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,uBAAA,IAAI,wCAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAqCH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,yBAAyB,EAAE,CAAC","sourcesContent":["type NotificationConfigCache = {\n data: Map<string, boolean>;\n timestamp: number;\n};\n\nexport const NotificationConfigCacheTTL = 1000 * 60; // 60 seconds\n\nexport class OnChainNotificationsCache {\n #cache: NotificationConfigCache | null = null;\n\n readonly #ttl = NotificationConfigCacheTTL;\n\n #isExpired(): boolean {\n return !this.#cache || Date.now() - this.#cache.timestamp > this.#ttl;\n }\n\n #hasAllAddresses(addresses: string[]): boolean {\n if (!this.#cache) {\n return false;\n }\n return addresses.every((address) => this.#cache?.data.has(address));\n }\n\n get(addresses: string[]): { address: string; enabled: boolean }[] | null {\n if (this.#isExpired() || !this.#hasAllAddresses(addresses)) {\n return null;\n }\n\n return addresses.map((address) => ({\n address,\n enabled: this.#cache?.data.get(address) ?? false,\n }));\n }\n\n set(data: { address: string; enabled: boolean }[]): void {\n let map: Map<string, boolean> = new Map<string, boolean>();\n\n // If we have existing cache, preserve it and update with new data\n if (this.#cache && !this.#isExpired()) {\n map = new Map(this.#cache.data);\n }\n\n // Update with new data\n data.forEach(({ address, enabled }) => {\n map.set(address, enabled);\n });\n\n this.#cache = {\n data: map,\n timestamp: Date.now(),\n };\n }\n\n clear(): void {\n this.#cache = null;\n }\n}\n\nexport const notificationsConfigCache = new OnChainNotificationsCache();\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPerpOrderNotification = exports.PERPS_API_CREATE_ORDERS = exports.PERPS_API = void 0;
|
|
4
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
5
|
+
exports.PERPS_API = 'https://perps.api.cx.metamask.io';
|
|
6
|
+
exports.PERPS_API_CREATE_ORDERS = `${exports.PERPS_API}/api/v1/orders`;
|
|
7
|
+
/**
|
|
8
|
+
* Sends a perp order to our API to create a perp order subscription
|
|
9
|
+
*
|
|
10
|
+
* @param bearerToken - JWT for authentication
|
|
11
|
+
* @param orderInput - order input shape
|
|
12
|
+
*/
|
|
13
|
+
async function createPerpOrderNotification(bearerToken, orderInput) {
|
|
14
|
+
try {
|
|
15
|
+
await (0, controller_utils_1.createServicePolicy)().execute(async () => {
|
|
16
|
+
return (0, controller_utils_1.successfulFetch)(exports.PERPS_API_CREATE_ORDERS, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
Authorization: `Bearer ${bearerToken}`,
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify(orderInput),
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Failed to create perp order notification', error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.createPerpOrderNotification = createPerpOrderNotification;
|
|
31
|
+
//# sourceMappingURL=perp-notifications.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perp-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/perp-notifications.ts"],"names":[],"mappings":";;;AAAA,iEAGoC;AAIvB,QAAA,SAAS,GAAG,kCAAkC,CAAC;AAC/C,QAAA,uBAAuB,GAAG,GAAG,iBAAS,gBAAgB,CAAC;AAEpE;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAC/C,WAAmB,EACnB,UAAsB;IAEtB,IAAI,CAAC;QACH,MAAM,IAAA,sCAAmB,GAAE,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;YAC7C,OAAO,IAAA,kCAAe,EAAC,+BAAuB,EAAE;gBAC9C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,aAAa,EAAE,UAAU,WAAW,EAAE;iBACvC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;aACjC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAlBD,kEAkBC","sourcesContent":["import {\n createServicePolicy,\n successfulFetch,\n} from '@metamask/controller-utils';\n\nimport type { OrderInput } from '../types/index.js';\n\nexport const PERPS_API = 'https://perps.api.cx.metamask.io';\nexport const PERPS_API_CREATE_ORDERS = `${PERPS_API}/api/v1/orders`;\n\n/**\n * Sends a perp order to our API to create a perp order subscription\n *\n * @param bearerToken - JWT for authentication\n * @param orderInput - order input shape\n */\nexport async function createPerpOrderNotification(\n bearerToken: string,\n orderInput: OrderInput,\n): Promise<void> {\n try {\n await createServicePolicy().execute(async () => {\n return successfulFetch(PERPS_API_CREATE_ORDERS, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify(orderInput),\n });\n });\n } catch (error) {\n console.error('Failed to create perp order notification', error);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OrderInput } from
|
|
1
|
+
import type { OrderInput } from "../types/index.cjs";
|
|
2
2
|
export declare const PERPS_API = "https://perps.api.cx.metamask.io";
|
|
3
3
|
export declare const PERPS_API_CREATE_ORDERS = "https://perps.api.cx.metamask.io/api/v1/orders";
|
|
4
4
|
/**
|
|
@@ -8,4 +8,4 @@ export declare const PERPS_API_CREATE_ORDERS = "https://perps.api.cx.metamask.io
|
|
|
8
8
|
* @param orderInput - order input shape
|
|
9
9
|
*/
|
|
10
10
|
export declare function createPerpOrderNotification(bearerToken: string, orderInput: OrderInput): Promise<void>;
|
|
11
|
-
//# sourceMappingURL=perp-notifications.d.
|
|
11
|
+
//# sourceMappingURL=perp-notifications.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perp-notifications.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/perp-notifications.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,2BAA0B;AAEpD,eAAO,MAAM,SAAS,qCAAqC,CAAC;AAC5D,eAAO,MAAM,uBAAuB,mDAA+B,CAAC;AAEpE;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAef"}
|