fix(gemini-titan): use millisecond nonce for WebSocket authentication - #2112
Open
VaggelisGian wants to merge 1 commit into
Open
fix(gemini-titan): use millisecond nonce for WebSocket authentication#2112VaggelisGian wants to merge 1 commit into
VaggelisGian wants to merge 1 commit into
Conversation
Gemini's WebSocket API requires the handshake nonce to be a Unix timestamp in milliseconds. buildWsHeaders() divided Date.now() by 1000, sending seconds, which lands outside the server's replay-prevention window and rejects authenticated connections. The REST path already sends milliseconds via GeminiAuth.nonce(), so only the WebSocket handshake was affected. Remove the division, correct the stale doc comment, and add unit tests that freeze Date.now() and assert the nonce header and signed payload carry the millisecond value. Fixes pmxt-dev#1933
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.
Fixes #1933
What was broken
buildWsHeaders() in core/src/exchanges/gemini-titan/auth.ts computed the WebSocket handshake nonce as Math.floor(Date.now() / 1000), sending seconds where Gemini's WebSocket API requires a millisecond Unix timestamp. The signed payload carried the same seconds value, so authenticated handshakes landed outside the server's replay-prevention window and were rejected, breaking watchOrderBook/watchTrades before any subscription could start.
The REST path was already correct: fetcher.ts signs payloads with GeminiAuth.nonce(), which returns milliseconds. Only buildWsHeaders() computed a nonce inline with the wrong unit.
What changed
Verification