Skip to content

Follow the spec when refusing a pairing activation - #223

Merged
maximmaxim345 merged 3 commits into
mainfrom
fix/pairing-activation-unauthorized
Oct 29, 2026
Merged

maximmaxim345 merged 3 commits into
mainfrom
fix/pairing-activation-unauthorized

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

What does this implement/fix?

When a server activated pairing with a method the client doesn't allow, the client could close with pairing_required instead of unauthorized, which told the server to pair first even though pairing couldn't help. An activation the client refused with pair/abort method_not_supported also still applied its activities and active_roles, and a pairing activation missing its method could get pairing_required instead of closing without a message.

These only happen with a non-compliant server. The pairing method and format are now checked together with the other activation rules, in the order the spec gives.

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 Sentinel session with unpaired access off that got playback plus
pairing with method pairing_psk closed with pairing_required instead of
unauthorized. An activation refused with pair/abort method_not_supported
still applied its activities and active_roles, and a pairing activation
without a method could get pairing_required instead of a silent close.
@github-actions github-actions Bot added the bugfix Fixes a bug label Oct 29, 2026
@maximmaxim345
maximmaxim345 requested a balanced review from Copilot October 29, 2026 11:55

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.

🟡 Changes recommended

A critical re-handshake authorization flaw retains prior roles after pairing refusal, allowing queued commands and reporting to resume despite the new connection not permitting playback.

1 open issue
What changed in this PR

This PR aligns pairing-activation refusal handling with the Sendspin specification, validating pairing methods and formats before applying activation state.

Changes:

  • Centralizes pairing validation alongside activation authorization.
  • Separates refused activations from accepted state updates and adds reporting resumption.
  • Expands regression coverage for refusal reasons, malformed activations, and re-handshake behavior.
File Description
tests/​unit/​transport-rehandshake.test.ts Tests refusal handling, retained roles, and queued commands.
tests/​unit/​transport-harness.ts Adds pairing-method offers and a refusal callback.
tests/​unit/​transport-activate.test.ts Tests silent closure when the pairing method is missing.
tests/​unit/​protocol-handler.test.ts Tests reporting resumption with retained roles.
tests/​unit/​pairing.test.ts Updates refusal and pairing-index tests after validation moves.
tests/​unit/​core-encryption.test.ts Tests reporting resumption after a refused re-handshake activation.
tests/​unit/​activate-authorization.test.ts Expands pairing authorization and error-precedence coverage.
src/​core/​transport.ts Handles authorization outcomes before applying activation state.
src/​core/​protocol-handler.ts Adds reporting resumption without replacing roles.
src/​core/​pairing.ts Moves validation out and adds refused-attempt handling.
src/​core/​core.ts Wires pairing offers and activation-refusal callbacks.
src/​core/​activate-authorization.ts Centralizes pairing-method, format, and activation checks.

Review effort: Balanced

Comment thread src/core/transport.ts Resolved

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.

🟢 Approval recommended

No active review issues block approval of the pairing activation refusal changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit c9b333f into main Oct 29, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/pairing-activation-unauthorized branch October 29, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants