Skip to content

Retry a wrong dynamic pairing code instead of ending pairing - #206

Merged
maximmaxim345 merged 7 commits into
mainfrom
fix/dynamic-pairing-rounds
Oct 27, 2026
Merged

maximmaxim345 merged 7 commits into
mainfrom
fix/dynamic-pairing-rounds

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

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:

  • The static pairing window now stays open across attempts, so a timed-out or cancelled attempt no longer needs a new gesture. It closes on a completed pairing, the fifth wrong code, a drop of the connection that used it, or cancelPairing().
  • Pairing messages that arrive out of sequence now close the connection instead of being ignored. Messages still in flight after the client's own pair/abort are still dropped.
  • The sample player shows the dynamic code as 123-456 and speaks it with a pause between groups.

This is a breaking change: isDynamicPinEscalated() is now isRoundLimitReached(), and releasePairingHold() replaces openPairingWindow() for releasing held-back dynamic pairing attempts.

Related issue or spec PR (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue): bugfix
  • New feature (non-breaking change which adds functionality): new-feature
  • Enhancement to an existing feature: enhancement
  • Breaking change (changes the public API or the protocol in a way that is not backwards compatible): breaking-change
  • Refactor (no behavior change): refactor
  • Documentation only: documentation
  • Maintenance / chore: maintenance
  • CI / workflow change: ci
  • Dependencies bump: dependencies

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.
@maximmaxim345
maximmaxim345 requested a balanced review from Copilot October 27, 2026 14:05
@github-actions github-actions Bot added the breaking-change Changes the public API or the protocol in a way that is not backwards compatible label Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Comment thread src/core/core.ts Resolved
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive pairing changes warrant human validation, and connection replacement retains an unresolved callback reentrancy issue.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread src/core/core.ts Resolved
An `onConnectionClose` handler that reconnects with `connect()` re-entered
`connect()` without end, since the replaced socket still counted as
connected.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive pairing and connection-lifecycle changes warrant human validation, including execution of the expanded unit and end-to-end tests.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit 18d6658 into main Oct 27, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/dynamic-pairing-rounds branch October 27, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Changes the public API or the protocol in a way that is not backwards compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants