chore(protocol): require the Document epoch identity pair - #429
Merged
Merged
Conversation
externalEpoch / epochGeneration were wire-optional so an old host could not brick a new webview. Since PROTOCOL_VERSION 2 such a host is rejected at isProtocolMatch before the pair is read, so the tolerance was unreachable. The pair is now required in the type and the boundary validator, and the webview's pair-absent (legacy host) branches are gone. No wire change: the host already always emits both.
2 tasks done
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.
Summary
Make the
documentmessage's identity pair (externalEpoch/epochGeneration) required. It was wire-optional so an old host could not brick a new webview; sincePROTOCOL_VERSION2 such a host is rejected atisProtocolMatchbefore the pair is read, so that tolerance was unreachable.Changes
protocol.ts: both fields required onDocumentMessage;isHostToWebviewrejects adocumentmissing either one;isValidEpochIdentityremovededit-sync.ts: the pair-absent (legacy host) branches are gone —incomingIdentityandidentityChangedremoved, the rule is now a plain generation comparison.nullremains only for "before the first host snapshot"protocol.test.ts(rejects neither / missingexternalEpoch/ missingepochGeneration); legacy-only tests deleted; remaining fixtures carry a pairPROTOCOL_VERSIONbump — the host already always emits both, so nothing changes on the wireNotes for review
srcis +41/−119. The test diff is larger only becauseapplyDocument/onHostSnapshotfixtures now have to pass the pair.Related
Test Plan
pnpm compile/pnpm compile:webviewpnpm test:unit/pnpm test:browserpnpm lint