@devries-cameron20 / t3code-1 / commits / eac011439a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): preview and Device Hub streams survive DPoP session renewal (#38410)

Elias committed Nov 19, 2026 at 01:00 UTC eac011439a4454f08b5ea31a09760ffeb0068bfc
2 files changed +30 -4
apps/server/src/auth/SessionStore.test.ts
+17 -1
@@ -137,6 +137,12 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("SessionStore.lay
137
138 it.effect.each([
139 { name: "a renewal for the same key", renewal: {}, closesAtMinute: 119 },
140 + {
141 + name: "a renewal for the same key, on a media ticket",
142 + renewal: {},
143 + closesAtMinute: 119,
144 + ticket: "media",
145 + },
146 {
147 name: "a renewal for another key",
148 renewal: { proofKeyThumbprint: "other-proof-key" },
@@ -164,8 +170,18 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("SessionStore.lay
170 const sessions = yield* SessionStore.SessionStore;
171 const client = yield* sessions.issue(relaySessionInput);
172 const invalidated = yield* Deferred.make<void>();
173 + // Media tickets carry no proof key, so their routes wait without one.
174 + const watched =
175 + "ticket" in testCase
176 + ? yield* sessions.verifyWebSocketToken(
177 + (yield* sessions.issueWebSocketToken(client.sessionId, { audience: "media" })).token,
178 + )
179 + : {
180 + sessionId: client.sessionId,
181 + proofKeyThumbprint: relaySessionInput.proofKeyThumbprint,
182 + };
183 const watcher = yield* sessions
168 - .awaitInvalidation(client.sessionId, relaySessionInput.proofKeyThumbprint)
184 + .awaitInvalidation(watched.sessionId, watched.proofKeyThumbprint)
185 .pipe(
186 Effect.andThen(Deferred.succeed(invalidated, undefined)),
187 Effect.forkScoped({ startImmediately: true }),
apps/server/src/auth/SessionStore.ts
+13 -3
@@ -1223,6 +1223,18 @@ const make = Effect.gen(function* () {
1223 );
1224 const original = yield* readRow(sessionId);
1225 if (Option.isNone(original)) return;
1226 + // Media tickets carry no proof key, so their streams follow the session's own.
1227 + const renewalKey =
1228 + proofKeyThumbprint ??
1229 + Option.getOrUndefined(
1230 + yield* authSessions
1231 + .getProofKeyThumbprint({ sessionId })
1232 + .pipe(
1233 + Effect.mapError(
1234 + (cause) => new SessionCredentialVerificationError({ sessionId, cause }),
1235 + ),
1236 + ),
1237 + );
1238 // Revoking any session the socket has used closes it. Events only wake this loop
1239 // and the rows decide: revocations are written before they are published, and
1240 // clientRemoved also reports an expired session losing its last socket.
@@ -1256,9 +1268,7 @@ const make = Effect.gen(function* () {
1268 continue;
1269 }
1270 const successorId =
1259 - proofKeyThumbprint === undefined
1260 - ? undefined
1261 - : latestSessionByProofKey.get(proofKeyThumbprint);
1271 + renewalKey === undefined ? undefined : latestSessionByProofKey.get(renewalKey);
1272 if (successorId === undefined || successorId === current.sessionId) return;
1273 const successor = yield* readRow(successorId);
1274 // The socket keeps its original scopes, so the renewal must still grant all of them.