Skip to content

Support for Facebook platform#395

Merged
micahflee merged 27 commits intomainfrom
380-facebook-platform
Feb 16, 2025
Merged

Support for Facebook platform#395
micahflee merged 27 commits intomainfrom
380-facebook-platform

Conversation

@micahflee
Copy link
Member

@micahflee micahflee commented Feb 8, 2025

Towards #380.

This adds the skeletons of Facebook support, with a FacebookAccountController on the main process with IPC functions hooked up, and a FacebookView and FacebookViewModel on the renderer side.

I've also implements login. It loads https://www.facebook.com/ and then detects if the user is logged in or not by the presence of a c_user cookie set in the browser. If the user is logged in, it then collects all of the <script type="application/json"> blocks from the HTML body, parses them all, and then searches them to find the user's Facebook account ID, name, and profile picture URI.

Login supports 2FA, including with U2F security keys, though there is a workaround because the "press your security key" thing doesn't pop up, like with X. If you login and 2FA is enabled, it does quickly flash this screen and then immediately move on:

Screenshot 2025-02-14 at 12 53 40 PM

Basically, Cyd detects you're logged in as soon as the c_user cookie is set, and so at this point the user is already logged in and it moves on from the login state. Do we maybe want to click the "Trust this device" button though? If so, we'd have to figure out how -- like, after the cookie is set, we need to wait for the page to finish loading and detect if we're at this page and if so, click the button. That can be left for a future PR though.

I also added very simple support for feature flags. To launch Cyd with Facebook enabled:

export CYD_FEATURE_FACEBOOK=1
npm run start

There's a new IPC function isFeatureEnabled(feature: string): boolean that just checks if CYD_FEATURE_{feature.toUpperCase()} is set to 1 or not. The way I'm using it right now is just in the AccountView.vue view -- it checks for Facebook and Bluesky features, and if the feature flags are set, it displays boxes for selecting those two types of accounts when adding a new account.

So if you run Cyd like:

export CYD_FEATURE_FACEBOOK=1
export CYD_FEATURE_BLUESKY=1
npm run start

When you add a new account it looks like this:

Screenshot 2025-02-14 at 1 01 48 PM

This all the feature flag does right now. So this means that everything else, including the migration to add the new facebookAccount table, and registering all the Facebook IPC functions, etc., is still enabled. If you've already added a Facebook account and then run Cyd again with CYD_FEATURE_FACEBOOK=0, you can use your Facebook account like normal without a problem.

Does this seem fine to ship in prod? I think so, but maybe I'm not thinking of something. My idea is once we have a feature (like Facebook) ready enough to enable by default, we just remove the code in AccountView.vue that only shows the Facebook option if the Facebook feature is enabled, so instead it always shows.

This PR adds the following:

  • Adds Facebook account to account selection page, along with FacebookView, FacebookViewModel, FacebookAccountController, and initial IPC functions
  • Supports logging into a Facebook account, and fetching the account ID, display name, and profile image
  • Supports Yubikeys, with a custom U2F page for Facebook
  • Supports Facebook error reports to the server
  • Includes a Facebook feature flag, so we can merge this earlier

…ve, and re-use it for Facebook. Start implementing the Facebook wizard
…cebook, with separate instructions and separate links
@micahflee micahflee marked this pull request as ready for review February 14, 2025 21:10
Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

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

Ran through the Facebook and X (to check for regressions) flows and all looks good!

@micahflee micahflee merged commit 9fff9e0 into main Feb 16, 2025
1 check passed
@micahflee micahflee deleted the 380-facebook-platform branch February 16, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants