refactor(core): describe secret storage as a SecretStore interface (P1.2)

This commit is contained in:
shumeiko.it
2026-10-24 12:07:42 +02:00
parent 815c667374
commit cb51ed0d28
3 changed files with 37 additions and 7 deletions

View File

@@ -0,0 +1,32 @@
/**
* SecretStore — where Waggle keeps API keys, connector tokens and other
* secrets (P1.2). Code that reads or writes secrets depends on this interface;
* `VaultStore` is the file-backed implementation (AES-256-GCM entries in
* `vault.json`, key in `.vault-key` protected by owner-only permissions).
*/
export interface SecretEntry {
name: string;
value: string;
metadata?: Record<string, unknown>;
updatedAt: string;
}
export interface SecretSummary {
name: string;
metadata?: Record<string, unknown>;
updatedAt: string;
}
export interface SecretStore {
/** The decrypted secret, or null when it is missing or cannot be read. */
get(name: string): SecretEntry | null;
set(name: string, value: string, metadata?: Record<string, unknown>): void;
setAsync(name: string, value: string, metadata?: Record<string, unknown>): Promise<void>;
/** Returns true when the secret existed. */
delete(name: string): boolean;
deleteAsync(name: string): Promise<boolean>;
/** Names and metadata, never values. */
list(): SecretSummary[];
has(name: string): boolean;
}