Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brave: synchronize settings when backend is "Provided by Brave" #1281

Open
lidel opened this issue Sep 18, 2023 · 1 comment
Open

Brave: synchronize settings when backend is "Provided by Brave" #1281

lidel opened this issue Sep 18, 2023 · 1 comment
Labels
area/brave Issues related to Brave Browser exp/expert Having worked on the specific codebase is important kind/discussion Topical discussion; usually not changes to codebase kind/enhancement A net-new feature or improvement to an existing feature P1 High: Likely tackled by core team if no one steps up post-mv3 Tasks to be done after MV3 release

Comments

@lidel
Copy link
Member

lidel commented Sep 18, 2023

Brave IPFS SOW 2023 has an item about exposing IPFS settings from brave://settings/ipfs to IPFS Companion extension.
We want to be able to read them, and to change them programmatically.

I've described feature request details in brave/brave-browser#31199, and the feature was implemented recently in brave/brave-core#18901.

List of new APIs

New chrome.ipfs methods are available (brave-browser-beta-1.59.92 or later) ONLY to IPFS Companion Extension ID.
These are privileged APIs that are NOT available to other extensions.

Reading IPFS Settings

  • chrome.ipfs.getSettings(callback) - returns a JSON with IPFS-related settings in Brave
    • chrome.ipfs.getSettings((a) => console.log(a)){"auto_redirect_to_configured_gateway":false,"gateway_auto_fallback_enabled":false,"gateway_url":"https://dweb.link","nft_gateway_url":"https://nftstorage.link","resolve_method":"local","storage_max":1}

Writing IPFS Settings

WRITING is limited to a subset of settings:

  • chrome.ipfs.setPublicGateway - sets current public gateway url
  • chrome.ipfs.setPublicNFTGateway - sets current public NFT gateway url (iiuc this is a privacy feature where images in Brave Wallet are not triggering fetch to local IPFS node, we probably should not touch this)
  • chrome.ipfs.setResolveMethod("local" | "gateway" | "ask" | "disabled") - sets IPFS resolution type ("local" here means Kubo node embedded in Brave, and "gateway" mean some other URL, it could be localhost from IPFS Desktop used by regular companion users).
  • chrome.ipfs.setAutoRedirectToConfiguredGatewayEnabled(true|false) - sets auto redirect setting
  • chrome.ipfs.setGatewayFallbackEnabled(true|false) - sets gateway fallback setting (fall back to public IPFS gateway if your Brave local IPFS node cannot be reached)

What IPFS Companion should do with them

We should synchronize gateway URLs and ensure redirect logic in brave and companion extension are not in conflict when "Provided by Brave" backend is used:

  1. If a user disables global redirects in Companion (2023-09-18_20-44 ) the automatic redirect MUST be also disabled in Brave (chrome.ipfs.setAutoRedirectToConfiguredGatewayEnabled(false))
    • Without this, a user may disable redirect in Companion, but still end up on local gateway due to redirect being enabled in Brave.
  2. If "Provided by Brave" backend IS used, companion MUST use Public Gateway URL from Brave:

    Unless we want to deal with bidirectional sync here, Companion Options should show read-only fields, like we already do for "Local Gateway" URL:
    2023-09-18_20-40
    Brave setting is the source of truth:
    2023-09-18_20-13_1
    We use Brave value for both fields (subdomain gateway).

  3. When "Provided by Brave" backend is NOT used in Companion, switch resolution method in Brave, to ensure user is not running two Kubo nodes on localhost:

    when Companion user switches backend from "Provided by Brave" to "External":
    2023-09-18_20-09
    we should switch Brave from chrome.ipfs.setResolveMethod("local") to chrome.ipfs.setResolveMethod("gateway") and disable all redirects (chrome.ipfs.setAutoRedirectToConfiguredGatewayEnabled(false)) in Brave, to ensure all IPFS responsibilities are delegated to in Companion (like it would in vanilla Google Chrome).

  4. (TBD) This needs research, but we may consider always disabling Brave redirect logic when IPFS Companion is enabled. Rationale is that Companion is more advanced and allows for opt-out from redirect per website, while Brave is global toggle, so will redirect even when companion user opted-out from redirecting specific website.

FAQ

  • How to detect Brave settings changes?
    • Checking once on extension start is enough.
    • When it comes to monitoring the Brave setting change, Companion can detect when a tab with brave://settings(.*) is open, and keep polling getSettings for updates every second, for as long the tab is open.
  • What if there is a bug in API (e.g. writing settings does not work)
@lidel lidel added the need/triage Needs initial labeling and prioritization label Sep 18, 2023
@lidel
Copy link
Member Author

lidel commented Sep 18, 2023

@whizzzkid not super urgent, but this is something we should look into after MV3 work ships, so we have time in 2023 to report any bugs and Brave is able to fix them under 2023 SOW plan.

@lidel lidel added the area/brave Issues related to Brave Browser label Sep 18, 2023
@lidel lidel changed the title Brave: Implement support for chrome.ipfs settings API Brave: synchronize settings when backend is "Provided by Brave" Sep 18, 2023
@whizzzkid whizzzkid added kind/enhancement A net-new feature or improvement to an existing feature kind/discussion Topical discussion; usually not changes to codebase exp/expert Having worked on the specific codebase is important P0 Critical: Tackled by core team ASAP post-mv3 Tasks to be done after MV3 release and removed need/triage Needs initial labeling and prioritization labels Sep 24, 2023
@lidel lidel added P1 High: Likely tackled by core team if no one steps up and removed P0 Critical: Tackled by core team ASAP labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/brave Issues related to Brave Browser exp/expert Having worked on the specific codebase is important kind/discussion Topical discussion; usually not changes to codebase kind/enhancement A net-new feature or improvement to an existing feature P1 High: Likely tackled by core team if no one steps up post-mv3 Tasks to be done after MV3 release
Projects
No open projects
Status: Needs Grooming
Development

No branches or pull requests

2 participants