The best way to control Claude Code, Codex and more from any computer or phone
fix(server): T3 Connect clients are named "T3 Connect", not "T3 Connect connect" (#27887)
Julius Marminge committed
Nov 13, 2026 at 16:42 UTC
99e10f05c8521445419cd0c09cedee0faa8f036b
2 files changed
+74
-8
apps/server/src/cloud/CloudLink.test.ts
+73
-7
@@ -1,5 +1,9 @@
1
+// @effect-diagnostics-next-line nodeBuiltinImport:off -- Effect's Crypto has no generateKeyPairSync.
2
+import * as NodeCrypto from "node:crypto";
3
import { EnvironmentId } from "@t3tools/contracts";
4
+import { RELAY_MINT_REQUEST_TYP, signRelayJwt } from "@t3tools/shared/relayJwt";
5
import { assert, it } from "@effect/vitest";
6
+import * as DateTime from "effect/DateTime";
7
import * as Effect from "effect/Effect";
8
import * as Fiber from "effect/Fiber";
9
import * as Layer from "effect/Layer";
@@ -7,7 +11,7 @@ import * as Option from "effect/Option";
11
import * as FetchHttpClient from "effect/http/FetchHttpClient";
12
import { HttpClient, HttpServer } from "effect/http";
13
import * as NetAddress from "effect/net/NetAddress";
10
-import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
14
+import * as NodePlatformCrypto from "@effect/platform-node/NodeCrypto";
15
import * as NodeServices from "@effect/platform-node/NodeServices";
16
17
import * as EnvironmentKeys from "./environmentKeys.ts";
@@ -22,6 +26,7 @@ import * as ConnectReachability from "./ConnectReachability.ts";
26
import * as ManagedEndpointRuntime from "./ManagedEndpointRuntime.ts";
27
import {
28
CLOUD_LINKED_USER_ID,
29
+ CLOUD_MINT_PUBLIC_KEY,
30
HOLD_WEBHOOKS_WHILE_OFFLINE_SECRET,
31
PUBLISH_AGENT_ACTIVITY_SECRET,
32
RELAY_ENVIRONMENT_CREDENTIAL_SECRET,
@@ -31,6 +36,11 @@ import * as ManagedPolicy from "../policy/ManagedPolicy.ts";
36
37
const encode = (value: string) => new TextEncoder().encode(value);
38
39
+const cloudMintKeys = NodeCrypto.generateKeyPairSync("ed25519", {
40
+ privateKeyEncoding: { format: "pem", type: "pkcs8" },
41
+ publicKeyEncoding: { format: "pem", type: "spki" },
42
+});
43
+
44
const withService = <A, E>(
45
options: {
46
readonly failHoldWrite?: boolean;
@@ -45,8 +55,10 @@ const withService = <A, E>(
55
},
56
body: (input: {
57
readonly preferences: { readonly update: CloudLink.CloudLink["Service"]["updatePreferences"] };
58
+ readonly mintCredential: CloudLink.CloudLink["Service"]["mintCredential"];
59
readonly stored: Map<string, Uint8Array>;
60
readonly relayCalls: Array<boolean>;
61
+ readonly pairingLinkLabels: Array<string | undefined>;
62
}) => Effect.Effect<A, E, never>,
63
) =>
64
Effect.gen(function* () {
@@ -55,8 +67,11 @@ const withService = <A, E>(
67
[RELAY_ENVIRONMENT_CREDENTIAL_SECRET, encode("credential")],
68
[HOLD_WEBHOOKS_WHILE_OFFLINE_SECRET, encode("false")],
69
[PUBLISH_AGENT_ACTIVITY_SECRET, encode("false")],
70
+ [CLOUD_MINT_PUBLIC_KEY, encode(cloudMintKeys.publicKey)],
71
+ [CLOUD_LINKED_USER_ID, encode("cloud-user-1")],
72
]);
73
const relayCalls: Array<boolean> = [];
74
+ const pairingLinkLabels: Array<string | undefined> = [];
75
const fetch: typeof globalThis.fetch = Object.assign(
76
(_input: Parameters<typeof globalThis.fetch>[0], init?: RequestInit) => {
77
const payload = JSON.parse(String(init?.body)) as { holdWebhooksWhileOffline: boolean };
@@ -93,6 +108,7 @@ const withService = <A, E>(
108
}),
109
)
110
: Effect.sync(() => void stored.set(name, value)),
111
+ create: (name, value) => Effect.sync(() => void stored.set(name, value)),
112
}),
113
Layer.mock(ServerEnvironment.ServerEnvironment)({
114
getEnvironmentId: Effect.succeed(EnvironmentId.make("environment-1")),
@@ -103,7 +119,20 @@ const withService = <A, E>(
119
Layer.mock(ConnectReachability.ConnectReachability)({
120
latest: Effect.succeedNone,
121
}),
106
- Layer.mock(EnvironmentAuth.EnvironmentAuth)({}),
122
+ Layer.mock(EnvironmentAuth.EnvironmentAuth)({
123
+ createPairingLink: (input) =>
124
+ Effect.sync(() => {
125
+ pairingLinkLabels.push(input?.label);
126
+ return {
127
+ id: "pairing-1",
128
+ credential: "pairing-credential",
129
+ scopes: input?.scopes ?? [],
130
+ subject: input?.subject ?? "",
131
+ createdAt: DateTime.makeUnsafe(0),
132
+ expiresAt: DateTime.makeUnsafe(120_000),
133
+ };
134
+ }),
135
+ }),
136
Layer.mock(CliTokenManager.CloudCliTokenManager)({}),
137
Layer.mock(HttpServer.HttpServer)({
138
address: NetAddress.inetAddressFromIpStringUnsafe("127.0.0.1", 3773),
@@ -114,16 +143,27 @@ const withService = <A, E>(
143
HttpClient.make(() => Effect.die("unused")),
144
),
145
NodeServices.layer,
117
- NodeCrypto.layer,
146
+ NodePlatformCrypto.layer,
147
);
148
return yield* Effect.gen(function* () {
149
const link = yield* CloudLink.CloudLink;
121
- return yield* body({ preferences: { update: link.updatePreferences }, stored, relayCalls });
150
+ return yield* body({
151
+ preferences: { update: link.updatePreferences },
152
+ mintCredential: link.mintCredential,
153
+ stored,
154
+ relayCalls,
155
+ pairingLinkLabels,
156
+ });
157
}).pipe(
158
Effect.provide(
159
CloudLink.layer.pipe(
125
- // These tests never sign proofs; the mocked secret store cannot create a key pair.
126
- Layer.provide(Layer.mock(EnvironmentKeys.EnvironmentSigningKey)({ publicKey: "" })),
160
+ // The mocked secret store cannot create a key pair, and no test reads the signature.
161
+ Layer.provide(
162
+ Layer.mock(EnvironmentKeys.EnvironmentSigningKey)({
163
+ publicKey: "",
164
+ sign: () => Effect.succeed("environment-signed-proof"),
165
+ }),
166
+ ),
167
Layer.provide(layerDependencies),
168
),
169
),
@@ -257,6 +297,32 @@ it.effect("an update the client walks away from still finishes", () => {
297
);
298
});
299
300
+it.effect('names T3 Connect sessions "T3 Connect" in authorized clients', () =>
301
+ withService({}, ({ mintCredential, pairingLinkLabels }) =>
302
+ Effect.gen(function* () {
303
+ const proof = yield* signRelayJwt({
304
+ privateKey: cloudMintKeys.privateKey,
305
+ typ: RELAY_MINT_REQUEST_TYP,
306
+ payload: {
307
+ iss: "https://relay.test",
308
+ aud: "t3-env:environment-1",
309
+ sub: "cloud-user-1",
310
+ jti: "mint-jti-1",
311
+ iat: 0,
312
+ exp: 60,
313
+ environmentId: "environment-1",
314
+ clientProofKeyThumbprint: "client-jkt",
315
+ cnf: { jkt: "client-jkt" },
316
+ nonce: "mint-nonce-1",
317
+ scope: ["environment:connect"],
318
+ },
319
+ }).pipe(Effect.provide(NodePlatformCrypto.layerSignature));
320
+ yield* mintCredential({ proof });
321
+ assert.deepEqual(pairingLinkLabels, ["T3 Connect"]);
322
+ }),
323
+ ),
324
+);
325
+
326
it.effect("unlinks on startup and refuses to link when the policy turns Connect off", () =>
327
Effect.gen(function* () {
328
const stored = new Map<string, Uint8Array>([
@@ -297,7 +363,7 @@ it.effect("unlinks on startup and refuses to link when the policy turns Connect
363
HttpClient.make(() => Effect.die("unused")),
364
),
365
NodeServices.layer,
300
- NodeCrypto.layer,
366
+ NodePlatformCrypto.layer,
367
);
368
yield* Effect.gen(function* () {
369
const link = yield* CloudLink.CloudLink;
apps/server/src/cloud/CloudLink.ts
+1
-1
@@ -1594,7 +1594,7 @@ const make = Effect.gen(function* () {
1594
scopes: AuthStandardClientScopes,
1595
subject: "cloud-connect",
1596
ttl: Duration.minutes(2),
1597
- label: "T3 Connect connect",
1597
+ label: "T3 Connect",
1598
proofKeyThumbprint: proof.clientProofKeyThumbprint,
1599
});
1600
const responsePayload = {