storage

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountExists        = errors.New("account exists")
	ErrAccountNotFound      = errors.New("account not found")
	ErrDIDExists            = errors.New("DID document exists")
	ErrDIDNotFound          = errors.New("DID document not found")
	ErrIdentityNotFound     = errors.New("identity not found")
	ErrLockerNotFound       = errors.New("locker not found")
	ErrAccessKeyNotFound    = errors.New("access key not found")
	ErrPropertyNotFound     = errors.New("property not found")
	ErrRecoveryCodeNotFound = errors.New("recovery code not found")
)

Functions

func Register

func Register(storageType string, ctor IdentityBackendConstructor)

Types

type AccountBackend

type AccountBackend interface {
	CreateAccount(ctx context.Context, acct *account.Account) error
	UpdateAccount(ctx context.Context, acct *account.Account) error
	GetAccount(ctx context.Context, id string) (*account.Account, error)
	DeleteAccount(ctx context.Context, id string) error
	ListAccounts(ctx context.Context, parentAccountID, stateFilter string) ([]*account.Account, error)

	HasAccountAccess(ctx context.Context, accountID, targetAccountID string) (bool, error)

	ListAccessKeys(ctx context.Context, accountID string) ([]*model.AccessKey, error)
	StoreAccessKey(ctx context.Context, accessKey *model.AccessKey) error
	GetAccessKey(ctx context.Context, keyID string) (*model.AccessKey, error)
	DeleteAccessKey(ctx context.Context, keyID string) error

	StoreIdentity(ctx context.Context, accountID string, idy *account.DataEnvelope) error
	GetIdentity(ctx context.Context, accountID string, hash string) (*account.DataEnvelope, error)
	ListIdentities(ctx context.Context, accountID string, lvl model.AccessLevel) ([]*account.DataEnvelope, error)

	StoreLocker(ctx context.Context, accountID string, l *account.DataEnvelope) error
	GetLocker(ctx context.Context, accountID string, hash string) (*account.DataEnvelope, error)
	ListLockers(ctx context.Context, accountID string, lvl model.AccessLevel) ([]*account.DataEnvelope, error)

	StoreProperty(ctx context.Context, accountID string, prop *account.DataEnvelope) error
	GetProperty(ctx context.Context, accountID string, hash string) (*account.DataEnvelope, error)
	ListProperties(ctx context.Context, accountID string, lvl model.AccessLevel) ([]*account.DataEnvelope, error)
	DeleteProperty(ctx context.Context, accountID string, hash string) error
}

type DIDBackend

type DIDBackend interface {
	CreateDIDDocument(ctx context.Context, ddoc *model.DIDDocument) error
	GetDIDDocument(ctx context.Context, iid string) (*model.DIDDocument, error)
	ListDIDDocuments(ctx context.Context) ([]*model.DIDDocument, error)
}

type IdentityBackend

type IdentityBackend interface {
	io.Closer
	DIDBackend
	AccountBackend
	RecoveryBackend
}

IdentityBackend stores MetaLocker accounts and related entities such as encrypted identities, lockers, access keys, properties, DID documents and recovery codes. This is the main node-specific storage layer.

func CreateIdentityBackend

func CreateIdentityBackend(cfg *IdentityBackendConfig, resolver cmdbase.ParameterResolver) (IdentityBackend, error)

type IdentityBackendConfig

type IdentityBackendConfig struct {
	Type   string     `json:"type"`
	Params Parameters `json:"params"`
}

type IdentityBackendConstructor

type IdentityBackendConstructor func(def Parameters, resolver cmdbase.ParameterResolver) (IdentityBackend, error)

type Parameters

type Parameters map[string]any

type RecoveryBackend

type RecoveryBackend interface {
	CreateRecoveryCode(ctx context.Context, c *account.RecoveryCode) error
	GetRecoveryCode(ctx context.Context, code string) (*account.RecoveryCode, error)
	DeleteRecoveryCode(ctx context.Context, code string) error
}

Jump to

Keyboard shortcuts

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