pub struct VaultDirectory { /* private fields */ }Expand description
Password-protected local vault file for native reVault metadata.
A VaultDirectory stores its data in local-vault.lbox under a private
directory. It can hold contact private keys, contact public keys,
and key-directory backups used by Vault recovery fallback paths.
Implementations§
Source§impl VaultDirectory
impl VaultDirectory
Sourcepub const DEFAULT_KEY_NAME: &'static str = "default"
pub const DEFAULT_KEY_NAME: &'static str = "default"
Default name used for the primary local contact key.
Sourcepub fn probe_structure_version(
root: impl AsRef<Path>,
password: &SecureString,
) -> Result<u32, Error>
pub fn probe_structure_version( root: impl AsRef<Path>, password: &SecureString, ) -> Result<u32, Error>
Reads the stable vault structure discriminator without interpreting
version-specific records. Migration orchestration uses this to choose a
historical exporter before opening the source through VaultDirectory.
Sourcepub fn open_or_create_default(
password: &SecureString,
) -> Result<VaultDirectory, Error>
pub fn open_or_create_default( password: &SecureString, ) -> Result<VaultDirectory, Error>
Opens or creates the default vault directory using password.
The directory is chosen by default_vault_dir.
Sourcepub fn replace_default(password: &SecureString) -> Result<VaultDirectory, Error>
pub fn replace_default(password: &SecureString) -> Result<VaultDirectory, Error>
Replaces the default vault directory using password.
The replacement is coordinated with the same interprocess lock used for vault backups and record writes.
Sourcepub fn change_default_password(
old_password: &SecureString,
new_password: &SecureString,
) -> Result<(), Error>
pub fn change_default_password( old_password: &SecureString, new_password: &SecureString, ) -> Result<(), Error>
Changes the pass phrase for the default vault directory.
Sourcepub fn change_password(
root: impl AsRef<Path>,
old_password: &SecureString,
new_password: &SecureString,
) -> Result<(), Error>
pub fn change_password( root: impl AsRef<Path>, old_password: &SecureString, new_password: &SecureString, ) -> Result<(), Error>
Changes the pass phrase for a vault directory.
Sourcepub fn replace(
root: impl AsRef<Path>,
password: &SecureString,
) -> Result<VaultDirectory, Error>
pub fn replace( root: impl AsRef<Path>, password: &SecureString, ) -> Result<VaultDirectory, Error>
Replaces the vault directory at root using password.
Sourcepub fn open_or_create(
root: impl AsRef<Path>,
password: &SecureString,
) -> Result<VaultDirectory, Error>
pub fn open_or_create( root: impl AsRef<Path>, password: &SecureString, ) -> Result<VaultDirectory, Error>
Opens or creates a vault directory at root.
The vault file is protected with password. When a new vault file is
created, private file permissions are applied on supported platforms.
Sourcepub fn structure_version(&self) -> Result<u32, Error>
pub fn structure_version(&self) -> Result<u32, Error>
Returns the structure version recorded inside this vault.
Sourcepub fn store_private_key(
&self,
name: &str,
keypair: &ContactKeyPair,
) -> Result<(), Error>
pub fn store_private_key( &self, name: &str, keypair: &ContactKeyPair, ) -> Result<(), Error>
Stores a contact private key under name.
Names must contain only ASCII letters, digits, -, or _.
Sourcepub fn restore_private_key(
&self,
name: &str,
keypair: &ContactKeyPair,
signing_key: Option<&OwnerSigningKeyPair>,
overwrite: bool,
) -> Result<(), Error>
pub fn restore_private_key( &self, name: &str, keypair: &ContactKeyPair, signing_key: Option<&OwnerSigningKeyPair>, overwrite: bool, ) -> Result<(), Error>
Restores a profile private key and optional owner signing key.
When overwrite is true, any existing profile with the same name is
removed first so current keys, signing keys, and generation history stay
consistent with the restored material.
Sourcepub fn load_private_key(&self, name: &str) -> Result<ContactKeyPair, Error>
pub fn load_private_key(&self, name: &str) -> Result<ContactKeyPair, Error>
Loads a contact private key previously stored under name.
Sourcepub fn load_owner_signing_key(
&self,
name: &str,
) -> Result<OwnerSigningKeyPair, Error>
pub fn load_owner_signing_key( &self, name: &str, ) -> Result<OwnerSigningKeyPair, Error>
Loads the owner signing key associated with a vault profile.
Older vault profiles did not have a separate signing key. The first load lazily creates one so future lockbox commits can be signed without deriving signing material from the lockbox content key.
Sourcepub fn load_owner_signing_key_cached(
&self,
name: &str,
) -> Result<OwnerSigningKeyPair, Error>
pub fn load_owner_signing_key_cached( &self, name: &str, ) -> Result<OwnerSigningKeyPair, Error>
Loads one owner-signing key using the enabled session-agent cache when available, then refreshes that cache after the normal vault load.
Sourcepub fn private_key_exists(&self, name: &str) -> Result<bool, Error>
pub fn private_key_exists(&self, name: &str) -> Result<bool, Error>
Returns whether a private key exists under name.
Sourcepub fn list_private_keys(&self) -> Result<Vec<String>, Error>
pub fn list_private_keys(&self) -> Result<Vec<String>, Error>
Lists private-key names stored in this vault.
Sourcepub fn delete_private_key(&self, name: &str) -> Result<(), Error>
pub fn delete_private_key(&self, name: &str) -> Result<(), Error>
Deletes the private key stored under name, if present.
Sourcepub fn store_profile_email(&self, name: &str, email: &str) -> Result<(), Error>
pub fn store_profile_email(&self, name: &str, email: &str) -> Result<(), Error>
Stores the public email address associated with a vault profile.
Sourcepub fn profile_email(&self, name: &str) -> Result<Option<String>, Error>
pub fn profile_email(&self, name: &str) -> Result<Option<String>, Error>
Loads the public email address associated with a vault profile.
Sourcepub fn list_profile_generations(
&self,
name: &str,
) -> Result<ProfileHistory, Error>
pub fn list_profile_generations( &self, name: &str, ) -> Result<ProfileHistory, Error>
Lists profile generations for a private key, creating generation one for existing pre-history profiles.
Sourcepub fn rotate_private_key(&self, name: &str) -> Result<ProfileHistory, Error>
pub fn rotate_private_key(&self, name: &str) -> Result<ProfileHistory, Error>
Rotates a vault profile to a new active key generation.
Sourcepub fn load_private_key_generation(
&self,
name: &str,
index: u16,
) -> Result<ContactKeyPair, Error>
pub fn load_private_key_generation( &self, name: &str, index: u16, ) -> Result<ContactKeyPair, Error>
Loads one profile generation by index.
Sourcepub fn load_owner_signing_key_generation(
&self,
name: &str,
index: u16,
) -> Result<OwnerSigningKeyPair, Error>
pub fn load_owner_signing_key_generation( &self, name: &str, index: u16, ) -> Result<OwnerSigningKeyPair, Error>
Loads one owner signing-key generation by index.
Sourcepub fn store_contact(
&self,
name: &str,
key: &ContactPublicKey,
) -> Result<(), Error>
pub fn store_contact( &self, name: &str, key: &ContactPublicKey, ) -> Result<(), Error>
Stores a contact public key under name.
Names must contain only ASCII letters, digits, -, or _.
Sourcepub fn store_contact_signing_key(
&self,
name: &str,
key: &OwnerSigningPublicKey,
) -> Result<(), Error>
pub fn store_contact_signing_key( &self, name: &str, key: &OwnerSigningPublicKey, ) -> Result<(), Error>
Stores the contact signing public key associated with a contact.
Sourcepub fn load_contact(&self, name: &str) -> Result<ContactPublicKey, Error>
pub fn load_contact(&self, name: &str) -> Result<ContactPublicKey, Error>
Loads a contact public key by name.
Sourcepub fn load_contact_signing_key(
&self,
name: &str,
) -> Result<OwnerSigningPublicKey, Error>
pub fn load_contact_signing_key( &self, name: &str, ) -> Result<OwnerSigningPublicKey, Error>
Loads the contact signing public key associated with a contact.
Sourcepub fn contact_exists(&self, name: &str) -> Result<bool, Error>
pub fn contact_exists(&self, name: &str) -> Result<bool, Error>
Returns whether a contact exists under name.
Sourcepub fn delete_contact(&self, name: &str) -> Result<(), Error>
pub fn delete_contact(&self, name: &str) -> Result<(), Error>
Deletes the contact stored under name, if present.
Sourcepub fn list_contacts(&self) -> Result<Vec<StoredContact>, Error>
pub fn list_contacts(&self) -> Result<Vec<StoredContact>, Error>
Lists contacts stored in this vault.
Sourcepub fn store_key_directory_backup(
&self,
lockbox_id: LockboxId,
key_directory: &[u8],
) -> Result<(), Error>
pub fn store_key_directory_backup( &self, lockbox_id: LockboxId, key_directory: &[u8], ) -> Result<(), Error>
Stores an exported key-directory backup for lockbox_id.
Backups can be used by Vault to recover openability when the
embedded key directory in a lockbox file is damaged.
Sourcepub fn load_key_directory_backup(
&self,
lockbox_id: LockboxId,
) -> Result<Vec<u8>, Error>
pub fn load_key_directory_backup( &self, lockbox_id: LockboxId, ) -> Result<Vec<u8>, Error>
Loads the key-directory backup for lockbox_id.
Sourcepub fn key_directory_backup_count(&self) -> Result<usize, Error>
pub fn key_directory_backup_count(&self) -> Result<usize, Error>
Counts key-directory backups stored in this vault.
Sourcepub fn remember_known_lockbox(
&self,
lockbox_id: LockboxId,
path: impl AsRef<Path>,
) -> Result<(), Error>
pub fn remember_known_lockbox( &self, lockbox_id: LockboxId, path: impl AsRef<Path>, ) -> Result<(), Error>
Remembers a lockbox path for diagnostics and future bulk access refresh.
Sourcepub fn list_known_lockboxes(&self) -> Result<Vec<KnownLockbox>, Error>
pub fn list_known_lockboxes(&self) -> Result<Vec<KnownLockbox>, Error>
Lists lockboxes remembered by the local vault.
Sourcepub fn forget_known_lockbox(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn forget_known_lockbox(&self, path: impl AsRef<Path>) -> Result<(), Error>
Removes one remembered lockbox path. The lockbox file itself is not deleted or modified.
Sourcepub fn remember_access_slot_label(
&self,
lockbox_id: LockboxId,
slot_id: u64,
name: impl Into<String>,
) -> Result<(), Error>
pub fn remember_access_slot_label( &self, lockbox_id: LockboxId, slot_id: u64, name: impl Into<String>, ) -> Result<(), Error>
Remember a local name for one lockbox access slot.
This mapping is stored only inside the encrypted local vault. It is not written to the shared lockbox, so it does not disclose contacts to third parties who inspect the lockbox file.
Sourcepub fn list_access_slot_labels(
&self,
lockbox_id: LockboxId,
) -> Result<Vec<AccessSlotLabel>, Error>
pub fn list_access_slot_labels( &self, lockbox_id: LockboxId, ) -> Result<Vec<AccessSlotLabel>, Error>
Lists local access-slot labels remembered for one lockbox.
Sourcepub fn find_access_slot_labels(
&self,
lockbox_id: LockboxId,
name: &str,
) -> Result<Vec<AccessSlotLabel>, Error>
pub fn find_access_slot_labels( &self, lockbox_id: LockboxId, name: &str, ) -> Result<Vec<AccessSlotLabel>, Error>
Finds local slot labels for name in one lockbox.
Sourcepub fn forget_access_slot_label(
&self,
lockbox_id: LockboxId,
slot_id: u64,
) -> Result<(), Error>
pub fn forget_access_slot_label( &self, lockbox_id: LockboxId, slot_id: u64, ) -> Result<(), Error>
Forget one local access-slot label.
Sourcepub fn define_form(
&self,
alias: &str,
name: &str,
fields: Vec<FormFieldDefinition>,
) -> Result<FormDefinition, Error>
pub fn define_form( &self, alias: &str, name: &str, fields: Vec<FormFieldDefinition>, ) -> Result<FormDefinition, Error>
Creates or revises a reusable form definition stored in the vault.
Sourcepub fn define_form_with_description(
&self,
alias: &str,
name: &str,
description: &str,
fields: Vec<FormFieldDefinition>,
) -> Result<FormDefinition, Error>
pub fn define_form_with_description( &self, alias: &str, name: &str, description: &str, fields: Vec<FormFieldDefinition>, ) -> Result<FormDefinition, Error>
Creates or revises a reusable form definition stored in the vault.
Sourcepub fn define_form_with_type_id(
&self,
type_id: FormTypeId,
alias: &str,
name: &str,
fields: Vec<FormFieldDefinition>,
) -> Result<FormDefinition, Error>
pub fn define_form_with_type_id( &self, type_id: FormTypeId, alias: &str, name: &str, fields: Vec<FormFieldDefinition>, ) -> Result<FormDefinition, Error>
Creates or revises a reusable form definition with a stable definition id.
Sourcepub fn define_form_with_type_id_and_description(
&self,
type_id: FormTypeId,
alias: &str,
name: &str,
description: &str,
fields: Vec<FormFieldDefinition>,
) -> Result<FormDefinition, Error>
pub fn define_form_with_type_id_and_description( &self, type_id: FormTypeId, alias: &str, name: &str, description: &str, fields: Vec<FormFieldDefinition>, ) -> Result<FormDefinition, Error>
Creates or revises a reusable form definition with a stable definition id.
Sourcepub fn import_form_definition(
&self,
definition: FormDefinition,
) -> Result<FormDefinition, Error>
pub fn import_form_definition( &self, definition: FormDefinition, ) -> Result<FormDefinition, Error>
Imports an exact reusable form definition into the vault.
Sourcepub fn resolve_form_definition(
&self,
reference: &str,
) -> Result<FormDefinition, Error>
pub fn resolve_form_definition( &self, reference: &str, ) -> Result<FormDefinition, Error>
Resolves a reusable vault form definition by alias or definition id.
Sourcepub fn list_form_definitions(&self) -> Result<Vec<FormDefinition>, Error>
pub fn list_form_definitions(&self) -> Result<Vec<FormDefinition>, Error>
Lists reusable form definitions stored in the vault.
Sourcepub fn list_form_definition_revisions(
&self,
type_id: &FormTypeId,
) -> Result<Vec<FormDefinition>, Error>
pub fn list_form_definition_revisions( &self, type_id: &FormTypeId, ) -> Result<Vec<FormDefinition>, Error>
Lists every stored revision of one reusable form definition.
Sourcepub fn seed_default_form_definitions(&self) -> Result<usize, Error>
pub fn seed_default_form_definitions(&self) -> Result<usize, Error>
Adds built-in form definitions that are not already present.
Sourcepub fn remember_lockbox_password(
&self,
lockbox_id: LockboxId,
password: &SecureString,
) -> Result<(), Error>
pub fn remember_lockbox_password( &self, lockbox_id: LockboxId, password: &SecureString, ) -> Result<(), Error>
Stores a lockbox pass phrase in the vault, keyed by lockbox id.
Sourcepub fn remembered_lockbox_password(
&self,
lockbox_id: LockboxId,
) -> Result<Option<SecureString>, Error>
pub fn remembered_lockbox_password( &self, lockbox_id: LockboxId, ) -> Result<Option<SecureString>, Error>
Loads a remembered lockbox pass phrase, if one exists for this lockbox id.