#534

fix(ios): ask before a link changes the relay or the pairing file (rebase of #350)

OpenJoaov41wants to merge intofrom

Summary of changes

#350 rebased onto current main, with one change on top.

  • A poki://setup?relay= link no longer saves or turns on a relay. It raises a question that shows the relay's address and says what a relay can do; nothing changes until the owner taps Allow. A link naming the relay already in use asks nothing.
  • A poki://pairing?data= or ?url= link from outside Poki asks before the pairing file is replaced or fetched, and a ?url= link must carry a 64-character sha256 or it is refused. The scanner on the pairing page still imports directly.
  • While one link waits, another relay or pairing link is turned away and logged; it is not queued and does not replace the request on screen.
  • Change on top of #350: answerLink(_:to:) now requires the request's id. The old default of nil answered whatever request was waiting, so a future caller could apply Allow without naming what it allows. The alert's dismiss binding passes the shown request's id, and the tests name the request they answer.

Rebase: the only conflict was the top of Localizable.xcstrings, where main renamed the first key. The result keeps every key on main plus the seven #350 adds, with those entries unchanged from #350 (checked by comparing the parsed JSON).

Motivation (Closes #N)

Supersedes #350, which needed a rebase and had not been compiled. A poki:// link can be opened by a web page, message, QR code or another app, and the phone trusts its relay completely, so a single tap on a crafted link could hand the phone's screen and input to someone else's relay.

Test plan

Xcode 27.2, iOS 27.0 Simulator (iPhone 18 Pro), Debug, ad-hoc signed, with native/launcher built for aarch64-apple-ios-sim after native/launcher/fetch-idevice.sh.

  • xcodegen generate and xcodebuild build-for-testing -scheme Poki: TEST BUILD SUCCEEDED.
  • PokiTests run inside the app as native/ios-app/scripts/app-tests.sh does: testARelayLinkAsksAndDoesNotSetTheRelay, testASecondLinkWhileOneAsksChangesNothing and testAPairingLinkAsksAndNeedsItsChecksum pass.
  • Full PokiTests on this Mac: every failure on this branch also fails on main in the same environment (missing generated assets, Live Activity and network-dependent tests), except BrowserGuardTests/testCloseThenOpenReadsTheNewPageAndCloseClearsIt, which passed when run again by itself.

Not done: the on-device evidence asked for in the #350 review (cold launch with a link, first run, Settings open, both QR entry points, Allow and Don't Allow, a second link while the first alert is visible). I have not run this on a physical iPhone.

Screenshots or screen recording

None yet; not run on a physical iPhone.

AI assistance: Claude Code.

🤖 Generated with Claude Code

Activity

4
poki-repo-bot[bot]2d ago

Thanks, @Joaov41. Your agreement to the Poki Contributor Agreement (version 1) is on record and covers your later pull requests too. 已记录你的同意,之后的 pull request 不会再询问。

Joaov412d ago

I agree to the Poki Contributor Agreement

JosssphZhou2d ago

Thanks for binding each answer to the request shown. Please resolve the string-catalog conflict and share the on-device results for cold launch, first run, Settings, both QR entry points, and a second link while the alert is open. For Allow and Don’t Allow, please show which relay or pairing record was kept.