Repository navigation
v0.3.4
v0.3.4
A client can now stay in its room past its token's expiry. Until this release
the relay ended a connection at the token's exp, and a CollabClient with
getToken rejoined under a new clientId. Every other peer saw it leave and
join again, once per token lifetime. Now the client hands the relay a fresh
token over the open socket before exp, and nobody sees anything.
Two missions closed with this release, each with an exercise in CI:
make exercise-token-refresh (issue 66) and make exercise-prod (issue 68),
which runs all three mission exercises through the make prod-up stack.
Nothing changes for a client that doesn't set getToken, and a v0.3.3 client
keeps working against this relay (see Compatibility).
Changed (behavior)
- A
CollabClientwithgetTokenrefreshes its token in-session (issue
13, PR 67). Against a v0.3.4 relay it no longer drops and rejoins at each
exp. It keeps itsclientId, andonConnect/onDisconnectdon't fire.
Against an older relay it behaves as before. - A failed refresh falls back to a bounded reconnect (PR 67). The client
retries the refresh at half the time left while 2s or more remain. If none
succeeds, the relay ends the connection at the oldexpand the client
reconnects throughgetToken. If the refresh fails again in the next
lifetime, the session ends withonSessionEnded("token_expired"). That
stops a client from dropping and rejoining once per lifetime indefinitely.
Added
ReAuthActionandReAuthResult(issue 13, PR 67). A client sends a
fresh JWT over the open connection. The relay checks it like the upgrade's
token (signature, issuer,exp, the deny list). The token must have the
samesubandclient_id, and itsroomsclaim must allow the
connection's room. On success the connection ends at the newexp. A
refusal leaves the oldexpin place, andReAuthResult.errorsays why.
ReAuth isn't rate limited.RoomJoined.token_expires_atgives the client the firstexp. The
relay sets it only when the connection has a token and the join's
protocol_versionis 3 or higher (PR 71).CollabClientOptions.onTokenRefreshreports each refresh: the new
expiresAt, or why it failed.- Go:
RelayAuthenticator.ValidateToken(ctx, raw)andErrAuthDisabled,
Guard.Authenticator(), andStreamConfig.Auth.api.gowires the Guard's
authenticator into every stream, so an embedder with a hand-builtGuard
(as mcpkit has) gets ReAuth without changes. make exercise-prod(issue 69, PR 70) brings up theprod-upstack
(Caddy with TLS, the relay container, auth from env, the stack's own rate
limits) and runs the auth, reconnect and token-refresh exercises against
wss://localhost. A required CI job runs it. The exercises take an
external relay fromMASSRELAY_RELAY_URL.
Fixed
- A rejoin refused with
ROOM_FORBIDDENstopped silently (PR 67). It
closed the connection without callingonSessionEnded. It now ends with
onSessionEnded("token_refused").
Compatibility
- A v0.3.3 client against this relay keeps working (PR 71). v0.3.3
rejects JSON fields it doesn't know, so the relay sends
token_expires_atonly to a join withprotocol_version3 or higher.
CollabClient0.3.4 sends 3.ts/interop/compat.interop.tsruns the
published v0.3.3 client against the binary in CI. - A v0.3.4 client against an older relay gets no
token_expires_at, so
it never sends aReAuthActionand reconnects atexpas before. An older
relay acceptsprotocol_version3. CollabClientnow ignores event fields it doesn't know, so a later
relay's additions can't stop it handling an event.
Tests
identity.interop.tsflaked about 1 run in 10 on an ordering assertion
across two senders, which the relay never promised. It now waits for the
first message before sending the second (PR 67).