bluesky-social / atproto

Social networking technology created by Bluesky
Other
7.21k stars 511 forks source link

Add Chrome Extension Support to BrowserOAuthClient #3093

Open kevinmcmahon opened 1 day ago

kevinmcmahon commented 1 day ago

Is your feature request related to a problem? Please describe.

The current BrowserOAuthClient implementation relies on Web APIs that are restricted or unavailable in Chrome Extension contexts.

Web-specific APIs used:

Describe the solution you'd like

Add pluggable providers to support both web and extension environments through configuration: Storage provider (chrome.storage.local) Location provider (chrome.runtime.getURL) Popup provider (chrome.windows.create) Messaging provider (chrome.runtime.connect)

This enhancement would enable Chrome Extension support while maintaining the existing web functionality through a single, configurable implementation.

Describe alternatives you've considered

Extending the OAuthClient and implementing a Chrome extension version was straightforward. Because you can leverage chrome.identity.launchWebAuthFlow, the window management and popups don't require management, and the implementation is more straightforward. The drawback is that you would have to provide implementations for the IndexedDB and encryption runtimes, which are the same ones that BrowserOAuthClient uses and seem redundant.

I have a basic implementation of that in vanilla JS here: https://gist.github.com/kevinmcmahon/82b96fb10685d93eaff53801b2d2adc0