From cae7a139bc1bb0b841bb751fd862b5e7f4cd1e2a Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Wed, 5 Aug 2026 13:37:29 -0400 Subject: [PATCH] refactor(server): remove obsolete auth header helpers (#40682) --- packages/server/src/auth.ts | 17 ----------------- packages/server/test/auth.test.ts | 4 ---- 2 files changed, 21 deletions(-) diff --git a/packages/server/src/auth.ts b/packages/server/src/auth.ts index 5f016d75e07..e6647fbd784 100644 --- a/packages/server/src/auth.ts +++ b/packages/server/src/auth.ts @@ -2,10 +2,6 @@ export * as ServerAuth from "./auth" import { Context, Layer, Option, Redacted } from "effect" -export type Credentials = { - password?: string -} - export type DecodedCredentials = { readonly username: string readonly password: Redacted.Redacted @@ -37,16 +33,3 @@ export function authorized(credentials: DecodedCredentials, config: Info) { Redacted.value(credentials.password) === config.password.value ) } - -export function header(credentials?: Credentials) { - const password = credentials?.password - if (!password) return undefined - - return `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}` -} - -export function headers(credentials?: Credentials) { - const authorization = header(credentials) - if (!authorization) return undefined - return { Authorization: authorization } -} diff --git a/packages/server/test/auth.test.ts b/packages/server/test/auth.test.ts index dc160cb2902..1000103a42b 100644 --- a/packages/server/test/auth.test.ts +++ b/packages/server/test/auth.test.ts @@ -7,7 +7,3 @@ test("accepts only the fixed opencode username", () => { expect(ServerAuth.authorized({ username: "opencode", password: Redacted.make("secret") }, config)).toBe(true) expect(ServerAuth.authorized({ username: "custom", password: Redacted.make("secret") }, config)).toBe(false) }) - -test("encodes the fixed opencode username", () => { - expect(ServerAuth.header({ password: "secret" })).toBe(`Basic ${Buffer.from("opencode:secret").toString("base64")}`) -})