-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcallback-server.ts
More file actions
27 lines (24 loc) · 948 Bytes
/
Copy pathcallback-server.ts
File metadata and controls
27 lines (24 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { startCallbackServer, type CallbackServer } from "@corbits/oauth-core";
import {
authorizationDoneHtml,
callbackPageHtml,
type CallbackPageCopy,
} from "../callback-page.js";
import { CODEX_CALLBACK_PATH, CODEX_CALLBACK_PORT } from "./constants.js";
export type CodexCallbackServer = CallbackServer;
// Codex registers a fixed loopback redirect on port 1455; the authorization
// server only accepts this exact redirect_uri for this client.
export async function startCodexCallbackServer(
expectedState: string,
copy: CallbackPageCopy,
): Promise<CodexCallbackServer> {
return startCallbackServer(expectedState, {
port: CODEX_CALLBACK_PORT,
// Codex's registered redirect_uri uses localhost (not 127.0.0.1).
host: "localhost",
path: CODEX_CALLBACK_PATH,
doneHtml: authorizationDoneHtml("Codex", copy),
failedHtml: (reason) =>
callbackPageHtml({ subject: "Codex", error: reason }, copy),
});
}