Repository navigation
Retry a wrong dynamic pairing code instead of ending pairing - #206
Merged
Merged
Conversation
A pairing message with no attempt running was always dropped silently, and server/pair-finalize was ignored in any phase without a pending PSK.
A mistyped dynamic pairing code ended the whole attempt. After 10 failures every attempt needed the pairing window, the gesture never reset the count, and rounds that ended without a server_kc were not counted. BREAKING CHANGE: `isDynamicPinEscalated()` is now `isRoundLimitReached()`, and `releasePairingHold()` replaces `openPairingWindow()` for releasing dynamic pairing code attempts.
The pairing window closed as soon as one attempt started, so a timed-out or cancelled static pairing code attempt needed a new gesture.
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive pairing lifecycle changes retain a connection-binding defect and need human review and runtime validation.
1 open issue
What changed in this PR
Updates the SDK’s pairing flow so mistyped dynamic codes retry within the same attempt, with revised safeguards and operator controls.
Changes:
- Adds same-code retries and a persistent 20-round limit released by deliberate operator action.
- Revises static pairing-window lifetime and rejects out-of-sequence pairing messages.
- Updates public APIs, sample controls, documentation, and tests.
| File | Description |
|---|---|
| tests/unit/pairing.test.ts | Covers retries, round limits, window lifetime, and message ordering. |
| tests/helpers/sendspin-server.py | Accepts a separate code submission for each round. |
| tests/helpers/aiosendspin-server.ts | Updates code-submission result types. |
| tests/e2e/sendspin-security.e2e.test.ts | Exercises dynamic retries and hold release. |
| src/types.ts | Adds retry messages and updates pairing contracts. |
| src/index.ts | Exposes revised pairing controls on the player API. |
| src/core/pairing.ts | Implements retries, round limits, and window lifecycle changes. |
| src/core/core.ts | Connects pairing cleanup and new controls to the core. |
| README.md | Documents revised pairing behavior and API usage. |
| public/app.js | Adds hold release and grouped code display and speech. |
| index.html | Updates pairing controls and explanatory text. |
| CLAUDE.md | Renames the documented persisted counter. |
Review effort: Balanced
Calling `connect()` again without `disconnect()` skipped the old connection's close cleanup, so a pairing window bound to it stayed open on the new connection and the next handshake counted as a re-handshake.
An `onConnectionClose` handler that reconnects with `connect()` re-entered `connect()` without end, since the replaced socket still counted as connected.
33 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.

What does this implement/fix?
A mistyped dynamic pairing code ended the whole pairing attempt, and after 10 failures every attempt needed the pairing window, with no way to reset the count.
Now a wrong code starts another round with the same code. After 20 rounds without a correct code, attempts wait until the app calls
releasePairingHold()on a deliberate action on the device, which also resets the count.This also fixes a few other gaps with the spec:
cancelPairing().pair/abortare still dropped.123-456and speaks it with a pause between groups.This is a breaking change:
isDynamicPinEscalated()is nowisRoundLimitReached(), andreleasePairingHold()replacesopenPairingWindow()for releasing held-back dynamic pairing attempts.Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies