@metamask-previews/notification-services-controller 0.0.0-preview-b09c2ed
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 +14 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/NotificationServicesController/NotificationServicesController.js +18 -0
- package/dist/NotificationServicesController/NotificationServicesController.js.map +1 -0
- package/dist/NotificationServicesController/NotificationServicesController.mjs +18 -0
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/constants.js +10 -0
- package/dist/NotificationServicesController/constants/constants.js.map +1 -0
- package/dist/NotificationServicesController/constants/constants.mjs +10 -0
- package/dist/NotificationServicesController/constants/constants.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/index.js +27 -0
- package/dist/NotificationServicesController/constants/index.js.map +1 -0
- package/dist/NotificationServicesController/constants/index.mjs +27 -0
- package/dist/NotificationServicesController/constants/index.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.js +20 -0
- package/dist/NotificationServicesController/constants/notification-schema.js.map +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.mjs +20 -0
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -0
- package/dist/NotificationServicesController/index.js +44 -0
- package/dist/NotificationServicesController/index.js.map +1 -0
- package/dist/NotificationServicesController/index.mjs +44 -0
- package/dist/NotificationServicesController/index.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/index.js +22 -0
- package/dist/NotificationServicesController/processors/index.js.map +1 -0
- package/dist/NotificationServicesController/processors/index.mjs +22 -0
- package/dist/NotificationServicesController/processors/index.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.js +10 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.js.map +1 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +10 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-notifications.js +13 -0
- package/dist/NotificationServicesController/processors/process-notifications.js.map +1 -0
- package/dist/NotificationServicesController/processors/process-notifications.mjs +13 -0
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.js +8 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.js.map +1 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +8 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/services/feature-announcements.js +14 -0
- package/dist/NotificationServicesController/services/feature-announcements.js.map +1 -0
- package/dist/NotificationServicesController/services/feature-announcements.mjs +14 -0
- package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.js +29 -0
- package/dist/NotificationServicesController/services/onchain-notifications.js.map +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.mjs +29 -0
- package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js.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.js +5 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.js.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.mjs +5 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js.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.js +2 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.js.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.js +12 -0
- package/dist/NotificationServicesController/types/index.js.map +1 -0
- package/dist/NotificationServicesController/types/index.mjs +12 -0
- package/dist/NotificationServicesController/types/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.js +3 -0
- package/dist/NotificationServicesController/types/notification/index.js.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.mjs +3 -0
- package/dist/NotificationServicesController/types/notification/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/notification.js +2 -0
- package/dist/NotificationServicesController/types/notification/notification.js.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/on-chain-notification/index.js +3 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.js.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.mjs +3 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js +2 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +2 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.js +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.js.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.js +1 -0
- package/dist/NotificationServicesController/types/type-utils.js.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.mjs +1 -0
- package/dist/NotificationServicesController/types/type-utils.mjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.js +3 -0
- package/dist/NotificationServicesController/types/user-storage/index.js.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs +3 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.js +2 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.js.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +2 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/utils/utils.js +32 -0
- package/dist/NotificationServicesController/utils/utils.js.map +1 -0
- package/dist/NotificationServicesController/utils/utils.mjs +32 -0
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.js +34 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.js.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +34 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -0
- package/dist/NotificationServicesPushController/constants.js +26 -0
- package/dist/NotificationServicesPushController/constants.js.map +1 -0
- package/dist/NotificationServicesPushController/constants.mjs +26 -0
- package/dist/NotificationServicesPushController/constants.mjs.map +1 -0
- package/dist/NotificationServicesPushController/index.js +49 -0
- package/dist/NotificationServicesPushController/index.js.map +1 -0
- package/dist/NotificationServicesPushController/index.mjs +49 -0
- package/dist/NotificationServicesPushController/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/endpoints.js +8 -0
- package/dist/NotificationServicesPushController/services/endpoints.js.map +1 -0
- package/dist/NotificationServicesPushController/services/endpoints.mjs +8 -0
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.js +1 -0
- package/dist/NotificationServicesPushController/services/push/index.js.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs +1 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/push/push-web.js +37 -0
- package/dist/NotificationServicesPushController/services/push/push-web.js.map +1 -0
- package/dist/NotificationServicesPushController/services/push/push-web.mjs +37 -0
- package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/services.js +43 -0
- package/dist/NotificationServicesPushController/services/services.js.map +1 -0
- package/dist/NotificationServicesPushController/services/services.mjs +43 -0
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -0
- package/dist/NotificationServicesPushController/types/firebase.js +2 -0
- package/dist/NotificationServicesPushController/types/firebase.js.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.js +3 -0
- package/dist/NotificationServicesPushController/types/index.js.map +1 -0
- package/dist/NotificationServicesPushController/types/index.mjs +3 -0
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.js +14 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.js.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +14 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.js +36 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.js.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +36 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.js +46 -0
- package/dist/NotificationServicesPushController/utils/index.js.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.mjs +46 -0
- package/dist/NotificationServicesPushController/utils/index.mjs.map +1 -0
- package/dist/chunk-232HZSEV.js +7 -0
- package/dist/chunk-232HZSEV.js.map +1 -0
- package/dist/chunk-26CCETCM.mjs +70 -0
- package/dist/chunk-26CCETCM.mjs.map +1 -0
- package/dist/chunk-3F4M3OUO.mjs +119 -0
- package/dist/chunk-3F4M3OUO.mjs.map +1 -0
- package/dist/chunk-3ZS2HAEG.js +1 -0
- package/dist/chunk-3ZS2HAEG.js.map +1 -0
- package/dist/chunk-4BTNTREI.mjs +1 -0
- package/dist/chunk-4BTNTREI.mjs.map +1 -0
- package/dist/chunk-4QXAPVW3.mjs +1 -0
- package/dist/chunk-4QXAPVW3.mjs.map +1 -0
- package/dist/chunk-52CALMRA.js +28 -0
- package/dist/chunk-52CALMRA.js.map +1 -0
- package/dist/chunk-52NKJDI2.mjs +93 -0
- package/dist/chunk-52NKJDI2.mjs.map +1 -0
- package/dist/chunk-5OYPOYXZ.mjs +802 -0
- package/dist/chunk-5OYPOYXZ.mjs.map +1 -0
- package/dist/chunk-5WWCWQCE.js +214 -0
- package/dist/chunk-5WWCWQCE.js.map +1 -0
- package/dist/chunk-6B5FOWRH.js +119 -0
- package/dist/chunk-6B5FOWRH.js.map +1 -0
- package/dist/chunk-6ZDVTRRT.mjs +9 -0
- package/dist/chunk-6ZDVTRRT.mjs.map +1 -0
- package/dist/chunk-7LWR54U7.js +7 -0
- package/dist/chunk-7LWR54U7.js.map +1 -0
- package/dist/chunk-7RM3YNTD.mjs +1 -0
- package/dist/chunk-7RM3YNTD.mjs.map +1 -0
- package/dist/chunk-A2RPVX47.mjs +1 -0
- package/dist/chunk-A2RPVX47.mjs.map +1 -0
- package/dist/chunk-B25TJ7KS.js +8 -0
- package/dist/chunk-B25TJ7KS.js.map +1 -0
- package/dist/chunk-B4ECJJ5C.mjs +7 -0
- package/dist/chunk-B4ECJJ5C.mjs.map +1 -0
- package/dist/chunk-BONB66A2.mjs +14 -0
- package/dist/chunk-BONB66A2.mjs.map +1 -0
- package/dist/chunk-CQ6CGSKZ.js +35 -0
- package/dist/chunk-CQ6CGSKZ.js.map +1 -0
- package/dist/chunk-D42BBXBM.mjs +28 -0
- package/dist/chunk-D42BBXBM.mjs.map +1 -0
- package/dist/chunk-DMH4NSLF.js +1 -0
- package/dist/chunk-DMH4NSLF.js.map +1 -0
- package/dist/chunk-DNTK4U5M.js +4300 -0
- package/dist/chunk-DNTK4U5M.js.map +1 -0
- package/dist/chunk-DY4ELDRQ.js +176 -0
- package/dist/chunk-DY4ELDRQ.js.map +1 -0
- package/dist/chunk-EJ52BDLB.js +55 -0
- package/dist/chunk-EJ52BDLB.js.map +1 -0
- package/dist/chunk-EQWVJX6K.mjs +91 -0
- package/dist/chunk-EQWVJX6K.mjs.map +1 -0
- package/dist/chunk-FFQNSBPU.js +31 -0
- package/dist/chunk-FFQNSBPU.js.map +1 -0
- package/dist/chunk-G52DNXFH.mjs +1 -0
- package/dist/chunk-G52DNXFH.mjs.map +1 -0
- package/dist/chunk-GETQWOTI.js +1 -0
- package/dist/chunk-GETQWOTI.js.map +1 -0
- package/dist/chunk-GFAESVZA.js +48 -0
- package/dist/chunk-GFAESVZA.js.map +1 -0
- package/dist/chunk-HPUQYDVC.js +1 -0
- package/dist/chunk-HPUQYDVC.js.map +1 -0
- package/dist/chunk-IDO4JFV5.mjs +1 -0
- package/dist/chunk-IDO4JFV5.mjs.map +1 -0
- package/dist/chunk-IKWNHNJQ.mjs +8 -0
- package/dist/chunk-IKWNHNJQ.mjs.map +1 -0
- package/dist/chunk-IOMDG67D.mjs +7 -0
- package/dist/chunk-IOMDG67D.mjs.map +1 -0
- package/dist/chunk-IPI7BAW3.js +1 -0
- package/dist/chunk-IPI7BAW3.js.map +1 -0
- package/dist/chunk-JLHFZ2UG.mjs +31 -0
- package/dist/chunk-JLHFZ2UG.mjs.map +1 -0
- package/dist/chunk-JQ7WKFCI.mjs +1 -0
- package/dist/chunk-JQ7WKFCI.mjs.map +1 -0
- package/dist/chunk-KTQP5UDT.mjs +4300 -0
- package/dist/chunk-KTQP5UDT.mjs.map +1 -0
- package/dist/chunk-LYEXYTOI.js +14 -0
- package/dist/chunk-LYEXYTOI.js.map +1 -0
- package/dist/chunk-NJBJIZLR.js +93 -0
- package/dist/chunk-NJBJIZLR.js.map +1 -0
- package/dist/chunk-NMLYB3XT.js +149 -0
- package/dist/chunk-NMLYB3XT.js.map +1 -0
- package/dist/chunk-ODI2BTKS.mjs +55 -0
- package/dist/chunk-ODI2BTKS.mjs.map +1 -0
- package/dist/chunk-OUPWMPLU.mjs +214 -0
- package/dist/chunk-OUPWMPLU.mjs.map +1 -0
- package/dist/chunk-PGMXFZ6Y.js +207 -0
- package/dist/chunk-PGMXFZ6Y.js.map +1 -0
- package/dist/chunk-PIZCE3JD.js +243 -0
- package/dist/chunk-PIZCE3JD.js.map +1 -0
- package/dist/chunk-PNCS6GEX.mjs +1 -0
- package/dist/chunk-PNCS6GEX.mjs.map +1 -0
- package/dist/chunk-PROWNV4M.js +1 -0
- package/dist/chunk-PROWNV4M.js.map +1 -0
- package/dist/chunk-QB5IFRLA.mjs +1 -0
- package/dist/chunk-QB5IFRLA.mjs.map +1 -0
- package/dist/chunk-QTK2RMF7.mjs +29 -0
- package/dist/chunk-QTK2RMF7.mjs.map +1 -0
- package/dist/chunk-RAUV5UV4.mjs +1 -0
- package/dist/chunk-RAUV5UV4.mjs.map +1 -0
- package/dist/chunk-RQWUD2FB.mjs +48 -0
- package/dist/chunk-RQWUD2FB.mjs.map +1 -0
- package/dist/chunk-SMKJEA45.mjs +243 -0
- package/dist/chunk-SMKJEA45.mjs.map +1 -0
- package/dist/chunk-SSWX2N73.mjs +207 -0
- package/dist/chunk-SSWX2N73.mjs.map +1 -0
- package/dist/chunk-TLX5QQK5.js +9 -0
- package/dist/chunk-TLX5QQK5.js.map +1 -0
- package/dist/chunk-TT56I53C.mjs +149 -0
- package/dist/chunk-TT56I53C.mjs.map +1 -0
- package/dist/chunk-U74Q3BRP.mjs +1 -0
- package/dist/chunk-U74Q3BRP.mjs.map +1 -0
- package/dist/chunk-UIRZIKC3.mjs +187 -0
- package/dist/chunk-UIRZIKC3.mjs.map +1 -0
- package/dist/chunk-UPVIT75F.js +29 -0
- package/dist/chunk-UPVIT75F.js.map +1 -0
- package/dist/chunk-V46WVGWN.js +70 -0
- package/dist/chunk-V46WVGWN.js.map +1 -0
- package/dist/chunk-V5HMYDWE.js +1 -0
- package/dist/chunk-V5HMYDWE.js.map +1 -0
- package/dist/chunk-VC6J62JI.mjs +176 -0
- package/dist/chunk-VC6J62JI.mjs.map +1 -0
- package/dist/chunk-VE4DTN4R.mjs +35 -0
- package/dist/chunk-VE4DTN4R.mjs.map +1 -0
- package/dist/chunk-VOZ7Y2OO.js +187 -0
- package/dist/chunk-VOZ7Y2OO.js.map +1 -0
- package/dist/chunk-WRYFIWNK.js +1 -0
- package/dist/chunk-WRYFIWNK.js.map +1 -0
- package/dist/chunk-XNBTOK6G.js +802 -0
- package/dist/chunk-XNBTOK6G.js.map +1 -0
- package/dist/chunk-XZEVRYUE.js +1 -0
- package/dist/chunk-XZEVRYUE.js.map +1 -0
- package/dist/chunk-ZBNBZN5H.js +1 -0
- package/dist/chunk-ZBNBZN5H.js.map +1 -0
- package/dist/chunk-ZMNXLHAC.js +91 -0
- package/dist/chunk-ZMNXLHAC.js.map +1 -0
- package/dist/chunk-ZV3DFBO4.js +1 -0
- package/dist/chunk-ZV3DFBO4.js.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +43 -0
- package/dist/index.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/NotificationServicesController/NotificationServicesController.d.ts +222 -0
- package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/index.d.ts +7 -0
- package/dist/types/NotificationServicesController/__fixtures__/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts +15 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts +9 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts +35 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts +82 -0
- package/dist/types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/mockResponses.d.ts +28 -0
- package/dist/types/NotificationServicesController/__fixtures__/mockResponses.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/mockServices.d.ts +12 -0
- package/dist/types/NotificationServicesController/__fixtures__/mockServices.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/__fixtures__/test-utils.d.ts +14 -0
- package/dist/types/NotificationServicesController/__fixtures__/test-utils.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/constants/constants.d.ts +3 -0
- package/dist/types/NotificationServicesController/constants/constants.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/constants/index.d.ts +3 -0
- package/dist/types/NotificationServicesController/constants/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/constants/notification-schema.d.ts +42 -0
- package/dist/types/NotificationServicesController/constants/notification-schema.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/index.d.ts +6 -0
- package/dist/types/NotificationServicesController/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/processors/index.d.ts +4 -0
- package/dist/types/NotificationServicesController/processors/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/processors/process-feature-announcement.d.ts +19 -0
- package/dist/types/NotificationServicesController/processors/process-feature-announcement.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/processors/process-notifications.d.ts +19 -0
- package/dist/types/NotificationServicesController/processors/process-notifications.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/processors/process-onchain-notifications.d.ts +10 -0
- package/dist/types/NotificationServicesController/processors/process-onchain-notifications.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/services/feature-announcements.d.ts +28 -0
- package/dist/types/NotificationServicesController/services/feature-announcements.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts +62 -0
- package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts +30 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts +4 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts +38 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/type-links.d.ts +24 -0
- package/dist/types/NotificationServicesController/types/feature-announcement/type-links.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/index.d.ts +5 -0
- package/dist/types/NotificationServicesController/types/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/notification/index.d.ts +2 -0
- package/dist/types/NotificationServicesController/types/notification/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/notification/notification.d.ts +25 -0
- package/dist/types/NotificationServicesController/types/notification/notification.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts +2 -0
- package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts +42 -0
- package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/on-chain-notification/schema.d.ts +283 -0
- package/dist/types/NotificationServicesController/types/on-chain-notification/schema.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/type-utils.d.ts +7 -0
- package/dist/types/NotificationServicesController/types/type-utils.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/user-storage/index.d.ts +2 -0
- package/dist/types/NotificationServicesController/types/user-storage/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/types/user-storage/user-storage.d.ts +26 -0
- package/dist/types/NotificationServicesController/types/user-storage/user-storage.d.ts.map +1 -0
- package/dist/types/NotificationServicesController/utils/utils.d.ts +144 -0
- package/dist/types/NotificationServicesController/utils/utils.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts +103 -0
- package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts +3 -0
- package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts +43 -0
- package/dist/types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/__fixtures__/mockServices.d.ts +9 -0
- package/dist/types/NotificationServicesPushController/__fixtures__/mockServices.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/constants.d.ts +11 -0
- package/dist/types/NotificationServicesPushController/constants.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/index.d.ts +5 -0
- package/dist/types/NotificationServicesPushController/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/services/endpoints.d.ts +2 -0
- package/dist/types/NotificationServicesPushController/services/endpoints.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/services/push/index.d.ts +6 -0
- package/dist/types/NotificationServicesPushController/services/push/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts +32 -0
- package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/services/services.d.ts +95 -0
- package/dist/types/NotificationServicesPushController/services/services.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/types/firebase.d.ts +53 -0
- package/dist/types/NotificationServicesPushController/types/firebase.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/types/index.d.ts +2 -0
- package/dist/types/NotificationServicesPushController/types/index.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/utils/get-notification-data.d.ts +42 -0
- package/dist/types/NotificationServicesPushController/utils/get-notification-data.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/utils/get-notification-message.d.ts +67 -0
- package/dist/types/NotificationServicesPushController/utils/get-notification-message.d.ts.map +1 -0
- package/dist/types/NotificationServicesPushController/utils/index.d.ts +3 -0
- package/dist/types/NotificationServicesPushController/utils/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkGFAESVZAjs = require('./chunk-GFAESVZA.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkZMNXLHACjs = require('./chunk-ZMNXLHAC.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkVOZ7Y2OOjs = require('./chunk-VOZ7Y2OO.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkPIZCE3JDjs = require('./chunk-PIZCE3JD.js');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkTLX5QQK5js = require('./chunk-TLX5QQK5.js');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var _chunkV46WVGWNjs = require('./chunk-V46WVGWN.js');
|
|
30
|
+
|
|
31
|
+
// src/NotificationServicesController/NotificationServicesController.ts
|
|
32
|
+
var _basecontroller = require('@metamask/base-controller');
|
|
33
|
+
var _controllerutils = require('@metamask/controller-utils');
|
|
34
|
+
var _loglevel = require('loglevel'); var _loglevel2 = _interopRequireDefault(_loglevel);
|
|
35
|
+
var controllerName = "NotificationServicesController";
|
|
36
|
+
var metadata = {
|
|
37
|
+
subscriptionAccountsSeen: {
|
|
38
|
+
persist: true,
|
|
39
|
+
anonymous: true
|
|
40
|
+
},
|
|
41
|
+
isMetamaskNotificationsFeatureSeen: {
|
|
42
|
+
persist: true,
|
|
43
|
+
anonymous: false
|
|
44
|
+
},
|
|
45
|
+
isNotificationServicesEnabled: {
|
|
46
|
+
persist: true,
|
|
47
|
+
anonymous: false
|
|
48
|
+
},
|
|
49
|
+
isFeatureAnnouncementsEnabled: {
|
|
50
|
+
persist: true,
|
|
51
|
+
anonymous: false
|
|
52
|
+
},
|
|
53
|
+
metamaskNotificationsList: {
|
|
54
|
+
persist: true,
|
|
55
|
+
anonymous: true
|
|
56
|
+
},
|
|
57
|
+
metamaskNotificationsReadList: {
|
|
58
|
+
persist: true,
|
|
59
|
+
anonymous: true
|
|
60
|
+
},
|
|
61
|
+
isUpdatingMetamaskNotifications: {
|
|
62
|
+
persist: false,
|
|
63
|
+
anonymous: false
|
|
64
|
+
},
|
|
65
|
+
isFetchingMetamaskNotifications: {
|
|
66
|
+
persist: false,
|
|
67
|
+
anonymous: false
|
|
68
|
+
},
|
|
69
|
+
isUpdatingMetamaskNotificationsAccount: {
|
|
70
|
+
persist: false,
|
|
71
|
+
anonymous: false
|
|
72
|
+
},
|
|
73
|
+
isCheckingAccountsPresence: {
|
|
74
|
+
persist: false,
|
|
75
|
+
anonymous: false
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var defaultState = {
|
|
79
|
+
subscriptionAccountsSeen: [],
|
|
80
|
+
isMetamaskNotificationsFeatureSeen: false,
|
|
81
|
+
isNotificationServicesEnabled: false,
|
|
82
|
+
isFeatureAnnouncementsEnabled: false,
|
|
83
|
+
metamaskNotificationsList: [],
|
|
84
|
+
metamaskNotificationsReadList: [],
|
|
85
|
+
isUpdatingMetamaskNotifications: false,
|
|
86
|
+
isFetchingMetamaskNotifications: false,
|
|
87
|
+
isUpdatingMetamaskNotificationsAccount: [],
|
|
88
|
+
isCheckingAccountsPresence: false
|
|
89
|
+
};
|
|
90
|
+
var _auth, _storage, _pushNotifications, _accounts, _featureAnnouncementEnv, _registerMessageHandlers, registerMessageHandlers_fn, _clearLoadingStates, clearLoadingStates_fn, _assertAuthEnabled, assertAuthEnabled_fn, _getValidStorageKeyAndBearerToken, getValidStorageKeyAndBearerToken_fn, _performEnableProfileSyncing, _assertUserStorage, assertUserStorage_fn, _getUserStorage, getUserStorage_fn, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn, _setIsFetchingMetamaskNotifications, setIsFetchingMetamaskNotifications_fn, _setIsCheckingAccountsPresence, setIsCheckingAccountsPresence_fn, _updateUpdatingAccountsState, updateUpdatingAccountsState_fn, _clearUpdatingAccountsState, clearUpdatingAccountsState_fn;
|
|
91
|
+
var NotificationServicesController = class extends _basecontroller.BaseController {
|
|
92
|
+
/**
|
|
93
|
+
* Creates a NotificationServicesController instance.
|
|
94
|
+
*
|
|
95
|
+
* @param args - The arguments to this function.
|
|
96
|
+
* @param args.messenger - Messenger used to communicate with BaseV2 controller.
|
|
97
|
+
* @param args.state - Initial state to set on this controller.
|
|
98
|
+
* @param args.env - environment variables for a given controller.
|
|
99
|
+
* @param args.env.featureAnnouncements - env variables for feature announcements.
|
|
100
|
+
*/
|
|
101
|
+
constructor({
|
|
102
|
+
messenger,
|
|
103
|
+
state,
|
|
104
|
+
env
|
|
105
|
+
}) {
|
|
106
|
+
super({
|
|
107
|
+
messenger,
|
|
108
|
+
metadata,
|
|
109
|
+
name: controllerName,
|
|
110
|
+
state: { ...defaultState, ...state }
|
|
111
|
+
});
|
|
112
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _registerMessageHandlers);
|
|
113
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _clearLoadingStates);
|
|
114
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _assertAuthEnabled);
|
|
115
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _getValidStorageKeyAndBearerToken);
|
|
116
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _assertUserStorage);
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves and parses the user storage from the storage key.
|
|
119
|
+
*
|
|
120
|
+
* This method attempts to retrieve the user storage using the specified storage key,
|
|
121
|
+
* then parses the JSON string to an object. If the storage is not found or cannot be parsed,
|
|
122
|
+
* it throws an error.
|
|
123
|
+
*
|
|
124
|
+
* @returns The parsed user storage object or null
|
|
125
|
+
*/
|
|
126
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _getUserStorage);
|
|
127
|
+
/**
|
|
128
|
+
* Sets the state of notification creation process.
|
|
129
|
+
*
|
|
130
|
+
* This method updates the `isUpdatingMetamaskNotifications` state, which can be used to indicate
|
|
131
|
+
* whether the notification creation process is currently active or not. This is useful
|
|
132
|
+
* for UI elements that need to reflect the state of ongoing operations, such as loading
|
|
133
|
+
* indicators or disabled buttons during processing.
|
|
134
|
+
*
|
|
135
|
+
* @param isUpdatingMetamaskNotifications - A boolean value representing the new state of the notification creation process.
|
|
136
|
+
*/
|
|
137
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _setIsUpdatingMetamaskNotifications);
|
|
138
|
+
/**
|
|
139
|
+
* Updates the state to indicate whether fetching of MetaMask notifications is in progress.
|
|
140
|
+
*
|
|
141
|
+
* This method is used to set the `isFetchingMetamaskNotifications` state, which can be utilized
|
|
142
|
+
* to show or hide loading indicators in the UI when notifications are being fetched.
|
|
143
|
+
*
|
|
144
|
+
* @param isFetchingMetamaskNotifications - A boolean value representing the fetching state.
|
|
145
|
+
*/
|
|
146
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _setIsFetchingMetamaskNotifications);
|
|
147
|
+
/**
|
|
148
|
+
* Updates the state to indicate that the checking of accounts presence is in progress.
|
|
149
|
+
*
|
|
150
|
+
* This method modifies the `isCheckingAccountsPresence` state, which can be used to manage UI elements
|
|
151
|
+
* that depend on the status of account presence checks, such as displaying loading indicators or disabling
|
|
152
|
+
* buttons while the check is ongoing.
|
|
153
|
+
*
|
|
154
|
+
* @param isCheckingAccountsPresence - A boolean value indicating whether the account presence check is currently active.
|
|
155
|
+
*/
|
|
156
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _setIsCheckingAccountsPresence);
|
|
157
|
+
/**
|
|
158
|
+
* Updates the state to indicate that account updates are in progress.
|
|
159
|
+
* Removes duplicate accounts before updating the state.
|
|
160
|
+
*
|
|
161
|
+
* @param accounts - The accounts being updated.
|
|
162
|
+
*/
|
|
163
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _updateUpdatingAccountsState);
|
|
164
|
+
/**
|
|
165
|
+
* Clears the state indicating that account updates are complete.
|
|
166
|
+
*
|
|
167
|
+
* @param accounts - The accounts that have finished updating.
|
|
168
|
+
*/
|
|
169
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _clearUpdatingAccountsState);
|
|
170
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _auth, {
|
|
171
|
+
getBearerToken: async () => {
|
|
172
|
+
return await this.messagingSystem.call(
|
|
173
|
+
"AuthenticationController:getBearerToken"
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
isSignedIn: () => {
|
|
177
|
+
return this.messagingSystem.call("AuthenticationController:isSignedIn");
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _storage, {
|
|
181
|
+
enableProfileSyncing: async () => {
|
|
182
|
+
return await this.messagingSystem.call(
|
|
183
|
+
"UserStorageController:enableProfileSyncing"
|
|
184
|
+
);
|
|
185
|
+
},
|
|
186
|
+
getStorageKey: () => {
|
|
187
|
+
return this.messagingSystem.call("UserStorageController:getStorageKey");
|
|
188
|
+
},
|
|
189
|
+
getNotificationStorage: async () => {
|
|
190
|
+
return await this.messagingSystem.call(
|
|
191
|
+
"UserStorageController:performGetStorage",
|
|
192
|
+
"notificationSettings"
|
|
193
|
+
);
|
|
194
|
+
},
|
|
195
|
+
setNotificationStorage: async (state) => {
|
|
196
|
+
return await this.messagingSystem.call(
|
|
197
|
+
"UserStorageController:performSetStorage",
|
|
198
|
+
"notificationSettings",
|
|
199
|
+
state
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _pushNotifications, {
|
|
204
|
+
enablePushNotifications: async (UUIDs) => {
|
|
205
|
+
return await this.messagingSystem.call(
|
|
206
|
+
"NotificationServicesPushController:enablePushNotifications",
|
|
207
|
+
UUIDs
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
disablePushNotifications: async (UUIDs) => {
|
|
211
|
+
return await this.messagingSystem.call(
|
|
212
|
+
"NotificationServicesPushController:disablePushNotifications",
|
|
213
|
+
UUIDs
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
updatePushNotifications: async (UUIDs) => {
|
|
217
|
+
return await this.messagingSystem.call(
|
|
218
|
+
"NotificationServicesPushController:updateTriggerPushNotifications",
|
|
219
|
+
UUIDs
|
|
220
|
+
);
|
|
221
|
+
},
|
|
222
|
+
subscribe: () => {
|
|
223
|
+
this.messagingSystem.subscribe(
|
|
224
|
+
"NotificationServicesPushController:onNewNotifications",
|
|
225
|
+
(notification) => {
|
|
226
|
+
this.updateMetamaskNotificationsList(notification);
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
},
|
|
230
|
+
initializePushNotifications: async () => {
|
|
231
|
+
if (!this.state.isNotificationServicesEnabled) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const storage = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
|
|
235
|
+
if (!storage) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const uuids = _chunkPIZCE3JDjs.getAllUUIDs.call(void 0, storage);
|
|
239
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).enablePushNotifications(uuids);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _accounts, {
|
|
243
|
+
/**
|
|
244
|
+
* Used to get list of addresses from keyring (wallet addresses)
|
|
245
|
+
*
|
|
246
|
+
* @returns addresses removed, added, and latest list of addresses
|
|
247
|
+
*/
|
|
248
|
+
listAccounts: async () => {
|
|
249
|
+
const nonChecksumAccounts = await this.messagingSystem.call(
|
|
250
|
+
"KeyringController:getAccounts"
|
|
251
|
+
);
|
|
252
|
+
const accounts = nonChecksumAccounts.map((a) => _controllerutils.toChecksumHexAddress.call(void 0, a));
|
|
253
|
+
const currentAccountsSet = new Set(accounts);
|
|
254
|
+
const prevAccountsSet = new Set(this.state.subscriptionAccountsSeen);
|
|
255
|
+
if (accounts.length === 0) {
|
|
256
|
+
return {
|
|
257
|
+
accountsAdded: [],
|
|
258
|
+
accountsRemoved: [],
|
|
259
|
+
accounts: []
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const accountsAdded = accounts.filter((a) => !prevAccountsSet.has(a));
|
|
263
|
+
const accountsRemoved = [...prevAccountsSet.values()].filter(
|
|
264
|
+
(a) => !currentAccountsSet.has(a)
|
|
265
|
+
);
|
|
266
|
+
this.update((state) => {
|
|
267
|
+
state.subscriptionAccountsSeen = [...prevAccountsSet, ...accountsAdded];
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
accountsAdded,
|
|
271
|
+
accountsRemoved,
|
|
272
|
+
accounts
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
/**
|
|
276
|
+
* Initializes the cache/previous list. This is handy so we have an accurate in-mem state of the previous list of accounts.
|
|
277
|
+
*
|
|
278
|
+
* @returns result from list accounts
|
|
279
|
+
*/
|
|
280
|
+
initialize: () => {
|
|
281
|
+
return _chunkV46WVGWNjs.__privateGet.call(void 0, this, _accounts).listAccounts();
|
|
282
|
+
},
|
|
283
|
+
/**
|
|
284
|
+
* Subscription to any state change in the keyring controller (aka wallet accounts).
|
|
285
|
+
* We can call the `listAccounts` defined above to find out about any accounts added, removed
|
|
286
|
+
* And call effects to subscribe/unsubscribe to notifications.
|
|
287
|
+
*/
|
|
288
|
+
subscribe: () => {
|
|
289
|
+
this.messagingSystem.subscribe(
|
|
290
|
+
"KeyringController:stateChange",
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
292
|
+
async () => {
|
|
293
|
+
if (!this.state.isNotificationServicesEnabled) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const { accountsAdded, accountsRemoved } = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _accounts).listAccounts();
|
|
297
|
+
const promises = [];
|
|
298
|
+
if (accountsAdded.length > 0) {
|
|
299
|
+
promises.push(this.updateOnChainTriggersByAccount(accountsAdded));
|
|
300
|
+
}
|
|
301
|
+
if (accountsRemoved.length > 0) {
|
|
302
|
+
promises.push(this.deleteOnChainTriggersByAccount(accountsRemoved));
|
|
303
|
+
}
|
|
304
|
+
await Promise.all(promises);
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _featureAnnouncementEnv, void 0);
|
|
310
|
+
_chunkV46WVGWNjs.__privateAdd.call(void 0, this, _performEnableProfileSyncing, async () => {
|
|
311
|
+
try {
|
|
312
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).enableProfileSyncing();
|
|
313
|
+
} catch (e) {
|
|
314
|
+
_loglevel2.default.error("Failed to enable profile syncing", e);
|
|
315
|
+
throw new Error("Failed to enable profile syncing");
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
_chunkV46WVGWNjs.__privateSet.call(void 0, this, _featureAnnouncementEnv, env.featureAnnouncements);
|
|
319
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
|
|
320
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _clearLoadingStates, clearLoadingStates_fn).call(this);
|
|
321
|
+
_chunkV46WVGWNjs.__privateGet.call(void 0, this, _accounts).initialize();
|
|
322
|
+
_chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).initializePushNotifications();
|
|
323
|
+
_chunkV46WVGWNjs.__privateGet.call(void 0, this, _accounts).subscribe();
|
|
324
|
+
_chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).subscribe();
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Retrieves the current enabled state of MetaMask notifications.
|
|
328
|
+
*
|
|
329
|
+
* This method directly returns the boolean value of `isMetamaskNotificationsEnabled`
|
|
330
|
+
* from the controller's state, indicating whether MetaMask notifications are currently enabled.
|
|
331
|
+
*
|
|
332
|
+
* @returns The enabled state of MetaMask notifications.
|
|
333
|
+
*/
|
|
334
|
+
selectIsNotificationServicesEnabled() {
|
|
335
|
+
return this.state.isNotificationServicesEnabled;
|
|
336
|
+
}
|
|
337
|
+
async checkAccountsPresence(accounts) {
|
|
338
|
+
try {
|
|
339
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsCheckingAccountsPresence, setIsCheckingAccountsPresence_fn).call(this, true);
|
|
340
|
+
const userStorage = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
|
|
341
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
|
|
342
|
+
const presence = _chunkPIZCE3JDjs.checkAccountsPresence.call(void 0, userStorage, accounts);
|
|
343
|
+
return presence;
|
|
344
|
+
} catch (error) {
|
|
345
|
+
_loglevel2.default.error("Failed to check accounts presence", error);
|
|
346
|
+
throw error;
|
|
347
|
+
} finally {
|
|
348
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsCheckingAccountsPresence, setIsCheckingAccountsPresence_fn).call(this, false);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Sets the enabled state of feature announcements.
|
|
353
|
+
*
|
|
354
|
+
* **Action** - used in the notification settings to enable/disable feature announcements.
|
|
355
|
+
*
|
|
356
|
+
* @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.
|
|
357
|
+
* @async
|
|
358
|
+
* @throws {Error} If fails to update
|
|
359
|
+
*/
|
|
360
|
+
async setFeatureAnnouncementsEnabled(featureAnnouncementsEnabled) {
|
|
361
|
+
try {
|
|
362
|
+
this.update((s) => {
|
|
363
|
+
s.isFeatureAnnouncementsEnabled = featureAnnouncementsEnabled;
|
|
364
|
+
});
|
|
365
|
+
} catch (e) {
|
|
366
|
+
_loglevel2.default.error("Unable to toggle feature announcements", e);
|
|
367
|
+
throw new Error("Unable to toggle feature announcements");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* This creates/re-creates on-chain triggers defined in User Storage.
|
|
372
|
+
*
|
|
373
|
+
* **Action** - Used during Sign In / Enabling of notifications.
|
|
374
|
+
*
|
|
375
|
+
* @returns The updated or newly created user storage.
|
|
376
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
377
|
+
*/
|
|
378
|
+
async createOnChainTriggers() {
|
|
379
|
+
try {
|
|
380
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, true);
|
|
381
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _performEnableProfileSyncing).call(this);
|
|
382
|
+
const { bearerToken, storageKey } = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getValidStorageKeyAndBearerToken, getValidStorageKeyAndBearerToken_fn).call(this);
|
|
383
|
+
const { accounts } = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _accounts).listAccounts();
|
|
384
|
+
let userStorage = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
|
|
385
|
+
if (userStorage?.[_chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY] === void 0) {
|
|
386
|
+
userStorage = _chunkPIZCE3JDjs.initializeUserStorage.call(void 0,
|
|
387
|
+
accounts.map((account) => ({ address: account })),
|
|
388
|
+
false
|
|
389
|
+
);
|
|
390
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
|
|
391
|
+
}
|
|
392
|
+
const triggers = _chunkPIZCE3JDjs.traverseUserStorageTriggers.call(void 0, userStorage);
|
|
393
|
+
await _chunkVOZ7Y2OOjs.createOnChainTriggers.call(void 0,
|
|
394
|
+
userStorage,
|
|
395
|
+
storageKey,
|
|
396
|
+
bearerToken,
|
|
397
|
+
triggers
|
|
398
|
+
);
|
|
399
|
+
const allUUIDS = _chunkPIZCE3JDjs.getAllUUIDs.call(void 0, userStorage);
|
|
400
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).enablePushNotifications(allUUIDS);
|
|
401
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
|
|
402
|
+
this.update((state) => {
|
|
403
|
+
state.isNotificationServicesEnabled = true;
|
|
404
|
+
state.isFeatureAnnouncementsEnabled = true;
|
|
405
|
+
state.isMetamaskNotificationsFeatureSeen = true;
|
|
406
|
+
});
|
|
407
|
+
return userStorage;
|
|
408
|
+
} catch (err) {
|
|
409
|
+
_loglevel2.default.error("Failed to create On Chain triggers", err);
|
|
410
|
+
throw new Error("Failed to create On Chain triggers");
|
|
411
|
+
} finally {
|
|
412
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, false);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Enables all MetaMask notifications for the user.
|
|
417
|
+
* This is identical flow when initializing notifications for the first time.
|
|
418
|
+
* 1. Enable Profile Syncing
|
|
419
|
+
* 2. Get or Create Notification User Storage
|
|
420
|
+
* 3. Upsert Triggers
|
|
421
|
+
* 4. Update Push notifications
|
|
422
|
+
*
|
|
423
|
+
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
424
|
+
*/
|
|
425
|
+
async enableMetamaskNotifications() {
|
|
426
|
+
try {
|
|
427
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, true);
|
|
428
|
+
await this.createOnChainTriggers();
|
|
429
|
+
} catch (e) {
|
|
430
|
+
_loglevel2.default.error("Unable to enable notifications", e);
|
|
431
|
+
throw new Error("Unable to enable notifications");
|
|
432
|
+
} finally {
|
|
433
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, false);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Disables all MetaMask notifications for the user.
|
|
438
|
+
* This method ensures that the user is authenticated, retrieves all linked accounts,
|
|
439
|
+
* and disables on-chain triggers for each account. It also sets the global notification
|
|
440
|
+
* settings for MetaMask, feature announcements to false.
|
|
441
|
+
*
|
|
442
|
+
* @throws {Error} If the user is not authenticated or if there is an error during the process.
|
|
443
|
+
*/
|
|
444
|
+
async disableNotificationServices() {
|
|
445
|
+
try {
|
|
446
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, true);
|
|
447
|
+
const userStorage = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
|
|
448
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
|
|
449
|
+
const UUIDs = _chunkPIZCE3JDjs.getAllUUIDs.call(void 0, userStorage);
|
|
450
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).disablePushNotifications(UUIDs);
|
|
451
|
+
this.update((state) => {
|
|
452
|
+
state.isNotificationServicesEnabled = false;
|
|
453
|
+
state.isFeatureAnnouncementsEnabled = false;
|
|
454
|
+
state.metamaskNotificationsList = [];
|
|
455
|
+
});
|
|
456
|
+
} catch (e) {
|
|
457
|
+
_loglevel2.default.error("Unable to disable notifications", e);
|
|
458
|
+
throw new Error("Unable to disable notifications");
|
|
459
|
+
} finally {
|
|
460
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, false);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Deletes on-chain triggers associated with a specific account.
|
|
465
|
+
* This method performs several key operations:
|
|
466
|
+
* 1. Validates Auth & Storage
|
|
467
|
+
* 2. Finds and deletes all triggers associated with the account
|
|
468
|
+
* 3. Disables any related push notifications
|
|
469
|
+
* 4. Updates Storage to reflect new state.
|
|
470
|
+
*
|
|
471
|
+
* **Action** - When a user disables notifications for a given account in settings.
|
|
472
|
+
*
|
|
473
|
+
* @param accounts - The account for which on-chain triggers are to be deleted.
|
|
474
|
+
* @returns A promise that resolves to void or an object containing a success message.
|
|
475
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
476
|
+
*/
|
|
477
|
+
async deleteOnChainTriggersByAccount(accounts) {
|
|
478
|
+
try {
|
|
479
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _updateUpdatingAccountsState, updateUpdatingAccountsState_fn).call(this, accounts);
|
|
480
|
+
const { bearerToken, storageKey } = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getValidStorageKeyAndBearerToken, getValidStorageKeyAndBearerToken_fn).call(this);
|
|
481
|
+
const userStorage = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
|
|
482
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
|
|
483
|
+
const UUIDs = accounts.map((a) => _chunkPIZCE3JDjs.getUUIDsForAccount.call(void 0, userStorage, a.toLowerCase())).flat();
|
|
484
|
+
if (UUIDs.length === 0) {
|
|
485
|
+
return userStorage;
|
|
486
|
+
}
|
|
487
|
+
await _chunkVOZ7Y2OOjs.deleteOnChainTriggers.call(void 0,
|
|
488
|
+
userStorage,
|
|
489
|
+
storageKey,
|
|
490
|
+
bearerToken,
|
|
491
|
+
UUIDs
|
|
492
|
+
);
|
|
493
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).disablePushNotifications(UUIDs);
|
|
494
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
|
|
495
|
+
return userStorage;
|
|
496
|
+
} catch (err) {
|
|
497
|
+
_loglevel2.default.error("Failed to delete OnChain triggers", err);
|
|
498
|
+
throw new Error("Failed to delete OnChain triggers");
|
|
499
|
+
} finally {
|
|
500
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _clearUpdatingAccountsState, clearUpdatingAccountsState_fn).call(this, accounts);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Updates/Creates on-chain triggers for a specific account.
|
|
505
|
+
*
|
|
506
|
+
* This method performs several key operations:
|
|
507
|
+
* 1. Validates Auth & Storage
|
|
508
|
+
* 2. Finds and creates any missing triggers associated with the account
|
|
509
|
+
* 3. Enables any related push notifications
|
|
510
|
+
* 4. Updates Storage to reflect new state.
|
|
511
|
+
*
|
|
512
|
+
* **Action** - When a user enables notifications for an account
|
|
513
|
+
*
|
|
514
|
+
* @param accounts - List of accounts you want to update.
|
|
515
|
+
* @returns A promise that resolves to the updated user storage.
|
|
516
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
517
|
+
*/
|
|
518
|
+
async updateOnChainTriggersByAccount(accounts) {
|
|
519
|
+
try {
|
|
520
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _updateUpdatingAccountsState, updateUpdatingAccountsState_fn).call(this, accounts);
|
|
521
|
+
const { bearerToken, storageKey } = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getValidStorageKeyAndBearerToken, getValidStorageKeyAndBearerToken_fn).call(this);
|
|
522
|
+
const userStorage = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
|
|
523
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
|
|
524
|
+
accounts.forEach((a) => _chunkPIZCE3JDjs.upsertAddressTriggers.call(void 0, a, userStorage));
|
|
525
|
+
const newTriggers = _chunkPIZCE3JDjs.traverseUserStorageTriggers.call(void 0, userStorage, {
|
|
526
|
+
mapTrigger: (t) => {
|
|
527
|
+
if (!t.enabled) {
|
|
528
|
+
return t;
|
|
529
|
+
}
|
|
530
|
+
return void 0;
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
if (newTriggers.length > 0) {
|
|
534
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
|
|
535
|
+
const triggers = _chunkPIZCE3JDjs.traverseUserStorageTriggers.call(void 0, userStorage, {
|
|
536
|
+
mapTrigger: (t) => {
|
|
537
|
+
if (accounts.some((a) => a.toLowerCase() === t.address.toLowerCase())) {
|
|
538
|
+
return t;
|
|
539
|
+
}
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
await _chunkVOZ7Y2OOjs.createOnChainTriggers.call(void 0,
|
|
544
|
+
userStorage,
|
|
545
|
+
storageKey,
|
|
546
|
+
bearerToken,
|
|
547
|
+
triggers
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
const UUIDs = _chunkPIZCE3JDjs.getAllUUIDs.call(void 0, userStorage);
|
|
551
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _pushNotifications).updatePushNotifications(UUIDs);
|
|
552
|
+
await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
|
|
553
|
+
return userStorage;
|
|
554
|
+
} catch (err) {
|
|
555
|
+
_loglevel2.default.error("Failed to update OnChain triggers", err);
|
|
556
|
+
throw new Error("Failed to update OnChain triggers");
|
|
557
|
+
} finally {
|
|
558
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _clearUpdatingAccountsState, clearUpdatingAccountsState_fn).call(this, accounts);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Fetches the list of metamask notifications.
|
|
563
|
+
* This includes OnChain notifications and Feature Announcements.
|
|
564
|
+
*
|
|
565
|
+
* **Action** - When a user views the notification list page/dropdown
|
|
566
|
+
*
|
|
567
|
+
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
568
|
+
*/
|
|
569
|
+
async fetchAndUpdateMetamaskNotifications() {
|
|
570
|
+
try {
|
|
571
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsFetchingMetamaskNotifications, setIsFetchingMetamaskNotifications_fn).call(this, true);
|
|
572
|
+
const rawFeatureAnnouncementNotifications = this.state.isFeatureAnnouncementsEnabled ? await _chunkZMNXLHACjs.getFeatureAnnouncementNotifications.call(void 0,
|
|
573
|
+
_chunkV46WVGWNjs.__privateGet.call(void 0, this, _featureAnnouncementEnv)
|
|
574
|
+
).catch(() => []) : [];
|
|
575
|
+
const rawOnChainNotifications = [];
|
|
576
|
+
const userStorage = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).getNotificationStorage().then((s) => s && JSON.parse(s)).catch(() => null);
|
|
577
|
+
const bearerToken = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _auth).getBearerToken().catch(() => null);
|
|
578
|
+
if (userStorage && bearerToken) {
|
|
579
|
+
const notifications = await _chunkVOZ7Y2OOjs.getOnChainNotifications.call(void 0,
|
|
580
|
+
userStorage,
|
|
581
|
+
bearerToken
|
|
582
|
+
).catch(() => []);
|
|
583
|
+
rawOnChainNotifications.push(...notifications);
|
|
584
|
+
}
|
|
585
|
+
const readIds = this.state.metamaskNotificationsReadList;
|
|
586
|
+
const isNotUndefined = (t) => Boolean(t);
|
|
587
|
+
const processAndFilter = (ns) => ns.map((n) => _chunkGFAESVZAjs.safeProcessNotification.call(void 0, n, readIds)).filter(isNotUndefined);
|
|
588
|
+
const featureAnnouncementNotifications = processAndFilter(
|
|
589
|
+
rawFeatureAnnouncementNotifications
|
|
590
|
+
);
|
|
591
|
+
const onChainNotifications = processAndFilter(rawOnChainNotifications);
|
|
592
|
+
const metamaskNotifications = [
|
|
593
|
+
...featureAnnouncementNotifications,
|
|
594
|
+
...onChainNotifications
|
|
595
|
+
];
|
|
596
|
+
metamaskNotifications.sort(
|
|
597
|
+
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
598
|
+
);
|
|
599
|
+
this.update((state) => {
|
|
600
|
+
state.metamaskNotificationsList = metamaskNotifications;
|
|
601
|
+
});
|
|
602
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsFetchingMetamaskNotifications, setIsFetchingMetamaskNotifications_fn).call(this, false);
|
|
603
|
+
return metamaskNotifications;
|
|
604
|
+
} catch (err) {
|
|
605
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _setIsFetchingMetamaskNotifications, setIsFetchingMetamaskNotifications_fn).call(this, false);
|
|
606
|
+
_loglevel2.default.error("Failed to fetch notifications", err);
|
|
607
|
+
throw new Error("Failed to fetch notifications");
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Marks specified metamask notifications as read.
|
|
612
|
+
*
|
|
613
|
+
* @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.
|
|
614
|
+
* @returns A promise that resolves when the operation is complete.
|
|
615
|
+
*/
|
|
616
|
+
async markMetamaskNotificationsAsRead(notifications) {
|
|
617
|
+
let onchainNotificationIds = [];
|
|
618
|
+
let featureAnnouncementNotificationIds = [];
|
|
619
|
+
try {
|
|
620
|
+
const onChainNotifications = notifications.filter(
|
|
621
|
+
(notification) => notification.type !== "features_announcement" /* FEATURES_ANNOUNCEMENT */ && !notification.isRead
|
|
622
|
+
);
|
|
623
|
+
const featureAnnouncementNotifications = notifications.filter(
|
|
624
|
+
(notification) => notification.type === "features_announcement" /* FEATURES_ANNOUNCEMENT */ && !notification.isRead
|
|
625
|
+
);
|
|
626
|
+
if (onChainNotifications.length > 0) {
|
|
627
|
+
const bearerToken = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _auth).getBearerToken();
|
|
628
|
+
if (bearerToken) {
|
|
629
|
+
onchainNotificationIds = onChainNotifications.map(
|
|
630
|
+
(notification) => notification.id
|
|
631
|
+
);
|
|
632
|
+
await _chunkVOZ7Y2OOjs.markNotificationsAsRead.call(void 0,
|
|
633
|
+
bearerToken,
|
|
634
|
+
onchainNotificationIds
|
|
635
|
+
).catch(() => {
|
|
636
|
+
onchainNotificationIds = [];
|
|
637
|
+
_loglevel2.default.warn("Unable to mark onchain notifications as read");
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (featureAnnouncementNotifications.length > 0) {
|
|
642
|
+
featureAnnouncementNotificationIds = featureAnnouncementNotifications.map(
|
|
643
|
+
(notification) => notification.id
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
} catch (err) {
|
|
647
|
+
_loglevel2.default.warn("Something failed when marking notifications as read", err);
|
|
648
|
+
}
|
|
649
|
+
this.update((state) => {
|
|
650
|
+
const currentReadList = state.metamaskNotificationsReadList;
|
|
651
|
+
const newReadIds = [...featureAnnouncementNotificationIds];
|
|
652
|
+
state.metamaskNotificationsReadList = [
|
|
653
|
+
.../* @__PURE__ */ new Set([...currentReadList, ...newReadIds])
|
|
654
|
+
];
|
|
655
|
+
state.metamaskNotificationsList = state.metamaskNotificationsList.map(
|
|
656
|
+
(notification) => {
|
|
657
|
+
if (newReadIds.includes(notification.id) || onchainNotificationIds.includes(notification.id)) {
|
|
658
|
+
return { ...notification, isRead: true };
|
|
659
|
+
}
|
|
660
|
+
return notification;
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.
|
|
667
|
+
* This method ensures that the most recent notification is displayed first in the UI.
|
|
668
|
+
*
|
|
669
|
+
* @param notification - The new notification object to be added to the list.
|
|
670
|
+
* @returns A promise that resolves when the notification list has been successfully updated.
|
|
671
|
+
*/
|
|
672
|
+
async updateMetamaskNotificationsList(notification) {
|
|
673
|
+
if (this.state.metamaskNotificationsList.some((n) => n.id === notification.id)) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const processedNotification = _chunkGFAESVZAjs.safeProcessNotification.call(void 0, notification);
|
|
677
|
+
if (processedNotification) {
|
|
678
|
+
this.update((state) => {
|
|
679
|
+
const existingNotificationIds = new Set(
|
|
680
|
+
state.metamaskNotificationsList.map((n) => n.id)
|
|
681
|
+
);
|
|
682
|
+
if (!existingNotificationIds.has(notification.id)) {
|
|
683
|
+
state.metamaskNotificationsList = [
|
|
684
|
+
notification,
|
|
685
|
+
...state.metamaskNotificationsList
|
|
686
|
+
];
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
_auth = new WeakMap();
|
|
693
|
+
_storage = new WeakMap();
|
|
694
|
+
_pushNotifications = new WeakMap();
|
|
695
|
+
_accounts = new WeakMap();
|
|
696
|
+
_featureAnnouncementEnv = new WeakMap();
|
|
697
|
+
_registerMessageHandlers = new WeakSet();
|
|
698
|
+
registerMessageHandlers_fn = function() {
|
|
699
|
+
this.messagingSystem.registerActionHandler(
|
|
700
|
+
`${controllerName}:updateMetamaskNotificationsList`,
|
|
701
|
+
this.updateMetamaskNotificationsList.bind(this)
|
|
702
|
+
);
|
|
703
|
+
this.messagingSystem.registerActionHandler(
|
|
704
|
+
`${controllerName}:disableNotificationServices`,
|
|
705
|
+
this.disableNotificationServices.bind(this)
|
|
706
|
+
);
|
|
707
|
+
this.messagingSystem.registerActionHandler(
|
|
708
|
+
`${controllerName}:selectIsNotificationServicesEnabled`,
|
|
709
|
+
this.selectIsNotificationServicesEnabled.bind(this)
|
|
710
|
+
);
|
|
711
|
+
};
|
|
712
|
+
_clearLoadingStates = new WeakSet();
|
|
713
|
+
clearLoadingStates_fn = function() {
|
|
714
|
+
this.update((state) => {
|
|
715
|
+
state.isUpdatingMetamaskNotifications = false;
|
|
716
|
+
state.isCheckingAccountsPresence = false;
|
|
717
|
+
state.isFetchingMetamaskNotifications = false;
|
|
718
|
+
state.isUpdatingMetamaskNotificationsAccount = [];
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
_assertAuthEnabled = new WeakSet();
|
|
722
|
+
assertAuthEnabled_fn = function() {
|
|
723
|
+
if (!_chunkV46WVGWNjs.__privateGet.call(void 0, this, _auth).isSignedIn()) {
|
|
724
|
+
this.update((state) => {
|
|
725
|
+
state.isNotificationServicesEnabled = false;
|
|
726
|
+
});
|
|
727
|
+
throw new Error("User is not signed in.");
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
_getValidStorageKeyAndBearerToken = new WeakSet();
|
|
731
|
+
getValidStorageKeyAndBearerToken_fn = async function() {
|
|
732
|
+
_chunkV46WVGWNjs.__privateMethod.call(void 0, this, _assertAuthEnabled, assertAuthEnabled_fn).call(this);
|
|
733
|
+
const bearerToken = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _auth).getBearerToken();
|
|
734
|
+
const storageKey = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).getStorageKey();
|
|
735
|
+
if (!bearerToken || !storageKey) {
|
|
736
|
+
throw new Error("Missing BearerToken or storage key");
|
|
737
|
+
}
|
|
738
|
+
return { bearerToken, storageKey };
|
|
739
|
+
};
|
|
740
|
+
_performEnableProfileSyncing = new WeakMap();
|
|
741
|
+
_assertUserStorage = new WeakSet();
|
|
742
|
+
assertUserStorage_fn = function(storage) {
|
|
743
|
+
if (!storage) {
|
|
744
|
+
throw new Error("User Storage does not exist");
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
_getUserStorage = new WeakSet();
|
|
748
|
+
getUserStorage_fn = async function() {
|
|
749
|
+
const userStorageString = await _chunkV46WVGWNjs.__privateGet.call(void 0, this, _storage).getNotificationStorage();
|
|
750
|
+
if (!userStorageString) {
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
try {
|
|
754
|
+
const userStorage = JSON.parse(userStorageString);
|
|
755
|
+
return userStorage;
|
|
756
|
+
} catch (error) {
|
|
757
|
+
_loglevel2.default.error("Unable to parse User Storage");
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
_setIsUpdatingMetamaskNotifications = new WeakSet();
|
|
762
|
+
setIsUpdatingMetamaskNotifications_fn = function(isUpdatingMetamaskNotifications) {
|
|
763
|
+
this.update((state) => {
|
|
764
|
+
state.isUpdatingMetamaskNotifications = isUpdatingMetamaskNotifications;
|
|
765
|
+
});
|
|
766
|
+
};
|
|
767
|
+
_setIsFetchingMetamaskNotifications = new WeakSet();
|
|
768
|
+
setIsFetchingMetamaskNotifications_fn = function(isFetchingMetamaskNotifications) {
|
|
769
|
+
this.update((state) => {
|
|
770
|
+
state.isFetchingMetamaskNotifications = isFetchingMetamaskNotifications;
|
|
771
|
+
});
|
|
772
|
+
};
|
|
773
|
+
_setIsCheckingAccountsPresence = new WeakSet();
|
|
774
|
+
setIsCheckingAccountsPresence_fn = function(isCheckingAccountsPresence) {
|
|
775
|
+
this.update((state) => {
|
|
776
|
+
state.isCheckingAccountsPresence = isCheckingAccountsPresence;
|
|
777
|
+
});
|
|
778
|
+
};
|
|
779
|
+
_updateUpdatingAccountsState = new WeakSet();
|
|
780
|
+
updateUpdatingAccountsState_fn = function(accounts) {
|
|
781
|
+
this.update((state) => {
|
|
782
|
+
const uniqueAccounts = /* @__PURE__ */ new Set([
|
|
783
|
+
...state.isUpdatingMetamaskNotificationsAccount,
|
|
784
|
+
...accounts
|
|
785
|
+
]);
|
|
786
|
+
state.isUpdatingMetamaskNotificationsAccount = Array.from(uniqueAccounts);
|
|
787
|
+
});
|
|
788
|
+
};
|
|
789
|
+
_clearUpdatingAccountsState = new WeakSet();
|
|
790
|
+
clearUpdatingAccountsState_fn = function(accounts) {
|
|
791
|
+
this.update((state) => {
|
|
792
|
+
state.isUpdatingMetamaskNotificationsAccount = state.isUpdatingMetamaskNotificationsAccount.filter(
|
|
793
|
+
(existingAccount) => !accounts.includes(existingAccount)
|
|
794
|
+
);
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
exports.defaultState = defaultState; exports.NotificationServicesController = NotificationServicesController;
|
|
802
|
+
//# sourceMappingURL=chunk-XNBTOK6G.js.map
|