Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(auth): keep login URLs when OSC sequences end with ST (#2124)

12d3b3f56661f6
diff --git a/sdk/typescript/src/auth.ts b/sdk/typescript/src/auth.ts
index b53100933..1c07eede6 100644
--- a/sdk/typescript/src/auth.ts
+++ b/sdk/typescript/src/auth.ts
@@ -372,7 +372,7 @@ function userCodeFromOutput(value: string): string | null {
function plainTerminalText(value: string): string {
return value
- .replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/g, "")
+ .replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, "")
.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "")
.replace(/\r/g, "");
}
diff --git a/sdk/typescript/tests-ts/auth.test.ts b/sdk/typescript/tests-ts/auth.test.ts
index f99144769..54ae5db68 100644
--- a/sdk/typescript/tests-ts/auth.test.ts
+++ b/sdk/typescript/tests-ts/auth.test.ts
@@ -255,6 +255,23 @@ describe("Codex authentication process boundary", () => {
},
);
+ test("reads login URLs from hyperlinks terminated with ST", async () => {
+ const url = "https://auth.example.test/device";
+ const st = "\u001b\\";
+ const link = `\u001b]8;;https://link.example.test/${st}${url}\u001b]8;;${st}`;
+ const output = `Open ${link}\nUser code: ABCD-EFGH\n`;
+ const handle = new CodexLoginHandle(
+ nodeCommand(),
+ ["-e", "process.stderr.write(process.argv[1])", output],
+ process.env,
+ () => {},
+ );
+
+ await expect(handle.wait()).resolves.toMatchObject({ success: true });
+ expect(handle.verificationUrl).toBe(url);
+ expect(handle.userCode).toBe("ABCD-EFGH");
+ });
+
test("retains large interactive output and login instructions", async () => {
const root = await temporaryDirectory("codex-security-auth-output-");
const script = join(root, "login.mjs");