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

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

fix(server): revoking all other clients also revokes unspent pairing codes (#39495)

Julius Marminge committed Nov 19, 2026 at 19:47 UTC ebf7b9a4c51ce6e080b1c4253877485dc0d4fe3d
3 files changed +41 -9
apps/server/src/auth/EnvironmentAuth.test.ts
+14
@@ -862,12 +862,26 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodePlatformCrypto.layer))(
862 const clientsBeforeRevoke = yield* serverAuth.listClientSessions(
863 administrativeSession.sessionId,
864 );
865 + const unspentCode = yield* serverAuth.issuePairingCredential({ label: "unspent" });
866 + const unspentApproval = yield* serverAuth.issuePairingCredential({
867 + access: "read-only",
868 + });
869 const revokedCount = yield* serverAuth.revokeOtherClientSessions(
870 administrativeSession.sessionId,
871 );
872 const clientsAfterRevoke = yield* serverAuth.listClientSessions(
873 administrativeSession.sessionId,
874 );
875 + expect(
876 + (yield* serverAuth
877 + .createBrowserSession(unspentCode.credential, requestMetadata)
878 + .pipe(Effect.exit))._tag,
879 + ).toBe("Failure");
880 + expect(
881 + (yield* serverAuth
882 + .consumeMcpApprovalCode(unspentApproval.credential, "read-only")
883 + .pipe(Effect.exit))._tag,
884 + ).toBe("Failure");
885
886 expect(listedPairingLinks.map((entry) => entry.id)).toContain(pairingCredential.id);
887 expect(listedPairingLinks.find((entry) => entry.id === pairingCredential.id)?.label).toBe(
apps/server/src/auth/PairingGrantStore.ts
+11 -2
@@ -828,7 +828,11 @@ const make = Effect.gen(function* () {
828 const revokeConnectDevice: PairingGrantStore["Service"]["revokeConnectDevice"] = Effect.fn(
829 "PairingGrantStore.revokeConnectDevice",
830 )(function* (proofKeyThumbprint) {
831 - yield* revokeUnspentLinks({ proofKeyThumbprint, keepProofKeyThumbprint: null });
831 + yield* revokeUnspentLinks({
832 + proofKeyThumbprint,
833 + keepProofKeyThumbprint: null,
834 + includeUnbound: false,
835 + });
836 const removed = yield* connectDevices
837 .remove(proofKeyThumbprint)
838 .pipe(Effect.mapError((cause) => new ConnectDevicesError({ operation: "revoke", cause })));
@@ -838,7 +842,12 @@ const make = Effect.gen(function* () {
842
843 const revokeConnectDevicesExcept: PairingGrantStore["Service"]["revokeConnectDevicesExcept"] =
844 Effect.fn("PairingGrantStore.revokeConnectDevicesExcept")(function* (keepProofKeyThumbprint) {
841 - yield* revokeUnspentLinks({ proofKeyThumbprint: null, keepProofKeyThumbprint });
845 + // "Revoke all others" promises every other way in is gone, so unspent codes go too.
846 + yield* revokeUnspentLinks({
847 + proofKeyThumbprint: null,
848 + keepProofKeyThumbprint,
849 + includeUnbound: true,
850 + });
851 const removed = yield* connectDevices
852 .removeAllExcept(keepProofKeyThumbprint)
853 .pipe(Effect.mapError((cause) => new ConnectDevicesError({ operation: "revoke", cause })));
apps/server/src/persistence/AuthPairingLinks.ts
+16 -7
@@ -98,10 +98,14 @@ export const FindPendingConnectPairingLinkInput = Schema.Struct({
98 });
99 export type FindPendingConnectPairingLinkInput = typeof FindPendingConnectPairingLinkInput.Type;
100
101 -/** Unspent links bound to `proofKeyThumbprint`, or with `keepProofKeyThumbprint` every other bound one. */
101 +/**
102 + * Unspent links bound to `proofKeyThumbprint`, or with `keepProofKeyThumbprint` every other bound
103 + * one. `includeUnbound` adds the links no key is bound to: pairing and approval codes.
104 + */
105 export const RevokeUnspentByProofKeyInput = Schema.Struct({
106 proofKeyThumbprint: Schema.NullOr(Schema.String),
107 keepProofKeyThumbprint: Schema.NullOr(Schema.String),
108 + includeUnbound: Schema.Boolean,
109 revokedAt: Schema.DateTimeUtcFromString,
110 });
111 export type RevokeUnspentByProofKeyInput = typeof RevokeUnspentByProofKeyInput.Type;
@@ -487,16 +491,21 @@ export const make = Effect.gen(function* () {
491 const revokeUnspentByProofKeyRows = SqlSchema.findAll({
492 Request: RevokeUnspentByProofKeyInput,
493 Result: Schema.Struct({ id: Schema.String }),
490 - execute: ({ proofKeyThumbprint, keepProofKeyThumbprint, revokedAt }) =>
494 + execute: ({ proofKeyThumbprint, keepProofKeyThumbprint, includeUnbound, revokedAt }) =>
495 sql`
492 - -- Only T3 Connect mints bind a proof key, so these are that key's connect credentials.
496 + -- Only T3 Connect mints bind a proof key, so bound links are that key's connect credentials.
497 UPDATE auth_pairing_links
498 SET revoked_at = ${revokedAt}
495 - WHERE proof_key_thumbprint IS NOT NULL
496 - AND revoked_at IS NULL
499 + WHERE revoked_at IS NULL
500 AND consumed_at IS NULL
498 - AND (${proofKeyThumbprint} IS NULL OR proof_key_thumbprint = ${proofKeyThumbprint})
499 - AND proof_key_thumbprint IS NOT ${keepProofKeyThumbprint}
501 + AND (
502 + (
503 + proof_key_thumbprint IS NOT NULL
504 + AND (${proofKeyThumbprint} IS NULL OR proof_key_thumbprint = ${proofKeyThumbprint})
505 + AND proof_key_thumbprint IS NOT ${keepProofKeyThumbprint}
506 + )
507 + OR (proof_key_thumbprint IS NULL AND ${includeUnbound ? 1 : 0} = 1)
508 + )
509 RETURNING id AS "id"
510 `,
511 });