feat(sign): prepareSign() — pre-warm a Yivi session for one-tap app open on iOS#103
Merged
Conversation
…app open
On iOS a Yivi Universal Link only opens the app when the navigation happens
inside a genuine user gesture. If the signing session is started on tap (as
part of encrypt()), the app deep-link URL doesn't exist yet, so the tap can't
navigate synchronously and falls back to Safari.
prepareSign() starts the Yivi signing session ahead of time and returns:
- mobileUrl: Promise<string> — the app deep-link, resolved as soon as Yivi
shows its mobile button (captured via a passive yivi-core state plugin,
not DOM scraping), so a caller can put it on an <a href> for a one-tap open;
- keys: Promise<SigningKeys> — resolved on disclosure, to feed into encrypt();
- cancel() — aborts the in-flight session.
The disclosure is identity-bound (sender email + optional attributes) and
independent of the files/recipients, so the keys are reusable. EncryptInput now
accepts a `signingKeys` field; when supplied, Sealed.getSigningKeys() uses it
directly and never starts a second session (the internal pipeline already
threaded signingKeys). Adds AbortSignal support to the Yivi resolver.
Contributor
There was a problem hiding this comment.
Approving — prepareSign() is a clean, well-scoped addition.
Rule check (Haiku fan-out + manual verification): no violations.
- Conventional PR title (
feat(sign):) ✓ - Tests present for the new surface: handle shape, no-DOM rejection of both
keysandmobileUrl, already-aborted signal, andencrypt({ signingKeys })short-circuit ✓ - No
vi.mockhoisting trap (onlyvi.stubGlobal) ✓ - Client-side JWT trust boundary untouched by this diff ✓
Review notes (all confirmed correct, nothing blocking):
mobileUrl.catch(() => {})prevents an unhandled rejection on the desktop path where nobody awaits the URL; the failure still surfaces viakeys.MobileUrlCapturefires at most once (firedguard) and has nostart, so yivi-core never drives it — passive listener only.- Abort wiring is sound: pre-aborted signal short-circuits before any widget construction, and the runtime listener uses
{ once: true }. signingKeysshort-circuit inSealed.getSigningKeys()returns before any Yivi session starts.
Full suite green (209/209), tsc --noEmit and tsdown clean. The runtime mobileUrl capture path still needs the on-device iOS check noted in the PR — tracked for the website wiring PR.
|
🎉 This PR is included in version 2.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
dobby-coder Bot
added a commit
to encryption4all/postguard-docs
that referenced
this pull request
Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On iOS a Yivi Universal Link only opens the app when the navigation happens inside a genuine user gesture. Today the signing session is started as part of
encrypt()— i.e. after the user taps send — so the app deep-link URL doesn't exist yet at tap time. There's nothing to navigate to synchronously, so the tap falls back to openingopen.yivi.appin Safari instead of the app.This adds the primitive needed to fix that in the website: start the session before the tap, so the URL is ready and a single tap can open the app.
What
PostGuard.prepareSign(opts)starts the Yivi signing session ahead of time and returns:mobileUrl: Promise<string>— the Yivi app deep-link, resolved as soon as Yivi shows its mobile app button. Captured via a small passive yivi-core state plugin that reads theShowingYiviButtonpayload'smobilefield — no DOM scraping. Put it on an<a href>so one tap opens the app. Mobile-only (desktop uses the QR flow), so race with a timeout there.keys: Promise<SigningKeys>— resolves on disclosure; pass intoencrypt({ signingKeys }).cancel()— aborts the in-flight session.The disclosure is identity-bound (sender email + optional attributes) and independent of the files/recipients, so the resolved keys are valid for whatever is ultimately encrypted.
Supporting changes:
EncryptInputgains an optionalsigningKeysfield. When supplied,Sealed.getSigningKeys()uses it directly and never starts a second Yivi session (thesign.elementwidget is never touched). The internal pipeline already threadedsigningKeys; this just surfaces it publicly.resolveSigningKeysFromYivigains aruntimearg (onMobileUrl,signal) for the URL capture andAbortSignalcancellation.PrepareSignOptions,PreparedSign,SigningKeys.Usage sketch (website side, follows separately)
Tests
prepareSignreturns{ mobileUrl, keys, cancel }; rejects bothkeysandmobileUrlwithYiviSessionErrorwhen no DOM; rejects immediately on an already-aborted signal.encrypt({ signingKeys })short-circuits session resolution (no "requires a DOM" throw when keys are supplied).tsc --noEmitclean;tsdownbuild clean.The runtime
mobileUrlcapture path needs a browser + live Yivi server to exercise end-to-end; that happens in the website wiring PR and an on-device iOS check.