Skip to content

Commit 0418055

Browse files
refactor: replace jose with effect/jose
Effect 4.1 ships JOSE support, so relay JWTs, Codex OIDC verification and web DPoP proofs now use effect/jose. relayJwt verifies against the ambient Clock, decodes claims with a schema, and requires Signature from the environment. jose stays only for the vendored task-cache worker. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9d7f771 commit 0418055

33 files changed

Lines changed: 553 additions & 439 deletions

‎apps/server/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"diff": "8.0.3",
6464
"effect": "catalog:",
6565
"ffi-rs": "1.3.2",
66-
"jose": "catalog:",
6766
"node-pty": "^1.2.0-beta.15",
6867
"playwright-core": "1.60.0",
6968
"proper-lockfile": "4.1.2",

‎apps/server/src/cloud/CloudLink.ts‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
import { isSecureRelayUrl } from "@t3tools/shared/relayUrl";
4545
import * as Context from "effect/Context";
4646
import * as SecureRandom from "effect/crypto/SecureRandom";
47+
import * as Signature from "effect/crypto/Signature";
4748
import * as DateTime from "effect/DateTime";
4849
import * as Duration from "effect/Duration";
4950
import * as Effect from "effect/Effect";
@@ -374,9 +375,6 @@ function normalizePemForSignedPayload(value: string): string {
374375
return value.trim();
375376
}
376377

377-
const decodeCloudHealthProof = Schema.decodeUnknownEffect(RelayCloudEnvironmentHealthProofPayload);
378-
const decodeCloudMintProof = Schema.decodeUnknownEffect(RelayCloudMintCredentialProofPayload);
379-
380378
type ManagedTunnelRecoveryProofInput = {
381379
readonly environmentId: RelayManagedEndpointRecoveryProofPayload["environmentId"];
382380
readonly cloudUserId: string;
@@ -532,6 +530,7 @@ const make = Effect.gen(function* () {
532530
const httpServer = yield* HttpServer.HttpServer;
533531
const awarenessRelay = yield* AgentAwarenessRelay.AgentAwarenessRelay;
534532
const random = yield* SecureRandom.SecureRandom;
533+
const signature = yield* Signature.Signature;
535534
const config = yield* ServerConfig.ServerConfig;
536535
const fileSystem = yield* FileSystem.FileSystem;
537536
const path = yield* Path.Path;
@@ -623,6 +622,7 @@ const make = Effect.gen(function* () {
623622
typ: RELAY_LINK_PROOF_TYP,
624623
payload,
625624
}).pipe(
625+
Effect.provideService(Signature.Signature, signature),
626626
Effect.mapError(
627627
(cause) =>
628628
new EnvironmentAuth.ServerAuthCloudLinkJwtSigningError({
@@ -960,6 +960,7 @@ const make = Effect.gen(function* () {
960960
typ: RELAY_MANAGED_TUNNEL_RECOVERY_TYP,
961961
payload,
962962
}).pipe(
963+
Effect.provideService(Signature.Signature, signature),
963964
Effect.mapError(
964965
(cause) => new CloudLinkInternalError({ operation: "sign-recovery-proof", cause }),
965966
),
@@ -1453,14 +1454,13 @@ const make = Effect.gen(function* () {
14531454
const linkedCloudUserId = yield* readInstalledCloudUserId;
14541455
const now = yield* DateTime.now;
14551456
const nowSeconds = Math.floor(now.epochMilliseconds / 1_000);
1456-
const proofOption = yield* verifyRelayJwt({
1457+
const proofOption = yield* verifyRelayJwt(RelayCloudEnvironmentHealthProofPayload, {
14571458
publicKey: cloudMintPublicKey,
14581459
token: request.proof,
14591460
typ: RELAY_HEALTH_REQUEST_TYP,
14601461
issuer: normalizeRelayIssuer(relayIssuer),
14611462
audience: `t3-env:${environmentId}`,
1462-
nowEpochSeconds: nowSeconds,
1463-
}).pipe(Effect.flatMap(decodeCloudHealthProof), Effect.option);
1463+
}).pipe(Effect.provideService(Signature.Signature, signature), Effect.option);
14641464
if (
14651465
Option.isNone(proofOption) ||
14661466
proofOption.value.environmentId !== environmentId ||
@@ -1504,6 +1504,7 @@ const make = Effect.gen(function* () {
15041504
typ: RELAY_HEALTH_RESPONSE_TYP,
15051505
payload: responsePayload,
15061506
}).pipe(
1507+
Effect.provideService(Signature.Signature, signature),
15071508
Effect.mapError(
15081509
(cause) =>
15091510
new EnvironmentAuth.ServerAuthCloudHealthJwtSigningError({
@@ -1556,14 +1557,13 @@ const make = Effect.gen(function* () {
15561557
const linkedCloudUserId = yield* readInstalledCloudUserId;
15571558
const now = yield* DateTime.now;
15581559
const nowSeconds = Math.floor(now.epochMilliseconds / 1_000);
1559-
const proofOption = yield* verifyRelayJwt({
1560+
const proofOption = yield* verifyRelayJwt(RelayCloudMintCredentialProofPayload, {
15601561
publicKey: cloudMintPublicKey,
15611562
token: request.proof,
15621563
typ: RELAY_MINT_REQUEST_TYP,
15631564
issuer: normalizeRelayIssuer(relayIssuer),
15641565
audience: `t3-env:${environmentId}`,
1565-
nowEpochSeconds: nowSeconds,
1566-
}).pipe(Effect.flatMap(decodeCloudMintProof), Effect.option);
1566+
}).pipe(Effect.provideService(Signature.Signature, signature), Effect.option);
15671567
if (
15681568
Option.isNone(proofOption) ||
15691569
proofOption.value.environmentId !== environmentId ||
@@ -1612,6 +1612,7 @@ const make = Effect.gen(function* () {
16121612
typ: RELAY_MINT_RESPONSE_TYP,
16131613
payload: responsePayload,
16141614
}).pipe(
1615+
Effect.provideService(Signature.Signature, signature),
16151616
Effect.mapError(
16161617
(cause) =>
16171618
new EnvironmentAuth.ServerAuthCloudMintJwtSigningError({

0 commit comments

Comments
 (0)