feat(config): add api_version config for versioned signaling paths#36
Open
TerryHowe wants to merge 1 commit into
Open
feat(config): add api_version config for versioned signaling paths#36TerryHowe wants to merge 1 commit into
TerryHowe wants to merge 1 commit into
Conversation
Introduce a server.api_version setting (default "v1", env PMUX_API_VERSION) that prefixes every HTTP/WebSocket call to the signaling server with the configured version. Legacy deployments pass api_version = "" to keep the unversioned paths. Auto-select the HMAC formula from the request path: /v1/ paths use timestamp:nonce:path with a pmux-nonce header; everything else keeps the legacy timestamp:path formula. This lets callers upgrade transparently just by passing the versioned base URL to the existing helpers. cfg.ServerURL() still returns the bare host URL for QR payloads and user-facing display. cfg.APIBaseURL() is the new value threaded to SignalingClient, PeerManager, InitiatePairing, ExchangeToken, WaitForPairComplete, DeletePairing, and DeleteDevice so every wire call picks up the prefix automatically without any new function parameters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Terry Howe <terrylhowe@gmail.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Summary
server.api_versionconfig field (default"v1") that prefixes all signaling server HTTP/WS paths — e.g.,/auth/tokenbecomes/v1/auth/tokenapi_version = ""continue using unversioned paths with no change; new installs default tov1automatically/v1/paths use the nonce-based formula (timestamp:nonce:pathname), legacy paths use the original formula (timestamp:pathname)Configuration
Or via env:
PMUX_API_VERSION=v1How it works
cfg.APIBaseURL()returnsserverURL + "/" + apiVersion(e.g.,https://signal.pmux.io/v1). This is passed to all HTTP/WS call sites (ExchangeToken,InitiatePairing,WaitForPairComplete,DeletePairing,DeleteDevice,SignalingClient,PeerManager). Function signatures are unchanged — callers supply the already-prefixed URL as the existingserverURLargument.cfg.ServerURL()(no prefix) is preserved for QR code payloads and user-facing display.SignRequest/SignWebSocketHeadersdetect the formula from the path: if it starts with/v1/, they generate a nonce, setpmux-nonce, and sign withtimestamp:nonce:path; otherwise they use the legacy formula.Files changed
internal/config/config.goAPIVersionfield,APIBaseURL()method,PMUX_API_VERSIONenv var, validation, docsinternal/auth/hmac.gogenerateNonce(),computeHMACv1(), path-based formula selection inSignRequest/SignWebSocketHeadersinternal/agent/agent.gocfg.APIBaseURL()forSignalingClientandPeerManagerinternal/agent/pair.gocfg.APIBaseURL()for API calls; keepcfg.ServerURL()for QR and warningsinternal/agent/unpair.gocfg.APIBaseURL()internal/agent/uninstall.gocfg.APIBaseURL()Test plan
go build ./...passesgo vet ./...passesgo test ./...passes"v1", file/env override, explicit""override,APIBaseURL()formattingCoordinated with server-side PR: ShiftinBits/pmux-server#25
🤖 Generated with Claude Code