model

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = db.NewVersion(0, 0, 5, 0)

Version is incremented whenever a bucket format is changed.

Functions

func With

func With(db db.DB, fn func(db *Model) error) error

Types

type Accounts

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

func (*Accounts) Book

func (c *Accounts) Book(url *url.URL) *AccountsBook

func (*Accounts) Books

func (c *Accounts) Books() values.Set[*url.URL]

func (*Accounts) Commit

func (c *Accounts) Commit() error

func (*Accounts) IsDirty

func (c *Accounts) IsDirty() bool

func (*Accounts) Key

func (c *Accounts) Key() *record.Key

func (*Accounts) Resolve

func (c *Accounts) Resolve(key *record.Key) (record.Record, *record.Key, error)

func (*Accounts) Tokens

func (c *Accounts) Tokens() values.Set[*url.URL]

func (*Accounts) Walk

func (c *Accounts) Walk(opts record.WalkOptions, fn record.WalkFunc) error

type AccountsBook

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

func (*AccountsBook) Commit

func (c *AccountsBook) Commit() error

func (*AccountsBook) IsDirty

func (c *AccountsBook) IsDirty() bool

func (*AccountsBook) Key

func (c *AccountsBook) Key() *record.Key

func (*AccountsBook) Pages

func (c *AccountsBook) Pages() values.List[*protocol.KeyPage]

func (*AccountsBook) Resolve

func (c *AccountsBook) Resolve(key *record.Key) (record.Record, *record.Key, error)

func (*AccountsBook) Walk

func (c *AccountsBook) Walk(opts record.WalkOptions, fn record.WalkFunc) error

type Address

type Address struct {
	Labels     []string               `json:"labels,omitempty" form:"labels" query:"labels" validate:"required"`
	Type       protocol.SignatureType `json:"type,omitempty" form:"type" query:"type" validate:"required"`
	Derivation string                 `json:"derivation,omitempty" form:"derivation" query:"derivation" validate:"required"`
	WalletId   *url.URL               `json:"walletId,omitempty" form:"walletId" query:"walletId" validate:"required"`
	PublicKey  []byte                 `json:"publicKey,omitempty" form:"publicKey" query:"publicKey" validate:"required"`
	LastUsedOn uint64                 `json:"lastUsedOn,omitempty" form:"lastUsedOn" query:"lastUsedOn" validate:"required"`
	// contains filtered or unexported fields
}

func (*Address) AddLabel

func (a *Address) AddLabel(s string)

func (*Address) Copy

func (v *Address) Copy() *Address

func (*Address) CopyAsInterface

func (v *Address) CopyAsInterface() interface{}

func (*Address) Equal

func (v *Address) Equal(u *Address) bool

func (*Address) Hash

func (a *Address) Hash() []byte

func (*Address) IsValid

func (v *Address) IsValid() error

func (*Address) LiteIdentity

func (a *Address) LiteIdentity() *url.URL

func (*Address) MarshalBinary

func (v *Address) MarshalBinary() ([]byte, error)

func (*Address) MarshalJSON

func (v *Address) MarshalJSON() ([]byte, error)

func (*Address) RemoveLabel

func (a *Address) RemoveLabel(s string)

func (*Address) UnmarshalBinary

func (v *Address) UnmarshalBinary(data []byte) error

func (*Address) UnmarshalBinaryFrom

func (v *Address) UnmarshalBinaryFrom(rd io.Reader) error

func (*Address) UnmarshalJSON

func (v *Address) UnmarshalJSON(b []byte) error

type Config

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

func (*Config) Commit

func (c *Config) Commit() error

func (*Config) IsDirty

func (c *Config) IsDirty() bool

func (*Config) Key

func (c *Config) Key() *record.Key

func (*Config) Magic added in v0.6.0

func (c *Config) Magic() magicValue

func (*Config) Resolve

func (c *Config) Resolve(key *record.Key) (record.Record, *record.Key, error)

func (*Config) Salt added in v0.6.0

func (c *Config) Salt() values.Value[[]byte]

func (*Config) Version

func (c *Config) Version() values.Value[[]byte]

func (*Config) Walk

func (c *Config) Walk(opts record.WalkOptions, fn record.WalkFunc) error

type Enclave

type Enclave struct {
	memguard.Enclave
}

func NewEnclave

func NewEnclave(b []byte, preserve bool) *Enclave

func (*Enclave) CopyAsInterface

func (e *Enclave) CopyAsInterface() any

CopyAsInterface does nothing as Enclave is immutable so there's no need to copy.

func (*Enclave) Equal

func (e *Enclave) Equal(f *Enclave) bool

Equal returns true if the two enclaves are reference-equal.

func (*Enclave) MarshalBinary

func (e *Enclave) MarshalBinary() ([]byte, error)

func (*Enclave) MarshalJSON

func (e *Enclave) MarshalJSON() ([]byte, error)

func (*Enclave) UnmarshalBinary

