mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* feat(ocm-cli): add file and keychain credential backends with auth commands * feat(ocm-cli): refactor credentials into async TokenStore architecture Replace the credential-backend module with a TokenStore interface and file/keychain implementations behind an internal facade. Convert token get/set/delete to async, add env-token precedence warnings on login and logout, and surface store availability in status. Add token-store tests and helpers; remove the old credential modules and tests. Bump to 0.2.6. * fix(ocm-cli): keep tokens out of security argv and stop masking config read errors Route every macOS Keychain call through `security -i`, sending the quoted command on stdin so the token is never visible in process arguments. Reject arguments containing line breaks, which would otherwise inject additional security commands. Let unexpected state file read failures propagate so a broken config dir is reported instead of being reduced to "no manager configured", and stop consuming the install notice when reading it fails unexpectedly. --------- Co-authored-by: CS <chris@chriswritescode.dev>
25 lines
638 B
TypeScript
25 lines
638 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(err: unknown): string {
|
|
return err instanceof Error ? err.message : String(err)
|
|
}
|