Add HTTP relay transport for browser-to-NHP-server communication - #8
Merged
Conversation
Implement the nhp-relay transport path that enables browser-based NHP agents to communicate with the NHP server via an intermediary HTTP relay service, removing the dependency on WebRTC signaling. Transport layer: - Add HttpRelayTransport (src/transport/relay.ts) that sends raw NHP packets via HTTP POST and receives ACK/COK responses in the HTTP response body - Register 'relay' transport type in NHPAgent with relayUrl config Protocol fixes for Go server interoperability: - Fix Noise chain key continuity: Go server/agent clear chainKey in encryptBody/decryptBody defer blocks, so ACK encryption effectively starts from all-zeros chain key. JS agent now passes zero-filled prevChainKey when parsing ACK responses to match this behavior - Save last build chain key in packet.ts for potential future use (consumeLastBuildChainKey), with fallback retry logic in NHPAgent - Fix errCode "0" incorrectly treated as error — in NHP protocol "0" means success GMSM cipher scheme: - Both build and parse paths for SM2/SM3/SM4 now support prevChainKey parameter for Noise chain continuation - resetGlobalCounter() also clears lastBuildChainKeyMap for test isolation Documentation: - Update README.md with verified end-to-end relay flow diagram showing Browser -> Relay -> NHP Server -> AC with actual packet sizes - Add Noise chain key continuity explanation - Add system architecture diagram with AC participant - Update transport selection table (relay as browser default) - Add relay-specific troubleshooting in Common Issues - Update CLAUDE.md with relay transport and known gotchas Tests: - Add NHPAgent.test.ts with knock success/error/event tests - Add protocol/header.test.ts for NHPHeader/NHPHeaderEx - Add protocol/packet.test.ts with GMSM round-trip, COK/RNK flow, anti-replay, and compression tests - All 116 tests passing
- Fetch ./config.json on startup and populate empty form fields so
deployments can ship live keys/URLs without editing source. Respects
user edits saved in localStorage.
- Add importmap for @noble/{ciphers,curves,hashes} which the SDK build
leaves as external specifiers; required when served as a static page.
- Ignore config.json at repo root (rendered at deploy time, may carry
demo-grade private key).
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.
No description provided.