@@ -44,6 +44,7 @@ import {
4444import { isSecureRelayUrl } from "@t3tools/shared/relayUrl" ;
4545import * as Context from "effect/Context" ;
4646import * as SecureRandom from "effect/crypto/SecureRandom" ;
47+ import * as Signature from "effect/crypto/Signature" ;
4748import * as DateTime from "effect/DateTime" ;
4849import * as Duration from "effect/Duration" ;
4950import * 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-
380378type 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