Skip to content

refactor(companion): modularize nonce registration and error response sealing in ChallengeHandler - #49

Merged
HMAKT99 merged 1 commit into
HMAKT99:mainfrom
aymanysr:refactor/companion-challenge-handler
Nov 1, 2026
Merged

HMAKT99 merged 1 commit into
HMAKT99:mainfrom
aymanysr:refactor/companion-challenge-handler

Conversation

@aymanysr

Copy link
Copy Markdown
Contributor

Summary

In ChallengeHandler.handleChallenge(encryptedData:deviceID:), nonce tracking cache management, biometric prompt dispatching, and error wire formatting were inline within a single asynchronous block.

This refactoring extracts three focused helpers:

  1. registerNonceIfFresh(nonce:expiry:): Prunes expired nonces, ensures replay prevention under the 512-entry bounds, and commits fresh challenge nonces.
  2. performAuthentication(reason:): Cleanly encapsulates routing between injected test closures and LocalAuthManager.
  3. sendErrorResponse(code:description:challengeID:session:): Encapsulates error payload packaging and wire sealing under WireFormat.seal(.error, ...).

All authorization validation, token generations, cancellation semantics, Secure Enclave flows, and error responses remain identical.

Testing

  • xcodebuild test -project companion/TouchBridge.xcodeproj -scheme TouchBridge: 10 companion security tests pass on the iOS Simulator.

@HMAKT99
HMAKT99 merged commit 8997ec3 into HMAKT99:main Nov 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants