mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
25 lines
646 B
TypeScript
25 lines
646 B
TypeScript
export type TokenStoreKind = 'env' | 'keychain' | 'file'
|
|
|
|
export interface TokenStoreDescription {
|
|
kind: TokenStoreKind
|
|
location: string
|
|
}
|
|
|
|
export interface TokenStore {
|
|
describe(): TokenStoreDescription
|
|
get(account: string): Promise<string | null>
|
|
set(account: string, token: string): Promise<void>
|
|
delete(account: string): Promise<boolean>
|
|
}
|
|
|
|
export class TokenStoreError extends Error {
|
|
constructor(message: string, public kind: TokenStoreKind) {
|
|
super(message)
|
|
this.name = 'TokenStoreError'
|
|
}
|
|
}
|
|
|
|
export function describeCause(cause: unknown): string {
|
|
return cause instanceof Error ? cause.message : String(cause)
|
|
}
|