@elizaos/vault 2.0.0-alpha.537

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +159 -0
  2. package/dist/audit.d.ts +14 -0
  3. package/dist/audit.d.ts.map +1 -0
  4. package/dist/audit.js +27 -0
  5. package/dist/audit.js.map +1 -0
  6. package/dist/credentials.d.ts +58 -0
  7. package/dist/credentials.d.ts.map +1 -0
  8. package/dist/credentials.js +157 -0
  9. package/dist/credentials.js.map +1 -0
  10. package/dist/crypto.d.ts +18 -0
  11. package/dist/crypto.d.ts.map +1 -0
  12. package/dist/crypto.js +67 -0
  13. package/dist/crypto.js.map +1 -0
  14. package/dist/external-credentials.d.ts +62 -0
  15. package/dist/external-credentials.d.ts.map +1 -0
  16. package/dist/external-credentials.js +335 -0
  17. package/dist/external-credentials.js.map +1 -0
  18. package/dist/index.d.ts +35 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +26 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/install.d.ts +70 -0
  23. package/dist/install.d.ts.map +1 -0
  24. package/dist/install.js +163 -0
  25. package/dist/install.js.map +1 -0
  26. package/dist/inventory.d.ts +140 -0
  27. package/dist/inventory.d.ts.map +1 -0
  28. package/dist/inventory.js +319 -0
  29. package/dist/inventory.js.map +1 -0
  30. package/dist/manager.d.ts +161 -0
  31. package/dist/manager.d.ts.map +1 -0
  32. package/dist/manager.js +466 -0
  33. package/dist/manager.js.map +1 -0
  34. package/dist/master-key.d.ts +86 -0
  35. package/dist/master-key.d.ts.map +1 -0
  36. package/dist/master-key.js +247 -0
  37. package/dist/master-key.js.map +1 -0
  38. package/dist/password-managers.d.ts +17 -0
  39. package/dist/password-managers.d.ts.map +1 -0
  40. package/dist/password-managers.js +59 -0
  41. package/dist/password-managers.js.map +1 -0
  42. package/dist/profiles.d.ts +68 -0
  43. package/dist/profiles.d.ts.map +1 -0
  44. package/dist/profiles.js +189 -0
  45. package/dist/profiles.js.map +1 -0
  46. package/dist/store.d.ts +22 -0
  47. package/dist/store.d.ts.map +1 -0
  48. package/dist/store.js +137 -0
  49. package/dist/store.js.map +1 -0
  50. package/dist/testing.d.ts +32 -0
  51. package/dist/testing.d.ts.map +1 -0
  52. package/dist/testing.js +70 -0
  53. package/dist/testing.js.map +1 -0
  54. package/dist/types.d.ts +56 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +12 -0
  57. package/dist/types.js.map +1 -0
  58. package/dist/vault.d.ts +77 -0
  59. package/dist/vault.d.ts.map +1 -0
  60. package/dist/vault.js +269 -0
  61. package/dist/vault.js.map +1 -0
  62. package/package.json +59 -0
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Install spec — what install methods exist for each external secrets-manager
3
+ * backend on which OS, and how to detect whether a given package manager is
4
+ * present on the host.
5
+ *
6
+ * Detection-only. The actual `child_process` execution and streaming live in
7
+ * the consumer (app-core's `secrets-manager-installer`); this module is pure
8
+ * data + small async checks so it stays usable from the vault package
9
+ * without pulling in spawn/PTY machinery.
10
+ */
11
+ import { execFile } from "node:child_process";
12
+ import { promisify } from "node:util";
13
+ const exec = promisify(execFile);
14
+ /**
15
+ * Install specs for each external backend.
16
+ *
17
+ * Sources:
18
+ * - 1Password CLI: `brew install --cask 1password-cli`
19
+ * (https://developer.1password.com/docs/cli/get-started)
20
+ * - Bitwarden CLI: `brew install bitwarden-cli` (formula, not cask) or
21
+ * `npm install -g @bitwarden/cli`
22
+ * (https://bitwarden.com/help/cli/)
23
+ * - Proton Pass CLI: vendor CLI is in beta, no automated install path yet.
24
+ */
25
+ export const BACKEND_INSTALL_SPECS = {
26
+ "1password": {
27
+ id: "1password",
28
+ methods: {
29
+ darwin: [
30
+ { kind: "brew", package: "1password-cli", cask: true },
31
+ {
32
+ kind: "manual",
33
+ instructions: "Download the 1Password CLI installer for macOS from the official page.",
34
+ url: "https://developer.1password.com/docs/cli/get-started",
35
+ },
36
+ ],
37
+ linux: [
38
+ {
39
+ kind: "manual",
40
+ instructions: "Follow the official Linux install instructions (apt/dnf/zypper repo with signed packages).",
41
+ url: "https://developer.1password.com/docs/cli/get-started/#linux",
42
+ },
43
+ ],
44
+ win32: [
45
+ {
46
+ kind: "manual",
47
+ instructions: "Install via winget or the MSI from the official 1Password CLI page.",
48
+ url: "https://developer.1password.com/docs/cli/get-started/#windows",
49
+ },
50
+ ],
51
+ },
52
+ },
53
+ bitwarden: {
54
+ id: "bitwarden",
55
+ methods: {
56
+ darwin: [
57
+ { kind: "brew", package: "bitwarden-cli", cask: false },
58
+ { kind: "npm", package: "@bitwarden/cli" },
59
+ ],
60
+ linux: [{ kind: "npm", package: "@bitwarden/cli" }],
61
+ win32: [{ kind: "npm", package: "@bitwarden/cli" }],
62
+ },
63
+ },
64
+ protonpass: {
65
+ id: "protonpass",
66
+ methods: {
67
+ darwin: [
68
+ {
69
+ kind: "manual",
70
+ instructions: "Proton Pass CLI is in closed beta. Track Proton's roadmap or use the desktop app.",
71
+ url: "https://proton.me/pass",
72
+ },
73
+ ],
74
+ linux: [
75
+ {
76
+ kind: "manual",
77
+ instructions: "Proton Pass CLI is in closed beta. Track Proton's roadmap or use the desktop app.",
78
+ url: "https://proton.me/pass",
79
+ },
80
+ ],
81
+ win32: [
82
+ {
83
+ kind: "manual",
84
+ instructions: "Proton Pass CLI is in closed beta. Track Proton's roadmap or use the desktop app.",
85
+ url: "https://proton.me/pass",
86
+ },
87
+ ],
88
+ },
89
+ },
90
+ };
91
+ /**
92
+ * Per-OS package-manager availability (brew/npm). Cached for the process
93
+ * lifetime — the result doesn't change without a host-level install/remove,
94
+ * and the caller can force a re-detect by importing `resetInstallerCache`.
95
+ */
96
+ let _packageManagerCache = null;
97
+ export async function detectPackageManagers() {
98
+ if (_packageManagerCache)
99
+ return _packageManagerCache;
100
+ const [brew, npm] = await Promise.all([
101
+ isCommandRunnable("brew"),
102
+ isCommandRunnable("npm"),
103
+ ]);
104
+ _packageManagerCache = { brew, npm };
105
+ return _packageManagerCache;
106
+ }
107
+ export function resetInstallerCache() {
108
+ _packageManagerCache = null;
109
+ }
110
+ async function isCommandRunnable(cmd) {
111
+ try {
112
+ await exec(cmd, ["--version"], { timeout: 5000 });
113
+ return true;
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ }
119
+ /**
120
+ * Resolve the install methods that are *runnable on this host* for a given
121
+ * backend. Manual methods are always returned (so the UI can show the doc
122
+ * link); brew/npm methods are filtered to those whose tool is present.
123
+ */
124
+ export async function resolveRunnableMethods(id, platform = currentPlatform()) {
125
+ const spec = BACKEND_INSTALL_SPECS[id];
126
+ const candidates = spec.methods[platform] ?? [];
127
+ if (candidates.length === 0)
128
+ return [];
129
+ const tools = await detectPackageManagers();
130
+ return candidates.filter((m) => {
131
+ if (m.kind === "brew")
132
+ return tools.brew;
133
+ if (m.kind === "npm")
134
+ return tools.npm;
135
+ return true;
136
+ });
137
+ }
138
+ export function currentPlatform() {
139
+ const p = process.platform;
140
+ if (p === "darwin" || p === "linux" || p === "win32")
141
+ return p;
142
+ // Treat anything else as linux for dispatch purposes; specs only ship the
143
+ // three primary platforms today.
144
+ return "linux";
145
+ }
146
+ /**
147
+ * Build the argv for a given install method. Caller spawns directly with
148
+ * argv (no shell interpolation). Returns null for `manual` — those have no
149
+ * automated execution path.
150
+ */
151
+ export function buildInstallCommand(method) {
152
+ if (method.kind === "brew") {
153
+ const args = method.cask
154
+ ? ["install", "--cask", method.package]
155
+ : ["install", method.package];
156
+ return { command: "brew", args };
157
+ }
158
+ if (method.kind === "npm") {
159
+ return { command: "npm", args: ["install", "-g", method.package] };
160
+ }
161
+ return null;
162
+ }
163
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE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ault` that surfaces every stored
3
+ * key in a categorized, UI-renderable shape, and lets the user attach
4
+ * metadata (label, providerId, profiles, routing) to a key without
5
+ * changing the vault's underlying storage contract.
6
+ *
7
+ * Storage convention:
8
+ * - Original keys live exactly where they always have (e.g.
9
+ * `OPENROUTER_API_KEY`).
10
+ * - Metadata for a key K lives at `_meta.<K>` as a JSON-encoded
11
+ * non-sensitive entry.
12
+ * - When profiles are enabled for K, the per-profile values live at
13
+ * `<K>.profile.<profileId>`. The "active profile" pointer lives in
14
+ * the meta blob.
15
+ * - Routing rules across keys live at `_routing.config` as a single
16
+ * JSON-encoded non-sensitive entry.
17
+ *
18
+ * The vault layer remains dumb: `vault.get(K)` still returns the value
19
+ * stored under K. Profile resolution is a thin wrapper exposed by the
20
+ * manager (see `manager.getActive`). This file owns the metadata
21
+ * read/write/categorize logic only.
22
+ *
23
+ * Hard rule: `_meta.*` and `_routing.*` are reserved prefixes — every
24
+ * inventory listing filters them out so the user never sees a meta
25
+ * blob masquerading as a normal vault entry.
26
+ */
27
+ import type { Vault } from "./vault.js";
28
+ export declare const META_PREFIX = "_meta.";
29
+ export declare const ROUTING_KEY = "_routing.config";
30
+ export declare const PROFILE_SEGMENT = "profile";
31
+ /**
32
+ * High-level category of a vault entry — drives grouping in the UI.
33
+ *
34
+ * - `provider` — model-provider API keys (OPENAI_API_KEY, etc.)
35
+ * - `plugin` — non-provider plugin tokens (N8N_API_KEY, GITHUB_TOKEN, …)
36
+ * - `wallet` — wallet private keys / mnemonics
37
+ * - `credential` — saved-login records (`creds.<domain>.<user>`)
38
+ * - `system` — internal manager/preferences entries
39
+ * - `session` — password-manager session tokens (`pm.<vendor>.session`)
40
+ */
41
+ export type VaultEntryCategory = "provider" | "plugin" | "wallet" | "credential" | "system" | "session";
42
+ export interface VaultEntryProfile {
43
+ readonly id: string;
44
+ readonly label: string;
45
+ /** Epoch ms; missing on legacy entries. */
46
+ readonly createdAt?: number;
47
+ }
48
+ /**
49
+ * On-disk shape of `_meta.<key>`. Only the fields the user has set
50
+ * are persisted — partial writes via `setEntryMeta` merge.
51
+ */
52
+ export interface VaultEntryMetaRecord {
53
+ readonly category?: VaultEntryCategory;
54
+ readonly label?: string;
55
+ readonly providerId?: string;
56
+ readonly lastModified?: number;
57
+ readonly lastUsed?: number;
58
+ readonly profiles?: ReadonlyArray<VaultEntryProfile>;
59
+ readonly activeProfile?: string;
60
+ }
61
+ /**
62
+ * Inventory row as the UI sees it. `kind` mirrors the underlying vault
63
+ * entry's storage kind (secret = encrypted, value = plaintext config,
64
+ * reference = pointer into a password manager).
65
+ */
66
+ export interface VaultEntryMeta {
67
+ readonly key: string;
68
+ readonly category: VaultEntryCategory;
69
+ readonly label: string;
70
+ readonly providerId?: string;
71
+ readonly hasProfiles: boolean;
72
+ readonly activeProfile?: string;
73
+ readonly profiles?: ReadonlyArray<VaultEntryProfile>;
74
+ readonly lastModified?: number;
75
+ readonly lastUsed?: number;
76
+ readonly kind: "secret" | "value" | "reference";
77
+ }
78
+ /**
79
+ * Heuristic categorization for keys without an explicit `_meta.*` entry.
80
+ * Order matters: more specific patterns run first.
81
+ */
82
+ export declare function categorizeKey(key: string): VaultEntryCategory;
83
+ /**
84
+ * Provider id derivation when no explicit meta is set. Returns null
85
+ * when the key isn't a recognized provider env var.
86
+ */
87
+ export declare function inferProviderId(key: string): string | null;
88
+ /**
89
+ * Read the meta record for `key`, parsing the underlying JSON. Returns
90
+ * null when no meta has been written. Malformed JSON is treated as
91
+ * "no meta" and logged at warn — we never silently coerce a corrupt
92
+ * blob into a valid meta to mask the underlying problem.
93
+ */
94
+ export declare function readEntryMeta(vault: Vault, key: string): Promise<VaultEntryMetaRecord | null>;
95
+ /**
96
+ * Merge `partial` into the existing meta for `key`. Writing partial
97
+ * meta is the only public way to mutate metadata — callers always
98
+ * read-modify-write through this helper so concurrent fields don't
99
+ * clobber each other.
100
+ *
101
+ * Wipe a field by setting its value to `null` in the partial.
102
+ */
103
+ /**
104
+ * Partial-update payload accepted by `setEntryMeta`. Fields are
105
+ * optional; passing `null` deletes the underlying field from the
106
+ * stored meta blob (the only way to wipe e.g. activeProfile without
107
+ * round-tripping the entire record).
108
+ */
109
+ export interface VaultEntryMetaUpdate {
110
+ readonly category?: VaultEntryCategory | null;
111
+ readonly label?: string | null;
112
+ readonly providerId?: string | null;
113
+ readonly lastUsed?: number | null;
114
+ readonly profiles?: ReadonlyArray<VaultEntryProfile> | null;
115
+ readonly activeProfile?: string | null;
116
+ }
117
+ export declare function setEntryMeta(vault: Vault, key: string, partial: VaultEntryMetaUpdate): Promise<void>;
118
+ /**
119
+ * Drop the meta record for `key`. Callers are responsible for also
120
+ * removing the underlying value(s) and profile entries — this only
121
+ * touches `_meta.<key>`.
122
+ */
123
+ export declare function removeEntryMeta(vault: Vault, key: string): Promise<void>;
124
+ /**
125
+ * List every meaningful vault entry, grouped by category. Reserved
126
+ * `_meta.*` and `_routing.*` keys are filtered out, as are the
127
+ * `_manager.*` preferences keys.
128
+ *
129
+ * For keys with profile entries (`<K>.profile.<id>`), only the parent
130
+ * `<K>` is surfaced — the profile rows roll up under it.
131
+ */
132
+ export declare function listVaultInventory(vault: Vault): Promise<readonly VaultEntryMeta[]>;
133
+ /**
134
+ * Vault key for the storage backing one profile of a parent key.
135
+ *
136
+ * Profiles use dot separators so `vault.list("<KEY>")` matches both the
137
+ * parent and every profile via the existing prefix logic.
138
+ */
139
+ export declare function profileStorageKey(key: string, profileId: string): string;
140
+ //# sourceMappingURL=inventory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../src/inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAC7C,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;;;;;;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AAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAUxE"}
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Vault inventory: a meta-layer over `Vault` that surfaces every stored
3
+ * key in a categorized, UI-renderable shape, and lets the user attach
4
+ * metadata (label, providerId, profiles, routing) to a key without
5
+ * changing the vault's underlying storage contract.
6
+ *
7
+ * Storage convention:
8
+ * - Original keys live exactly where they always have (e.g.
9
+ * `OPENROUTER_API_KEY`).
10
+ * - Metadata for a key K lives at `_meta.<K>` as a JSON-encoded
11
+ * non-sensitive entry.
12
+ * - When profiles are enabled for K, the per-profile values live at
13
+ * `<K>.profile.<profileId>`. The "active profile" pointer lives in
14
+ * the meta blob.
15
+ * - Routing rules across keys live at `_routing.config` as a single
16
+ * JSON-encoded non-sensitive entry.
17
+ *
18
+ * The vault layer remains dumb: `vault.get(K)` still returns the value
19
+ * stored under K. Profile resolution is a thin wrapper exposed by the
20
+ * manager (see `manager.getActive`). This file owns the metadata
21
+ * read/write/categorize logic only.
22
+ *
23
+ * Hard rule: `_meta.*` and `_routing.*` are reserved prefixes — every
24
+ * inventory listing filters them out so the user never sees a meta
25
+ * blob masquerading as a normal vault entry.
26
+ */
27
+ // Reserved key prefixes. Anything starting with these is internal to
28
+ // the inventory layer and must not surface to UI listings.
29
+ export const META_PREFIX = "_meta.";
30
+ export const ROUTING_KEY = "_routing.config";
31
+ export const PROFILE_SEGMENT = "profile";
32
+ // ── Categorization ──────────────────────────────────────────────────
33
+ /**
34
+ * Heuristic categorization for keys without an explicit `_meta.*` entry.
35
+ * Order matters: more specific patterns run first.
36
+ */
37
+ export function categorizeKey(key) {
38
+ if (key.startsWith("creds."))
39
+ return "credential";
40
+ if (key.startsWith("pm."))
41
+ return "session";
42
+ if (key.startsWith("_manager.") || key === ROUTING_KEY)
43
+ return "system";
44
+ if (/(?:_PRIVATE_KEY|_MNEMONIC|_SEED_PHRASE)$/i.test(key) ||
45
+ /^(?:EVM|SOLANA|BTC|ETH|BITCOIN)_/i.test(key) ||
46
+ // wallet.<agent>.<chain>.privateKey (Phase 3 unified storage)
47
+ key.startsWith("wallet.") ||
48
+ // Legacy per-agent shape: agent.<name>.wallet.<chain>
49
+ /(?:^|\.)wallet\./i.test(key)) {
50
+ return "wallet";
51
+ }
52
+ if (/_API_KEY$/.test(key)) {
53
+ if (PROVIDER_KEY_PATTERNS.some((rx) => rx.test(key)))
54
+ return "provider";
55
+ return "plugin";
56
+ }
57
+ if (PROVIDER_EXACT_KEYS.has(key))
58
+ return "provider";
59
+ return "plugin";
60
+ }
61
+ /**
62
+ * Provider id derivation when no explicit meta is set. Returns null
63
+ * when the key isn't a recognized provider env var.
64
+ */
65
+ export function inferProviderId(key) {
66
+ const lookup = PROVIDER_KEY_TO_ID[key];
67
+ if (lookup)
68
+ return lookup;
69
+ const m = /^([A-Z][A-Z0-9_]*)_API_KEY$/.exec(key);
70
+ if (m)
71
+ return m[1].toLowerCase();
72
+ return null;
73
+ }
74
+ const PROVIDER_KEY_TO_ID = {
75
+ OPENAI_API_KEY: "openai",
76
+ ANTHROPIC_API_KEY: "anthropic",
77
+ OPENROUTER_API_KEY: "openrouter",
78
+ GROQ_API_KEY: "groq",
79
+ XAI_API_KEY: "grok",
80
+ DEEPSEEK_API_KEY: "deepseek",
81
+ MISTRAL_API_KEY: "mistral",
82
+ TOGETHER_API_KEY: "together",
83
+ GOOGLE_GENERATIVE_AI_API_KEY: "gemini",
84
+ GOOGLE_API_KEY: "gemini",
85
+ GEMINI_API_KEY: "gemini",
86
+ };
87
+ const PROVIDER_EXACT_KEYS = new Set(Object.keys(PROVIDER_KEY_TO_ID));
88
+ const PROVIDER_KEY_PATTERNS = [
89
+ /^OPENAI_API_KEY$/,
90
+ /^ANTHROPIC_API_KEY$/,
91
+ /^OPENROUTER_API_KEY$/,
92
+ /^GROQ_API_KEY$/,
93
+ /^XAI_API_KEY$/,
94
+ /^DEEPSEEK_API_KEY$/,
95
+ /^MISTRAL_API_KEY$/,
96
+ /^TOGETHER_API_KEY$/,
97
+ /^GOOGLE_(?:GENERATIVE_AI_)?API_KEY$/,
98
+ /^GEMINI_API_KEY$/,
99
+ /^PERPLEXITY_API_KEY$/,
100
+ ];
101
+ // ── Default labels ─────────────────────────────────────────────────
102
+ const PROVIDER_LABELS = {
103
+ openai: "OpenAI",
104
+ anthropic: "Anthropic",
105
+ openrouter: "OpenRouter",
106
+ groq: "Groq",
107
+ grok: "xAI Grok",
108
+ deepseek: "DeepSeek",
109
+ mistral: "Mistral",
110
+ together: "Together",
111
+ gemini: "Gemini",
112
+ };
113
+ function defaultLabel(key, providerId) {
114
+ if (providerId && PROVIDER_LABELS[providerId])
115
+ return PROVIDER_LABELS[providerId];
116
+ return key;
117
+ }
118
+ // ── Public API ─────────────────────────────────────────────────────
119
+ /**
120
+ * Read the meta record for `key`, parsing the underlying JSON. Returns
121
+ * null when no meta has been written. Malformed JSON is treated as
122
+ * "no meta" and logged at warn — we never silently coerce a corrupt
123
+ * blob into a valid meta to mask the underlying problem.
124
+ */
125
+ export async function readEntryMeta(vault, key) {
126
+ const metaKey = `${META_PREFIX}${key}`;
127
+ if (!(await vault.has(metaKey)))
128
+ return null;
129
+ const raw = await vault.get(metaKey);
130
+ return parseMetaRecord(raw, metaKey);
131
+ }
132
+ export async function setEntryMeta(vault, key, partial) {
133
+ const metaKey = `${META_PREFIX}${key}`;
134
+ const existing = (await readEntryMeta(vault, key)) ?? {};
135
+ const merged = { ...existing };
136
+ for (const [k, v] of Object.entries(partial)) {
137
+ if (v === null) {
138
+ delete merged[k];
139
+ continue;
140
+ }
141
+ if (v === undefined)
142
+ continue;
143
+ merged[k] = v;
144
+ }
145
+ merged.lastModified = Date.now();
146
+ // Meta is non-sensitive but its content describes which keys exist
147
+ // and which profiles a user maintains — disclosure-meaningful but
148
+ // not credential-bearing. Stored as a plain `value` entry; the
149
+ // sensitive value sits in `<key>` (or `<key>.profile.<id>`).
150
+ await vault.set(metaKey, JSON.stringify(merged));
151
+ }
152
+ /**
153
+ * Drop the meta record for `key`. Callers are responsible for also
154
+ * removing the underlying value(s) and profile entries — this only
155
+ * touches `_meta.<key>`.
156
+ */
157
+ export async function removeEntryMeta(vault, key) {
158
+ const metaKey = `${META_PREFIX}${key}`;
159
+ if (await vault.has(metaKey)) {
160
+ await vault.remove(metaKey);
161
+ }
162
+ }
163
+ /**
164
+ * List every meaningful vault entry, grouped by category. Reserved
165
+ * `_meta.*` and `_routing.*` keys are filtered out, as are the
166
+ * `_manager.*` preferences keys.
167
+ *
168
+ * For keys with profile entries (`<K>.profile.<id>`), only the parent
169
+ * `<K>` is surfaced — the profile rows roll up under it.
170
+ */
171
+ export async function listVaultInventory(vault) {
172
+ const allKeys = await vault.list();
173
+ const profileChildren = new Set();
174
+ // First pass: identify keys that are themselves children of a
175
+ // profile-bearing parent. Pattern: <PARENT>.profile.<id>.
176
+ // We strip these so the inventory only ever exposes the parent.
177
+ for (const k of allKeys) {
178
+ const split = k.indexOf(`.${PROFILE_SEGMENT}.`);
179
+ if (split > 0)
180
+ profileChildren.add(k);
181
+ }
182
+ // The set of parents we want to expose:
183
+ // 1. Every concrete vault key that isn't a profile child or a
184
+ // reserved internal key.
185
+ // 2. Every parent whose `_meta.<key>` exists even if the bare key
186
+ // itself doesn't (the user has profiles but no legacy default
187
+ // value at the bare key — common after `migrate-to-profiles`).
188
+ const parentKeys = new Set();
189
+ for (const key of allKeys) {
190
+ if (key.startsWith(META_PREFIX)) {
191
+ parentKeys.add(key.slice(META_PREFIX.length));
192
+ continue;
193
+ }
194
+ if (key === ROUTING_KEY)
195
+ continue;
196
+ if (key.startsWith("_manager."))
197
+ continue;
198
+ if (profileChildren.has(key))
199
+ continue;
200
+ parentKeys.add(key);
201
+ }
202
+ const out = [];
203
+ for (const key of parentKeys) {
204
+ const descriptor = await vault.describe(key);
205
+ const meta = await readEntryMeta(vault, key);
206
+ if (!descriptor && !meta)
207
+ continue; // nothing to surface
208
+ const kind = descriptor
209
+ ? descriptorKind(descriptor.source)
210
+ : "secret"; // meta-only parents are presumed to back sensitive data
211
+ const providerId = meta?.providerId ?? inferProviderId(key) ?? undefined;
212
+ const category = meta?.category ?? categorizeKey(key);
213
+ const label = meta?.label ?? defaultLabel(key, providerId ?? null);
214
+ const profiles = meta?.profiles ?? [];
215
+ const hasProfiles = profiles.length > 0;
216
+ out.push({
217
+ key,
218
+ category,
219
+ label,
220
+ ...(providerId ? { providerId } : {}),
221
+ hasProfiles,
222
+ ...(meta?.activeProfile ? { activeProfile: meta.activeProfile } : {}),
223
+ ...(hasProfiles ? { profiles } : {}),
224
+ ...(meta?.lastModified !== undefined
225
+ ? { lastModified: meta.lastModified }
226
+ : descriptor?.lastModified !== undefined
227
+ ? { lastModified: descriptor.lastModified }
228
+ : {}),
229
+ ...(meta?.lastUsed !== undefined ? { lastUsed: meta.lastUsed } : {}),
230
+ kind,
231
+ });
232
+ }
233
+ return out;
234
+ }
235
+ /**
236
+ * Vault key for the storage backing one profile of a parent key.
237
+ *
238
+ * Profiles use dot separators so `vault.list("<KEY>")` matches both the
239
+ * parent and every profile via the existing prefix logic.
240
+ */
241
+ export function profileStorageKey(key, profileId) {
242
+ if (typeof profileId !== "string" || profileId.length === 0) {
243
+ throw new TypeError("profileStorageKey: profileId must be non-empty");
244
+ }
245
+ if (!/^[a-zA-Z0-9_-]+$/.test(profileId)) {
246
+ throw new TypeError(`profileStorageKey: profileId must match [a-zA-Z0-9_-]+, got ${JSON.stringify(profileId)}`);
247
+ }
248
+ return `${key}.${PROFILE_SEGMENT}.${profileId}`;
249
+ }
250
+ // ── Internals ───────────────────────────────────────────────────────
251
+ function descriptorKind(source) {
252
+ if (source === "file")
253
+ return "value";
254
+ if (source === "keychain-encrypted")
255
+ return "secret";
256
+ return "reference";
257
+ }
258
+ function parseMetaRecord(raw, metaKey) {
259
+ const parsed = JSON.parse(raw);
260
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
261
+ throw new Error(`vault: meta entry ${metaKey} is not a JSON object (got ${typeof parsed})`);
262
+ }
263
+ const obj = parsed;
264
+ const out = {};
265
+ const cat = obj.category;
266
+ if (typeof cat === "string" && isCategory(cat)) {
267
+ out.category = cat;
268
+ }
269
+ if (typeof obj.label === "string" && obj.label.length > 0) {
270
+ out.label = obj.label;
271
+ }
272
+ if (typeof obj.providerId === "string" && obj.providerId.length > 0) {
273
+ out.providerId = obj.providerId;
274
+ }
275
+ if (typeof obj.lastModified === "number") {
276
+ out.lastModified = obj.lastModified;
277
+ }
278
+ if (typeof obj.lastUsed === "number") {
279
+ out.lastUsed = obj.lastUsed;
280
+ }
281
+ if (typeof obj.activeProfile === "string" && obj.activeProfile.length > 0) {
282
+ out.activeProfile = obj.activeProfile;
283
+ }
284
+ if (Array.isArray(obj.profiles)) {
285
+ const profiles = [];
286
+ for (const p of obj.profiles) {
287
+ if (!p || typeof p !== "object")
288
+ continue;
289
+ const rec = p;
290
+ if (typeof rec.id !== "string" || rec.id.length === 0)
291
+ continue;
292
+ const label = typeof rec.label === "string" && rec.label.length > 0
293
+ ? rec.label
294
+ : rec.id;
295
+ const profile = {
296
+ id: rec.id,
297
+ label,
298
+ ...(typeof rec.createdAt === "number"
299
+ ? { createdAt: rec.createdAt }
300
+ : {}),
301
+ };
302
+ profiles.push(profile);
303
+ }
304
+ if (profiles.length > 0) {
305
+ out.profiles =
306
+ profiles;
307
+ }
308
+ }
309
+ return out;
310
+ }
311
+ function isCategory(v) {
312
+ return (v === "provider" ||
313
+ v === "plugin" ||
314
+ v === "wallet" ||
315
+ v === "credential" ||
316
+ v === "system" ||
317
+ v === "session");
318
+ }
319
+ //# sourceMappingURL=inventory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inventory.js","sourceRoot":"","sources":["../src/inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,qEAAqE;AACrE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;AACpC,MAAM,CAAC,MAAM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