Skip to content

feat: Integrate notifications related controller into core packages - #4320

Closed
Jonathansoufer wants to merge 75 commits into
mainfrom
feat/integrate-notifications-controllers
Closed

feat: Integrate notifications related controller into core packages#4320
Jonathansoufer wants to merge 75 commits into
mainfrom
feat/integrate-notifications-controllers

Conversation

@Jonathansoufer

@JonathansouferJonathansoufer commented May 24, 2024

Copy link
Copy Markdown
Contributor

Explanation

This PR adds/integrates all major controllers necessary for the new Notifications feature. These controllers were first created integrated into MM Extension, but need to be shared among clients [extension, mobile, portfolio].

References

Changelog

@metamask/notifications-controller

  • : Bootstrap controller

@metamask/profile-sync-controller

  • : Bootstrap controller

@metamask/push-platform-notifications-controller

  • : Bootstrap controller

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@JonathansouferJonathansoufer self-assigned this May 24, 2024
Comment threadpackages/notifications-controller/src/utils/utils.ts Fixed
@socket-security

socket-securityBot commented May 27, 2024

Copy link
Copy Markdown

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

PackageNew capabilitiesTransitivesSizePublisher
npm/@contentful/content-source-maps@0.5.0None+3252 kBcontentful-ecosystem
npm/@contentful/rich-text-html-renderer@16.5.2None+1150 kBcontentful-ecosystem
npm/@contentful/rich-text-types@16.5.2None0146 kBcontentful-ecosystem
npm/@fastify/busboy@2.1.1None080.2 kBgurgunday
npm/@firebase/analytics-compat@0.2.10Transitive: environment, network+72.77 MBgoogle-wombot
npm/@firebase/app-check-compat@0.3.11Transitive: environment, network+52.13 MBgoogle-wombot
npm/@firebase/app-check-interop-types@0.3.2None02.9 kBgoogle-wombot
npm/@firebase/app-compat@0.2.35Transitive: environment+31.66 MBgoogle-wombot
npm/@firebase/app-types@0.9.2None09.56 kBgoogle-wombot
npm/@firebase/app@0.10.5Transitive: environment+42.03 MBgoogle-wombot
npm/@firebase/auth-compat@0.5.9Transitive: environment, network, unsafe+622.8 MBgoogle-wombot
npm/@firebase/auth-interop-types@0.2.3None01.97 kBgoogle-wombot
npm/@firebase/database-compat@1.0.5Transitive: environment, network+914.8 MBgoogle-wombot
npm/@firebase/firestore-compat@0.3.32Transitive: environment, filesystem, network, unsafe+2139.3 MBgoogle-wombot
npm/@firebase/functions-compat@0.3.11Transitive: environment, network, unsafe+63 MBgoogle-wombot
npm/@firebase/installations-compat@0.2.7Transitive: environment, network+51.95 MBgoogle-wombot
npm/@firebase/messaging-compat@0.2.9Transitive: environment, network+62.98 MBgoogle-wombot
npm/@firebase/performance-compat@0.2.7Transitive: environment, network+72.66 MBgoogle-wombot
npm/@firebase/remote-config-compat@0.2.7Transitive: environment, network+72.59 MBgoogle-wombot
npm/@firebase/storage-compat@0.3.8Transitive: environment, network, unsafe+55.32 MBgoogle-wombot
npm/@firebase/vertexai-preview@0.0.2network Transitive: environment+32.22 MBgoogle-wombot
npm/@metamask/notification-services-controller@0.0.0-use.localNone00 B
npm/@protobufjs/aspromise@1.1.2None09.05 kBdcode
npm/axios@1.6.8network Transitive: environment, filesystem+82.22 MBjasonsaayman
npm/bignumber.js@4.1.0None0392 kBmikemcl
npm/contentful-resolve-response@1.8.1None+1139 kBwhydah-gally
npm/contentful-sdk-core@8.1.4None+5451 kBcontentful-ecosystem
npm/contentful@10.11.11None00 B
npm/firebase@10.12.2Transitive: environment, filesystem, network, unsafe+3699.5 MBgoogle-wombot
npm/loglevel@1.9.1None0639 kBpimterry
npm/tslib@2.6.3None084.9 kBtypescript-bot

🚮 Removed packages:npm/tslib@2.6.2

View full report↗︎

@socket-security

socket-securityBot commented May 27, 2024

Copy link
Copy Markdown

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

AlertPackageNoteSource
Network access npm/@protobufjs/fetch@1.1.0
Network access npm/faye-websocket@0.11.4
Network access npm/faye-websocket@0.11.4
Network access npm/websocket-driver@0.7.4
New author npm/@fastify/busboy@2.1.1
Network access npm/follow-redirects@1.15.6
Network access npm/follow-redirects@1.15.6
Network access npm/axios@1.6.8
Network access npm/axios@1.6.8
Network access npm/undici@5.28.4
Network access npm/undici@5.28.4
Network access npm/undici@5.28.4
Network access npm/undici@5.28.4
Network access npm/undici@5.28.4
Network access npm/@firebase/app-check@0.8.4
Network access npm/@firebase/functions@0.11.5
Network access npm/@firebase/installations@0.6.7
Network access npm/@firebase/messaging@0.12.9
Network access npm/@firebase/performance@0.6.7
Network access npm/@firebase/remote-config@0.4.7
Network access npm/@firebase/analytics@0.10.4
Network access npm/@firebase/auth@1.7.4
Network access npm/@firebase/auth@1.7.4
Network access npm/@firebase/vertexai-preview@0.0.2
Network access npm/@grpc/grpc-js@1.9.15
Network access npm/@grpc/grpc-js@1.9.15
Network access npm/@grpc/grpc-js@1.9.15
Network access npm/@grpc/grpc-js@1.9.15
Network access npm/@grpc/grpc-js@1.9.15

View full report↗︎

Next steps

What is network access?

This module accesses the network.

Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

What is new author?

A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.

Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/@protobufjs/fetch@1.1.0
  • @SocketSecurity ignore npm/faye-websocket@0.11.4
  • @SocketSecurity ignore npm/websocket-driver@0.7.4
  • @SocketSecurity ignore npm/@fastify/busboy@2.1.1
  • @SocketSecurity ignore npm/follow-redirects@1.15.6
  • @SocketSecurity ignore npm/axios@1.6.8
  • @SocketSecurity ignore npm/undici@5.28.4
  • @SocketSecurity ignore npm/@firebase/app-check@0.8.4
  • @SocketSecurity ignore npm/@firebase/functions@0.11.5
  • @SocketSecurity ignore npm/@firebase/installations@0.6.7
  • @SocketSecurity ignore npm/@firebase/messaging@0.12.9
  • @SocketSecurity ignore npm/@firebase/performance@0.6.7
  • @SocketSecurity ignore npm/@firebase/remote-config@0.4.7
  • @SocketSecurity ignore npm/@firebase/analytics@0.10.4
  • @SocketSecurity ignore npm/@firebase/auth@1.7.4
  • @SocketSecurity ignore npm/@firebase/vertexai-preview@0.0.2
  • @SocketSecurity ignore npm/@grpc/grpc-js@1.9.15

Prithpal-Sooriya
Prithpal-Sooriya previously approved these changes May 30, 2024

@Prithpal-SooriyaPrithpal-Sooriya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structure looks good! This is mostly a copy of extension

Comment threadpackages/notifications-controller/src/utils/utils.ts Fixed
@JonathansouferJonathansoufer added enhancement New feature or request dependencies Pull requests that update a dependency file labels May 30, 2024
@Jonathansoufer
Jonathansoufer marked this pull request as ready for review May 30, 2024 18:21
@Jonathansoufer
Jonathansoufer requested a review from a teamMay 30, 2024 18:21
@JonathansouferJonathansoufer changed the title chore: Integrate notifications related controller into core packagesfeat: Integrate notifications related controller into core packagesMay 30, 2024
JSouferand others added 2 commits May 31, 2024 11:33
note - we need to ensure types and linting are passing

@mcmiremcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! I see that there are new controllers being added in this PR. I left some suggestions on aligning to our current standards for controllers. I realize these aren't documented anywhere — we're working on that — but in the meantime I've left some suggestions. I also realize that this code may have been lifted directly from the extension. So if this PR is primarily designed to match the extension, and then work is planned to align it with this repo in another PR, I am fine with that.

That said, we should definitely ensure that versions of new packages starts at 0.0.0 and not 1.0.0 so that they don't get prematurely published accidentally.

Comment threadpackages/notifications-controller/src/MetamaskNotificationsController.ts Outdated
Comment threadpackages/notifications-controller/src/MetamaskNotificationsController.ts Outdated
Comment threadpackages/notifications-controller/src/MetamaskNotificationsController.ts Outdated
Comment threadpackages/notifications-controller/src/MetamaskNotificationsController.ts Outdated
Comment threadpackages/notifications-controller/src/MetamaskNotificationsController.ts Outdated
Comment threadpackages/push-platform-notifications-controller/tsconfig.build.json Outdated
Comment threadpackages/push-platform-notifications-controller/tsconfig.json Outdated
Comment threadpackages/push-platform-notifications-controller/LICENSE Outdated
Comment threadREADME.md Outdated
@Prithpal-Sooriya

