|
|
@@ -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 }
|
|
|
-}
|