Skip to content

feat: make public gateways optional for sharing - #1371

Merged
lidel merged 5 commits into
mainfrom
feat/native-share-links
Jul 17, 2026
Merged

feat: make public gateways optional for sharing#1371
lidel merged 5 commits into
mainfrom
feat/native-share-links

Conversation

@lidel

@lidel lidel commented Jul 2, 2026

Copy link
Copy Markdown
Member

Problem

"Copy Shareable Link" always produced a URL on a third-party gateway, and parts of the extension assumed a public gateway is always set. There was no way to copy a native ipfs:// or ipns:// address, or to stop routing people through ipfs.io and dweb.link.

Fix

  • defaults are unchanged: ipfs.io and dweb.link stay prefilled and share links are still built on dweb.link, matching feat: choose share link type, add native uris ipfs-webui#2482; a future flip to native-by-default only touches the DEFAULT_* constants in lib/options.js plus a migration
  • clearing the gateway URLs (or the new "Use Public Gateways for Shareable Links" toggle) switches copied links to native ipfs:// and ipns:// addresses
  • share links prefer the subdomain gateway, then the path gateway (e.g. when a CID is too long for a DNS label), then native, so they are never empty or broken
  • with no public gateway, failed requests recover to the local gateway, or to a recovery page showing the native address and how to install a node
  • the IPFS Node section explains Kubo RPC and hides the one-option node type select, plus a copy pass over the whole Preferences screen

Preferences → Gateways

ipfs-companion-options-gateways

Preferences → IPFS Node

ipfs-companion-options-node

Recovery page

With no public gateway set and the node offline, the page shows the content's native address and offers to install a local node:

ipfs-companion-recovery-native

With a public gateway configured, it is unchanged and still offers to continue to that gateway:

ipfs-companion-recovery-gateway

Related

@lidel
lidel force-pushed the feat/native-share-links branch from 013cfc5 to c1691cd Compare July 2, 2026 01:25
Public gateway URLs are now empty by default, so "Copy Shareable
Link" and friends copy native ipfs:// and ipns:// URIs. A new opt-in
toggle restores public gateway URLs for sharing with people who do
not run IPFS.

- options: empty publicGatewayUrl/publicSubdomainGatewayUrl defaults
  plus usePublicGatewaysForShare (off, disabled until a public gateway
  URL is set)
- ipfs-path: resolveToNativeUri plus toggle-aware resolveToShareableUrl
  and resolveToPermalink (Copy Shareable and Snapshot Link);
  resolveToPublicUrl falls back to native on empty gateway
- public shareable links follow the "Use Subdomains" preference: on
  uses the subdomain gateway, off the path gateway, and whichever one
  is configured when only one is set
- native URIs use case-insensitive roots since browsers treat them as
  origins: base32 CIDv1 for ipfs://, base36 libp2p-key CIDv1 for
  ipns:// peer ids (DNSLink hostnames unchanged)
- empty gateways handled across state, request, dnslink, import and
  inspector: sameGateway/dropSlash are null-safe and browser-loading
  paths fall back to the local gateway
- recovery page: with no public gateway configured it shows the native
  ipfs:// address, drops the public-gateway wording, and offers to
  install a local IPFS node
- options UI: public gateway fields moved below the local gateway;
  path gateway renamed to make its shape explicit; both documented
  with link examples and links to the path/subdomain gateway specs
@lidel
lidel force-pushed the feat/native-share-links branch from c1691cd to 79ab0da Compare July 3, 2026 00:21
@lidel lidel added the status/blocked Unable to be worked further until needs are met label Jul 3, 2026
Making public gateways optional left several consumers resolving to
native ipfs:// URIs they could not use, and routed offline failures to
dead ends. Degrade each consumer to a loadable URL or the recovery page.

- resolveToPublicUrl: use the subdomain gateway for content paths when
  only it is set, keep subdomain requests native rather than downgrade
  them to a path gateway (origin isolation), and repair the ipns://
  DNSLink protocol swap that URL.protocol assignment silently dropped
- recovery: send failed requests to the recovery page with the native
  URI when no loadable gateway remains, including failures at the
  configured gateway itself; only reopen on the local gateway when the
  node is online; limit HTTP recovery to 5xx
- preload: noop without a public gateway, otherwise pick a random
  configured one
- linkify: fall back to the local gateway so injected hrefs stay http(s)
- sharing: reset usePublicGatewaysForShare when both gateway URLs are
  cleared; share helpers no longer re-parse an already-decoded path
- sameGateway: match on a label boundary so nondefaultipfs.io is not
  treated as ipfs.io
lidel added 3 commits July 17, 2026 13:19
Match the defaults ipfs/ipfs-webui#2482 shipped: fresh installs prefill
ipfs.io and dweb.link and copy dweb.link subdomain URLs, while clearing
the gateway URLs switches copied links to native ipfs:// and ipns://
URIs.

- options: defaults live in DEFAULT_* constants; a future flip to
  native-by-default changes those plus a migrateOptions entry
- ipfs-path: share links prefer the subdomain gateway and fall back to
  the path gateway, then native; roots longer than the 63-char DNS
  label limit no longer produce hostnames that cannot resolve
- options/store: clearing the last gateway URL no longer flips the
  share toggle off; the fallback is dynamic, so re-adding a URL
  restores public sharing
- recovery: resolve a native URI via the background once the node is
  online instead of navigating to ipfs://, which Chromium drops
- popup: show the local gateway address when no public one is set
- locales/en: describe the new behavior on the Preferences screen
- rename lingering "custom gateway" mentions to "local gateway"
- fix grammar in the automatic mode descriptions and a missing space
  in the notifications one
The node type select had a single option, so it asked users to choose
nothing. Hide it while POSSIBLE_NODE_TYPES has one entry and instead
explain what the Kubo RPC API is, with links to install Kubo or IPFS
Desktop and to the RPC docs.
@lidel
lidel marked this pull request as ready for review July 17, 2026 11:35
@lidel
lidel requested a review from a team as a code owner July 17, 2026 11:35
@lidel
lidel merged commit 5558e5f into main Jul 17, 2026
5 checks passed
@lidel
lidel deleted the feat/native-share-links branch July 17, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/blocked Unable to be worked further until needs are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant