@@ -7,6 +7,7 @@ import * as Option from "effect/Option";
77import * as Path from "effect/Path" ;
88import * as Schema from "effect/Schema" ;
99import * as Hex from "effect/encoding/Hex" ;
10+ import * as FetchHttpClient from "effect/http/FetchHttpClient" ;
1011import * as HttpClient from "effect/http/HttpClient" ;
1112import * as HttpClientRequest from "effect/http/HttpClientRequest" ;
1213import * as HttpClientResponse from "effect/http/HttpClientResponse" ;
@@ -21,6 +22,9 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
2122const DEFAULT_API_SERVER_URL = "https://server.codeium.com" ;
2223const USER_STATUS_PATH = "/exa.seat_management_pb.SeatManagementService/GetUserStatus" ;
2324
25+ /** The API key in the request body must never follow a redirect off the API server. */
26+ const NO_REDIRECT : RequestInit = { redirect : "error" } ;
27+
2428const tomlString = ( contents : string , key : string ) : string | undefined =>
2529 new RegExp ( `^\\s*${ key } \\s*=\\s*"([^"\\n]*)"` , "m" ) . exec ( contents ) ?. [ 1 ] ;
2630
@@ -99,24 +103,26 @@ export const readDevinUsageLimits = Effect.fn("readDevinUsageLimits")(function*
99103 if ( ! apiUrl || apiUrl . protocol !== "https:" ) return unsupported ;
100104
101105 const client = yield * HttpClient . HttpClient ;
102- const response = yield * client . execute (
103- HttpClientRequest . post ( `${ apiUrl . origin } ${ USER_STATUS_PATH } ` ) . pipe (
104- HttpClientRequest . setHeaders ( {
105- "content-type" : "application/json" ,
106- "connect-protocol-version" : "1" ,
107- } ) ,
108- HttpClientRequest . bodyJsonUnsafe ( {
109- metadata : {
110- apiKey,
111- ideName : "t3code" ,
112- ideVersion : "0.0.0" ,
113- extensionName : "t3code" ,
114- extensionVersion : "0.0.0" ,
115- locale : "en" ,
116- } ,
117- } ) ,
118- ) ,
119- ) ;
106+ const response = yield * client
107+ . execute (
108+ HttpClientRequest . post ( `${ apiUrl . origin } ${ USER_STATUS_PATH } ` ) . pipe (
109+ HttpClientRequest . setHeaders ( {
110+ "content-type" : "application/json" ,
111+ "connect-protocol-version" : "1" ,
112+ } ) ,
113+ HttpClientRequest . bodyJsonUnsafe ( {
114+ metadata : {
115+ apiKey,
116+ ideName : "t3code" ,
117+ ideVersion : "0.0.0" ,
118+ extensionName : "t3code" ,
119+ extensionVersion : "0.0.0" ,
120+ locale : "en" ,
121+ } ,
122+ } ) ,
123+ ) ,
124+ )
125+ . pipe ( Effect . provideService ( FetchHttpClient . RequestInit , NO_REDIRECT ) ) ;
120126 if ( response . status === 401 || response . status === 403 ) return unsupported ;
121127 const body = yield * HttpClientResponse . filterStatusOk ( response ) . pipe (
122128 Effect . flatMap ( HttpClientResponse . schemaBodyJson ( GetUserStatusResponse ) ) ,
0 commit comments