Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep managed Codex token renewal in the server #21786

Mergedjuliusmarmingemerged 5 commits intomain fromrefs/pull/21786/headmerged by juliusmarminge View on GitHub

Showing 4 changed files with 218 additions and 1 deletion (loading 3).

x
0 of 4 viewed, 4 left
218 additions and 1 deletionapps/server/src/provider/CodexChatGptAuth.test.tsModified
View file
@@ -1,4 +1,9 @@
// @effect-diagnostics nodeBuiltinImport:off globalFetchInEffect:off - Local mock OAuth server validates the browser callback boundary.
+import * as NodeNet from "node:net";
+import * as Context from "effect/Context";
+import * as Scope from "effect/Scope";
+import * as ServerConfig from "../config.ts";
+import * as CodexManagedTokenBroker from "./CodexManagedTokenBroker.ts";
import * as NodeHttp from "node:http";
import * as NodeCrypto from "node:crypto";
import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -11,7 +16,7 @@
import * as Fiber from "effect/Fiber";
import * as Deferred from "effect/Deferred";
import { subscribeChatGptHandoff } from "./CodexChatGptHandoff.ts";
-import { FetchHttpClient } from "effect/http";
+import { FetchHttpClient, HttpClient, HttpClientResponse } from "effect/http";
import { exportJWK, generateKeyPair, SignJWT } from "jose";
import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
@@ -320,6 +325,16 @@
return { auth: destination, bytes: destinationBytes };
}),
+ bindProfile: (expectedProfileKey: string) =>
+ makeCodexChatGptAuth({
+ instanceId,
+ expectedProfileKey,
+ discoveryUrl: `${origin}/discovery`,
+ resource: `${origin}/v1`,