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.



Description of Changes
First set out to fix Auth Middleware but it turns out the issue is fixable from Peer class.
The /.well-known/auth endpoint hangs because:
The middleware sets up a listener for certificates but never responds if:
No certificates are sent by the client
A session already exists for that identity
The response is only sent when:
The Peer class calls transport.send() with a response message
This happens inside the messageCallback processing
Your backend's onCertificatesReceived callback (server.ts:54-72) calls next() on line 71, but this only happens AFTER certificates are received
The initial auth handshake response should be sent by the Peer class through the messageCallback, but if the Peer doesn't respond (perhaps due to session state or missing configuration), the request hangs forever.
The fix would involve ensuring that:
The Peer always sends a response for the initial /.well-known/auth request
Or the middleware sends an explicit response if no session/certificates are needed
Or there's a timeout mechanism to prevent indefinite hanging
Bug #1: Race Condition in Timeout Setup
Bug #2: Inconsistent Key Usage (Less Critical)
Stored promise with: message.yourNonce
Resolved promise with: peerSession.sessionNonce
Testing Procedure
Describe the tests you've added or any testing steps you've taken.
Checklist
CHANGELOG.mdwith my changesnpm run docandnpm run lintone final time before requesting a reviewts-standardnpm version patchso that my changes will trigger a new version to be released when they are merged