Secrets: list all mounts and group dynamic engines by type
Adds listMounts and an engine registry (database, aws, ssh, generic fallback). The Secrets page groups mounts by engine; KV v2 keeps the path browser and dynamic mounts get a placeholder EngineView. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eba7c97de6
commit
6daed8d388
5 files changed
+149
-24
No files matched your search
+18
-3
@@ -14,17 +14,32 @@ export interface SecretEntry {
|
||||
isFolder: boolean
|
||||
}
|
||||
|
||||
export async function listKvMounts(c: BaoClient): Promise<KvMount[]> {
|
||||
export interface Mount {
|
||||
/** Mount path with trailing slash, e.g. "database/". */
|
||||
path: string
|
||||
/** Engine type as reported by sys/mounts, e.g. "kv", "database", "aws", "ssh". */
|
||||
type: string
|
||||
/** KV version ("1" | "2") when the engine is KV. */
|
||||
version?: string
|
||||
}
|
||||
|
||||
/** Every secrets engine mount visible to the token, sorted by path. */
|
||||
export async function listMounts(c: BaoClient): Promise<Mount[]> {
|
||||
const res = await c.request<{ data: Record<string, { type: string; options?: { version?: string } | null }> }>(
|
||||
'GET',
|
||||
'sys/mounts',
|
||||
)
|
||||
return Object.entries(res.data)
|
||||
.filter(([, m]) => m.type === 'kv' && m.options?.version === '2')
|
||||
.map(([path]) => ({ path }))
|
||||
.map(([path, m]) => ({ path, type: m.type, version: m.options?.version }))
|
||||
.sort((a, b) => a.path.localeCompare(b.path))
|
||||
}
|
||||
|
||||
export const isKvV2 = (m: Mount) => m.type === 'kv' && m.version === '2'
|
||||
|
||||
export async function listKvMounts(c: BaoClient): Promise<KvMount[]> {
|
||||
return (await listMounts(c)).filter(isKvV2).map(({ path }) => ({ path }))
|
||||
}
|
||||
|
||||
/** Lists metadata only; secret values are never read. `prefix` is "" or ends with "/". */
|
||||
export async function listSecrets(c: BaoClient, mount: string, prefix: string): Promise<SecretEntry[]> {
|
||||
const keys = await c.list(`${mount}metadata/${enc(prefix)}`)
|
||||
|
||||
Reference in new issue
Block a user