func (e *Enclave) UnmarshalBinary(b []byte) error

func (*Enclave) UnmarshalBinaryFrom

func (e *Enclave) UnmarshalBinaryFrom(rd io.Reader) error

func (*Enclave) UnmarshalJSON

func (e *Enclave) UnmarshalJSON(b []byte) error

type Lookup

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

func (*Lookup) ByLabel

func (c *Lookup) ByLabel(value string) values.Value[*url.URL]

func (*Lookup) ByPublicKey

func (c *Lookup) ByPublicKey(value string) values.Value[*url.URL]

func (*Lookup) Commit

func (c *Lookup) Commit() error

func (*Lookup) IsDirty

func (c *Lookup) IsDirty() bool

func (*Lookup) Key

func (c *Lookup) Key() *record.Key

func (*Lookup) Resolve

func (c *Lookup) Resolve(key *record.Key) (record.Record, *record.Key, error)

func (*Lookup) Walk

func (c *Lookup) Walk(opts record.WalkOptions, fn record.WalkFunc) error

type Model

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

func New

func New(db db.DB) *Model

func NewEncrypted added in v0.6.0

func NewEncrypted(db db.DB, key *memguard.Enclave) *Model

func (*Model) Accounts

func (c *Model) Accounts() *Accounts

func (*Model) Address

func (c *Model) Address(lite *url.URL) values.Value[*Address]

func (*Model) AddressByHash

func (m *Model) AddressByHash(hash []byte) values.Value[*Address]

func (*Model) AddressByLabel

func (m *Model) AddressByLabel(label string) values.Value[*Address]

func (*Model) AddressByPublicKey

func (m *Model) AddressByPublicKey(pubKey []byte) values.Value[*Address]

func (*Model) Addresses

func (m *Model) Addresses() []values.Value[*Address]

func (*Model) AsEncrypted added in v0.6.0

func (m *Model) AsEncrypted(key *memguard.Enclave) *Model

AsEncrypted returns a new model using the given key for encryption.

func (*Model) Commit

func (c *Model) Commit() error

func (*Model) Config

func (c *Model) Config() *Config

func (*Model) Decrypt added in v0.6.0

func (m *Model) Decrypt(key *memguard.Enclave) (*Model, error)

Decrypt calls AsEncrypted and verifies the magic.

func (*Model) IsDirty

func (c *Model) IsDirty() bool

func (*Model) Key

func (c *Model) Key() *record.Key

func (*Model) Multi

func (c *Model) Multi() *Multi

func (*Model) PrivateKey

func (m *Model) PrivateKey(lite *url.URL) *PrivateKey

func (*Model) Resolve

func (c *Model) Resolve(key *record.Key) (record.Record, *record.Key, error)

func (*Model) Unwrap

func (m *Model) Unwrap() db.DB

func (*Model) Walk

func (c *Model) Walk(opts record.WalkOptions, fn record.WalkFunc) error

type Multi

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

func (*Multi) Commit

func (c *Multi) Commit() error

func (*Multi) Enabled

func (c *Multi) Enabled() values.Value[bool]

func (*Multi) IsDirty

func (c *Multi) IsDirty() bool

func (*Multi) Key

func (c *Multi) Key() *record.Key

func (*Multi) Names

func (c *Multi) Names() values.Set[string]

func (*Multi) Resolve

func (c *Multi) Resolve(key *record.Key) (record.Record, *record.Key, error)

func (*Multi) Salt

func (c *Multi) Salt() values.Value[[32]byte]

func (*Multi) Vault

func (c *Multi) Vault(name string) values.Value[*api.VaultInfo]

func (*Multi) Walk

func (c *Multi) Walk(opts record.WalkOptions, fn record.WalkFunc) error

type PrivateKey

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

func (*PrivateKey) Get

func (p *PrivateKey) Get() (*memguard.LockedBuffer, error)

Get loads the contents of the enclave as a locked buffer. The buffer must be destroyed once it is no longer needed.

func (*PrivateKey) GetAs

func (p *PrivateKey) GetAs(target any) error

func (*PrivateKey) GetCopy

func (p *PrivateKey) GetCopy() ([]byte, error)

GetCopy loads, unlocks, and copies the contents of the enclave. The value must be wiped once it is no longer needed. GetCopy *does not* guarantee constant-time.

func (*PrivateKey) Put

func (p *PrivateKey) Put(b []byte) error

Put creates an enclave with the buffer and stores it. The original buffer is wiped.

func (*PrivateKey) PutCopy

func (p *PrivateKey) PutCopy(b []byte) error

PutCopy creates an enclave with a copy of the buffer and stores it. The original buffer is not modified.

func (*PrivateKey) PutLocked

func (p *PrivateKey) PutLocked(b *memguard.LockedBuffer) error

PutLocked creates an enclave from the locked buffer and stores it. The buffer is wiped and destroyed.

Jump to

Keyboard shortcuts

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