Copy link
Copy Markdown
Contributor

Hey @mcmire, TY for the comments and reviews!
Most of these comments we should definitely resolve - and ensure that Linting and Tests will pass before we merge this.
Additional (higher level) comments you pointed out I'll note down for our team.

This PR is mostly to keep our Extension and Mobile teams unblocked for delivering the notifications feature and ensuring the Mobile and Extension logic doesn't diverge too much. If possible, we would like to release this as a V0 until the main development phase is done and the controllers start being more concrete.

@mcmire

Copy link
Copy Markdown
Collaborator

Ah, I think this just needs a yarn lint:fix and should be good to go.

JSouferand others added 20 commits June 6, 2024 20:06
reorganise logic and controllers into separate folders. Will figure out module exports in a little bit
fix circular deps, tests, types, linting
we pass feature announcement env through the controller config now
fix types, imports, tests, builds, circular deps, and decouple as much as I can from extension.
some stuff was using the old controller name. There are some places that use the older name, but might be a hassle to update
these 2 controllers are heavily tied together and should belong under the same package
for some reason the yarn.lock file got mangled. This mostly reverts it & ensures CI passes
@Prithpal-Sooriya

Copy link
Copy Markdown
Contributor

Hey all, I'm closing this PR since it's become a little too cumbersome to work in.

CI is all passing now, so will open a fresh PR and get the notifications team for a thorough first.
Keep in mind lets have these packages at v0.0.0 (unpublished) so we can prioritise getting the WIP and unblock mobile.

Prithpal-Sooriya added a commit that referenced this pull request Jun 13, 2024
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
This adds some core controllers for the notification services that are
consumed in both mobile and extension. (Maintained by the notifications
team).
Controllers are:
- `ProfileSyncController` - which contains 2 controllers
(`AuthenticationController` and `UserStorageController`)
- These are used for adding or consuming authenticated endpoints and
also make use of the profile syncing feature across platforms and
devices.
- `NotificationServicesController` - which also contains 2 controllers
(`NotificationServicesController` and
`NotificationsServicesPushController`)
- Both of these controllers are tightly coupled. The first manages pull
based notifications and creation of resource; and the second is
responsible for push notifications.
NOTE - these controllers should be treated as V0.x.x, as they are under
development on extension and mobile (iron out any issues).
Previous PR: #4320
(closed this as it was getting to unruly to work in.)
## References
Here is a loom recording for the new controllers.
https://www.loom.com/share/4e95a8fcc2ae4d81b737265fc75571c5?sid=8247a832-3f2e-4837-ab74-30c45524ccfe
Future Improvements (as separate PRs)
1. Lets tidy up and improve Push Notifications for Mobile (after
dog-fooding) - the implementation may differ on mobile.
2. I also want to improve imports so we can do paths (e.g.
`@metamask/profile-sync-controller/sdk`) instead of the global named
exports have.
3. Decoupling this from extension has shown some annoying messaging
system actions back and forth (leading to some circular dependencies due
to importing types). This has been resolved for now, but I want our team
to rethink how we are using the messaging system to be more streamlined.
- I don't want UserStorage controller calling actions to Notifications
(we should not do this)
- I don't really like how tied the notifications and push notifications
do communication back and forth. I would rather we orchestrate
communication in 1 controller (so communication is 1 way).
<!--
Are there any issues that this pull request is tied to? Are there other
links that reviewers should consult to understand these changes better?
For example:
* Fixes #12345
* Related to #67890
-->
## Changelog
<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.
(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)
Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).
If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.
Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->
### `@metamask/profile-sync-controller`
- **ADDED**: new `AuthenticationController`
- **ADDED**: new `UserStorageController`
### `@metamask/notfication-services-controller`
- **ADDED**: new `NotificationServicesController`
- **ADDED**: new `NotificationServicesPushController`
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
---------
Co-authored-by: JSoufer <jonathan.ferreira@consensys.net>
Co-authored-by: Jonathan Ferreira <44679989+Jonathansoufer@users.noreply.github.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependenciesPull requests that update a dependency fileenhancementNew feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants

@Jonathansoufer@Prithpal-Sooriya@mcmire@github-advanced-security