Expand description
Encrypted secrets manager for developers — one file, age encryption, git-friendly.
This library provides the core functionality for murk: vault I/O, age encryption, BIP39 key recovery, and secret management. The CLI binary wraps this library.
Re-exports§
pub use error::MurkError;pub use github::GitHubError;pub use github::fetch_keys;pub use crypto::MurkIdentity;pub use crypto::MurkRecipient;
Modules§
- cli
- CLI command model: the clap
Parser/Subcommandtypes. - connect
- Wiring
murk mcpinto AI-editor MCP client configs — the engine behindmurk agent connect/murk agent disconnect. - crypto
- edit
- Edit buffer parsing and diff logic for
murk edit. - error
- Unified error type for the murk library.
- github
- GitHub SSH key fetching for
murk authorize github:username. - hardening
- Process hardening: best-effort defense-in-depth measures.
- pins
- Trust-on-first-use pinning of a vault’s signer registry.
- recovery
- scan
- Scan files for leaked secret values.
- signing
- Ed25519 signatures over the vault — integrity against an active attacker with write access to the repo.
- types
- vault
Structs§
- Agent
Plan - Schema-only view of a vault, suitable for agent prompt context.
- Agent
Plan Key - One key in the schema. Mirrors
info::InfoEntryminus any field that names a recipient or carries recipient-derived metadata. - Diff
Entry - A single entry in a secret diff.
- Discovered
Key - A key discovered from the environment or .env file.
- Info
Entry - A single key entry in the vault info output.
- Init
Status - Status of an existing vault relative to a given key.
- Merge
Driver Output - Output of the merge driver: the merge result and whether meta was regenerated.
- Recipient
Entry - A single recipient entry with resolved display info.
- Revoke
Result - Result of revoking a recipient.
- Vault
Info - Aggregated vault information for display.
Enums§
- Commit
Signature - Signature status of the most recent commit that modified
path. - Diff
Kind - The kind of change in a diff entry.
- Envrc
Status - Status of
.envrcafter writing. - KeySource
- Where the resolved key came from.
- Merge
Driver Setup Step - A step completed during merge driver setup.
- Rotation
Issue - A rotation-hygiene problem found by
rotation_health.
Constants§
- EXPIRY_
WARN_ DAYS - Days of lead time before a hard
expires_atis flagged as “expiring soon”.
Functions§
- add_
grouped_ secret - Add or update a secret encrypted to a named group. The operator must be a member of the group (so they can read it and re-encrypt it later). Assigning a secret to a group makes the group its sole base tier: any existing shared value and other group assignments are dropped so non-members can’t read it. Returns true if the key was new (no existing schema entry).
- add_
member - Add a member to a group. The group must exist, the operator must already be a member (so they can re-encrypt the group’s secrets), and the new member must be an authorized recipient. Returns true if the member was added (false if already present).
- add_
secret - Add or update a secret in the working state.
If
scopedis true, stores in scoped (encrypted to self only). Returns true if the key was new (no existing schema entry). - agent_
key_ file_ path - Compute the file path for an agent grant key:
~/.config/murk/agent-keys/<vault-hash>-<name>. - agent_
keys_ dir - Return
~/.config/murk/agent-keys/, creating it if needed (dir0700). - agent_
plan - Build an
AgentPlanfrom a vault’s schema. Iftagsis non-empty an entry is included only when it carries one of the requested tags. - authorize_
recipient - Add a recipient to the vault. Returns an error if the pubkey is invalid or already present.
- check_
agent_ keys - Check that every key in
keysis permitted to agents by the vault’s policy. - check_
init_ status - Check whether a secret key is authorized in an existing vault.
- create_
grant - Create an agent grant in the working state. The caller mints the ephemeral
identity, adds
agent_pubkeyto the vault recipients, and registers its display name before calling this. Encrypts a private copy of each scope key’s shared value to the agent and records the grant metadata. - create_
group - Create a new empty group, seeded with the creator as its first member so they can always read and re-encrypt it. Errors if the name is invalid or the group already exists.
- create_
vault - Create a new vault with a single recipient.
- decrypt_
meta - Decrypt the meta blob from a vault, returning the deserialized Meta if possible.
- decrypt_
value - Decrypt a base64-encoded ciphertext and return plaintext bytes.
- decrypt_
vault - Decrypt a vault using the given identity. Verifies integrity, decrypts all shared and scoped values, and returns the working state.
- decrypt_
vault_ values - Decrypt all shared secret values from a vault.
- delete_
group - Delete a group. Refuses if any secret is still assigned to it — the caller should reassign or remove those secrets first, so no data is silently orphaned (group ciphertext would become unreadable).
- describe_
key - Update a key’s plaintext schema metadata.
- diff_
secrets - Compare two sets of secret values and return the differences.
- discover_
existing_ key - Try to find an existing age key from the environment.
- dotenv_
has_ murk_ key - Check whether
.envalready contains aMURK_KEYline. - encrypt_
value - Encrypt a value and return base64-encoded ciphertext.
- enforce_
agent_ policy - Apply
check_agent_keyswhen the caller is a granted agent, or when the operator has opted into self-scope (crate::hardening::self_scope). - export_
secrets - Build shell-escaped export key-value pairs for
eval $(murk export). Wraps values in single quotes with embedded quote escaping. - format_
agent_ plan_ text - Format an
AgentPlanas plain text (no ANSI). Columns are aligned. - format_
diff_ lines - Format diff entries as display lines. Returns plain-text lines (no ANSI colors) suitable for testing.
- format_
info_ lines - Format vault info as plain-text lines (no ANSI colors).
has_metaindicates whether scoped/tag columns should be shown. - format_
recipient_ lines - Group recipient entries by display name and format for display. Returns plain-text lines (no ANSI colors).
- get_
secret - Look up a decrypted value. Resolution order, highest priority first: a personal scoped override, then a named-group value we can read, then the shared (everyone) value.
- import_
secrets - Import multiple secrets at once.
- is_
agent_ identity - True when
pubkeyidentifies a granted agent for this decrypted vault state. - is_
agent_ key_ allowed - Whether
keymay be read under the agent allow-tag policy: always true when the vault has no policy, otherwise true only if the key carries an allowed tag. The public, per-key form ofcheck_agent_keys, used by self-scope filtering (e.g.murk export). - is_
valid_ key_ name - Check whether a key name is a valid shell identifier (safe for
export KEY=...). Must start with a letter or underscore, and contain only[A-Za-z0-9_]. - key_
file_ path - Compute the key file path for a vault:
~/.config/murk/keys/<hash>. - key_
type_ label - Return the key type label for a pubkey string.
- last_
commit_ signature - Return the signature status of the last commit touching
path, orNonewhen git is unavailable, the repo has no such commit, or the path is untracked — i.e. there is no git anchor to check. - lifecycle_
segment - Build the at-a-glance lifecycle segment shown after each info row, e.g.
rotate 90d expires 2026-09-01. Returns an empty string when neither is set. The expiry is shown as a bare date (the stored time is end-of-day). Public schema, so this renders without a key — same as tags. - list_
keys - Return key names from the vault schema, optionally filtered by tags.
- list_
recipients - List all recipients in the vault with optional name resolution.
- load_
vault - Resolve the key from the environment, read the vault, and decrypt it.
- mark_
revoked - Mark
keysas owing a post-revoke rotation, stamping each withrevoked_at. - parse_
and_ decrypt_ values - Parse a vault from its JSON string and decrypt all shared values.
- parse_
env - Parse a .env file into key-value pairs.
Skips comments, blank lines,
MURK_*keys, and strips quotes andexportprefixes. - parse_
ttl - Parse a TTL like
90s,30m,2h, or7dinto aDuration. A bare number is rejected — the unit must be explicit so2is never ambiguous. - read_
vault - Read a vault file from disk.
- remove_
grant - Remove a grant by name, returning its metadata so the caller can revoke the agent recipient (which clears its private entries) and rotate the scope.
- remove_
member - Remove a member from a group. The operator must be a member. Refuses to remove the last member (the group’s secrets would become unreadable). Returns true if the member was removed (false if not present).
- remove_
secret - Remove a secret from the working state and schema.
- resolve_
key - Resolve the secret key, checking in order:
- resolve_
key_ for_ vault - Resolve the secret key for a specific vault.
- resolve_
key_ with_ source - Resolve the secret key and report where it came from.
- resolve_
member - Resolve a member spec (a pubkey or a display name) to a recipient pubkey. The result must be an authorized recipient of the vault.
- resolve_
secrets - Merge private overrides over shared values and filter by tag. Returns raw (unescaped) values suitable for env var injection.
- resolve_
vault_ path - Resolve a vault path argument, walking up parent directories to discover the vault.
- revoke_
recipient - Remove a recipient from the vault.
recipientcan be a pubkey or a display name. - rotation_
health - Evaluate per-key rotation hygiene against
now. - run_
merge_ driver - Run the three-way merge driver on vault contents (as strings).
- save_
vault - Save the vault: compare against original state and only re-encrypt changed values. Unchanged values keep their original ciphertext for minimal git diffs.
- setup_
merge_ driver - Configure git to use murk’s custom merge driver for
.murkfiles. - truncate_
pubkey - Truncate a pubkey for display, keeping start and end.
- validate_
grant_ name - Validate a grant name: 1–64 chars of
[A-Za-z0-9_-]. - validate_
group_ name - Validate a group name: 1–64 chars of
[A-Za-z0-9_-], not reserved. - vault_
info - Compute vault info from raw vault bytes.
- warn_
env_ permissions - Warn if
.envhas loose permissions (Unix only). - write_
envrc - Write a
.envrcfile for direnv integration. - write_
key_ ref_ to_ dotenv - Write a MURK_KEY_FILE reference to
.env, removing any existing MURK_KEY/MURK_KEY_FILE lines. - write_
key_ to_ dotenv - Write a MURK_KEY to
.env, removing any existing MURK_KEY lines. On Unix, sets file permissions to 600 atomically at creation time to prevent a TOCTOU window where the secret key is world-readable. On non-Unix platforms, permissions are not hardened. - write_
key_ to_ file - Write a secret key to a file with restricted permissions.