fix(device-pairing): refuse to mint pairing codes from an address that cannot pair

A loopback origin in production or plain HTTP on a public address still
minted a code and showed a browser QR no other device could use.

- one availability rule decides untrusted, loopback and public plain-HTTP
  origins; POST /api/device-pairing/links checks it before minting
- GET /api/device-pairing/availability reports the rule for the page origin
  without minting
- Connect a device disables "Show QR code" and explains the fix when the
  address cannot pair
- private-network plain HTTP keeps the browser QR; the app QR still needs
  the toggle
This commit is contained in:
Chris Scott committed 2026-10-24 19:26:21 -04:00
1 parent 106e8f51fc
commit b9d8d18124
12 files changed
+529 -64

No files matched your search

@@ -24,9 +24,6 @@ const WARNING_MESSAGES: Record<DevicePairingLinkWarning, string> = {
'headers-unreadable': 'Stored remote access headers could not be decrypted and are not included.',
}
const LOOPBACK_EXPLANATION =
'This page is open on localhost, which your phone cannot reach. Open the Manager at its public or LAN address to show the app QR code.'
const INSECURE_ORIGIN_EXPLANATION =
"The mobile app QR code needs HTTPS. Use an HTTPS address, or turn on 'Allow plain-HTTP app links on private networks' if this Manager uses a private IP address."
@@ -187,11 +184,7 @@ export function ConnectDeviceDialog({ open, onOpenChange }: ConnectDeviceDialogP
</p>
</>
) : (
<p className="text-sm text-muted-foreground">
{links.appLinkBlockedReason === 'loopback'
? LOOPBACK_EXPLANATION
: INSECURE_ORIGIN_EXPLANATION}
</p>
<p className="text-sm text-muted-foreground">{INSECURE_ORIGIN_EXPLANATION}</p>
)}
</TabsContent>