glm_vault/vault

Types

A vault is an opaque datatype that contains the secrets.

pub opaque type Vault

Vault Errors

pub type VaultError {
  UnableToSerializeUnsupportedType(tom.Toml)
  UnableToGetFromVault(tom.GetError)
  UnableToDecryptFile(openssl.OpenSslError, String, String)
  UnableToEncryptFile(simplifile.FileError)
  UnableToGetFromDict(String)
  UnableToParseDecryptedPlaintext(String, tom.ParseError)
}

Constructors

Values

pub fn decrypt(
  encrypted_file: String,
  password_file: String,
) -> Result(Vault, VaultError)

Decrypt an encrypted file and return a vault instance.

pub const default_dummy_bool: Bool
pub const default_dummy_float: Float
pub const default_dummy_int: Int
pub const default_dummy_string: String
pub fn encrypt(
  vault: Vault,
  encrypted_file: String,
  password_file: String,
) -> Result(Nil, VaultError)

Serialize a vault instance to a temporary file, then encrypt that file and delete the temporary file. Upon success, an encrypted file is created that contains the serialized contents of the vault.

pub fn get_bool(
  v: Vault,
  key: String,
) -> Result(Bool, VaultError)
pub fn get_float(
  v: Vault,
  key: String,
) -> Result(Float, VaultError)
pub fn get_int(v: Vault, key: String) -> Result(Int, VaultError)
pub fn get_keys(v: Vault) -> Result(List(String), VaultError)
pub fn get_string(
  v: Vault,
  key: String,
) -> Result(String, VaultError)
pub fn new_dummy_vault() -> Vault

Create a new dummy vault. This vault has no secrets, silently allows values to be set (but does not actually set them, as it has no secrets), and returns default values for all get operations, see ‘default_dummy_*’ above.

pub fn new_elided_vault(
  secrets: dict.Dict(String, tom.Toml),
) -> Vault

Create an elided vault, one that does not reveal it’s secrets. The Elided vault can have secrets set, and will behave like a regular vault in all ways EXCEPT that get operations will allways return a default value, see ‘default_dummy_*’ above.

This means that if you try to access a key that does not exist in an elided vault, you will get an access error.

pub fn new_vault(secrets: dict.Dict(String, tom.Toml)) -> Vault

Create a new vault.

pub fn set_bool(v: Vault, key: String, value: Bool) -> Vault
pub fn set_float(v: Vault, key: String, value: Float) -> Vault
pub fn set_int(v: Vault, key: String, value: Int) -> Vault
pub fn set_string(v: Vault, key: String, value: String) -> Vault
pub fn to_elided_vault(v: Vault) -> Vault

Convert a vault to an elided vault. Useful for code that sometimes needs a regular vault, but sometimes needs to cast to an elided vault.

✨ Search Document