vault

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 44 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const VaultKeychainService = "Icebath Agent vault key"

Keychain service every vault key entry is filed under

Variables

View Source
var AddressFields = jsonutil.ObjectOf("address_line1", "address-line1", "address_line2", "address-line2", "city", "address-level2",
	"state", "address-level1", "postal_code", "postal-code", "country", "country-name")

Address payload names mapped to the WHATWG autocomplete token the fill targets

View Source
var LoginIdentifierTypes = []string{"email", "phone", "username"}
View Source
var PaymentFields = jsonutil.ObjectOf("card_number", "cc-number", "cardholder_name", "cc-name", "exp_month", "cc-exp-month",
	"exp_year", "cc-exp-year", "cvc", "cc-csc", "billing_postal_code", "postal-code")

Payment payload names mapped to the WHATWG autocomplete token the fill targets

View Source
var VaultKinds = []string{"login", "payment", "address"}

Functions

func ConfiguredKeyStorage

func ConfiguredKeyStorage(ctx context.Context, h string) string

ConfiguredKeyStorage is the vault.key_storage setting of a home, file when unset

func KeychainBackendLabel

func KeychainBackendLabel() string

Human name of the keychain this process would use, for the vault key command

func NormalizeOTPSecret

func NormalizeOTPSecret(value string) (string, error)

Canonical stored seed of a base32 secret or otpauth totp URI, non default parameters appended

func NormalizeOrigin

func NormalizeOrigin(urlOrOrigin string) (string, error)

Scheme, host and non default port of a URL or origin, a VaultError without scheme and host

func RequiredFields

func RequiredFields(kind string) []string

RequiredFields lists the fields a payment or address item must carry

func ScrubSecretFromText

func ScrubSecretFromText(text string, secret *jsonutil.Object) string

Strips every secret value of at least three characters and password echoes from text

func TOTPAt

func TOTPAt(seed string, digits, period int, at float64) (string, error)

RFC 6238 code for a stored seed at a unix time, the seed form NormalizeOTPSecret produces

func TOTPNow

func TOTPNow(seed string) (string, error)

RFC 6238 code for a stored seed now

func VaultDeleteKeyRef

func VaultDeleteKeyRef(ref map[string]any) bool

Deletes the entry a plain map pointer names, true once it is gone

Types

type KeychainUnavailable

type KeychainUnavailable struct{ Msg string }

No OS keychain is reachable from this process, headless or a plaintext backend

func (*KeychainUnavailable) Error

func (e *KeychainUnavailable) Error() string

type MemoryKeyring

type MemoryKeyring struct {
	// contains filtered or unexported fields
}

MemoryKeyring is an in memory OS keychain stand in for tests of the packages that drive the vault

func UseMemoryKeyring

func UseMemoryKeyring() (*MemoryKeyring, func())

UseMemoryKeyring installs an in memory keyring as the host keychain, the returned func restores the native one

func (*MemoryKeyring) Count

func (k *MemoryKeyring) Count() int

Count is how many entries the keyring holds

func (*MemoryKeyring) DeletePassword

func (k *MemoryKeyring) DeletePassword(service, account string) error

func (*MemoryKeyring) GetPassword

func (k *MemoryKeyring) GetPassword(service, account string) (string, bool, error)

func (*MemoryKeyring) SetPassword

func (k *MemoryKeyring) SetPassword(service, account, password string) error

type VaultError

type VaultError struct{ Msg string }

Vault failure that is safe to surface, never carrying a secret value

func (*VaultError) Error

func (e *VaultError) Error() string

type VaultItemMeta

type VaultItemMeta struct {
	ID             string
	Kind           string
	Label          string
	Origin         any
	CreatedAt      string
	IdentifierType any
	Identifier     any
	HasOTP         bool
	AllowedOrigins []string
}

Metadata only view of a vault item, never a secret value

func (VaultItemMeta) ToDict

func (m VaultItemMeta) ToDict() *jsonutil.Object

type VaultStore

type VaultStore struct {
	// contains filtered or unexported fields
}

Encrypted profile scoped vault under the home's vault directory

func GetVaultStore

func GetVaultStore(ctx context.Context) *VaultStore

Default store of the home in effect for ctx

func NewVaultStore

func NewVaultStore(ctx context.Context, baseDir string) *VaultStore

Store at baseDir, empty meaning the vault directory of the home in effect for ctx

func (*VaultStore) AddItem

func (s *VaultStore) AddItem(kind, label string, secret *jsonutil.Object, origin string) (VaultItemMeta, error)

Adds an item, a login keeping its identifier in metadata and only the password and seed secret

func (*VaultStore) EncryptVaultBody

func (s *VaultStore) EncryptVaultBody(plaintext []byte) error

EncryptVaultBody writes plaintext as this store's encrypted vault file, the way a test corrupts a store

func (*VaultStore) GetMeta

func (s *VaultStore) GetMeta(itemID string) (*VaultItemMeta, error)

func (*VaultStore) KeyLocation

func (s *VaultStore) KeyLocation() (*jsonutil.Object, error)

Where this vault's key lives, never the key itself

func (*VaultStore) ListItems

func (s *VaultStore) ListItems() ([]VaultItemMeta, error)

Metadata only listing, secret payloads never included

func (*VaultStore) MigrateKey

func (s *VaultStore) MigrateKey(target string) (string, error)

Moves the key between the file and the OS keychain, proving the destination before removing the source

func (*VaultStore) OwnCopiedKey

func (s *VaultStore) OwnCopiedKey(publishedBase string) (*jsonutil.Object, error)

Gives a cloned vault its own keychain entry before publication at publishedBase, nil when nothing is shared

func (*VaultStore) RemoveItem

func (s *VaultStore) RemoveItem(itemID string) (bool, error)

func (*VaultStore) ResolveSecret

func (s *VaultStore) ResolveSecret(itemID string) (*jsonutil.Object, error)

Decrypted secret payload for server side use only, never for results, logs or errors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL