wallet

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountUpdateType = "AccountUpdate"

	MetaLeaseDurationYears = 100
)

Variables

View Source
var (
	ErrRecordNotFoundInRootIndex = errors.New("record not found in root index")
	ErrSenderNotFound            = errors.New("sender not found")
	ErrRecipientNotFound         = errors.New("recipient not found")
	ErrLeaseRevokedAndPurged     = errors.New("lease revoked and purged")
)
View Source
var (
	ErrInsufficientLockLevel = errors.New("insufficient wallet lock level")
	ErrWalletLocked          = errors.New("data wallet is locked")
)
View Source
var (
	ErrForbiddenOperation = errors.New("forbidden operation with restricted wallet")
)

Functions

func ForceSyncRootIndex

func ForceSyncRootIndex(dw DataWallet) error

func SaveNewAccount

func SaveNewAccount(resp *account.GenerationResponse, nodeClient NodeClient, registrationCode string, hashFunction account.PasswordHashFunction) error

Types

type AccountBackend

type AccountBackend interface {
	CreateAccount(account *account.Account, registrationCode string) error
	GetOwnAccount() (*account.Account, error)

	GetAccount(id string) (*account.Account, error)
	UpdateAccount(account *account.Account) error
	PatchAccount(email, oldEncryptedPassword, newEncryptedPassword, name, givenName, familyName string) error
	DeleteAccount(id string) error

	CreateSubAccount(account *account.Account) (*account.Account, error)
	ListSubAccounts(id string) ([]*account.Account, error)

	CreateAccessKey(key *model.AccessKey) (*model.AccessKey, error)
	GetAccessKey(keyID string) (*model.AccessKey, error)
	DeleteAccessKey(keyID string) error
	ListAccessKeys() ([]*model.AccessKey, error)

	StoreIdentity(idy *account.DataEnvelope) error
	GetIdentity(hash string) (*account.DataEnvelope, error)
	ListIdentities() ([]*account.DataEnvelope, error)

	StoreLocker(l *account.DataEnvelope) error
	GetLocker(hash string) (*account.DataEnvelope, error)
	ListLockers() ([]*account.DataEnvelope, error)
	ListLockerHashes() ([]string, error)

	StoreProperty(prop *account.DataEnvelope) error
	GetProperty(hash string) (*account.DataEnvelope, error)
	ListProperties() ([]*account.DataEnvelope, error)
	DeleteProperty(hash string) error
}

type AccountUpdate

type AccountUpdate struct {
	Type        string            `json:"type"`
	AccountID   string            `json:"a"`
	AccessLevel model.AccessLevel `json:"lvl"`

	IdentitiesAdded   []string `json:"ida,omitempty"`
	IdentitiesRemoved []string `json:"idr,omitempty"`

	LockersOpened []string `json:"lop,omitempty"`
	LockersClosed []string `json:"lcl,omitempty"`

	SubAccountsAdded   []string `json:"saa,omitempty"`
	SubAccountsRemoved []string `json:"sar,omitempty"`

	IndexesAdded   []string `json:"ixa,omitempty"`
	IndexesRemoved []string `json:"ixr,omitempty"`
}

type AccountUpdateMessage

type AccountUpdateMessage struct {
	Type   string `json:"type"`
	UserID string `json:"id"`
}

type DataSetStoreConstructor

type DataSetStoreConstructor func(dataWallet DataWallet, services Services) (DataStore, error)

type DataStore

type DataStore interface {
	// NewDataSetBuilder returns an instance of dataset.Builder that enables interactive construction
	// of a dataset.
	NewDataSetBuilder(lockerID string, opts ...dataset.BuilderOption) (dataset.Builder, error)
	// Load returns an interface to interact with the dataset behind the given record ID.
	Load(id string, opts ...dataset.LoadOption) (model.DataSet, error)
	// Revoke revokes for the lease for the dataset behind the given record ID.
	Revoke(id string) dataset.RecordFuture

	// AssetHead returns the dataset that is a head with the given ID.
	AssetHead(headID string, opts ...dataset.LoadOption) (model.DataSet, error)
	// SetAssetHead sets the record with the given ID as a head for the dataset with the given asset ID,
	// name and for the given locker.
	SetAssetHead(assetID string, locker *model.Locker, headName string, recordID string) dataset.RecordFuture

	// Share shares the dataset from the record with the given id (we assume the account has access
	// to this record) through the locker.
	Share(ds model.DataSet, locker Locker, vaultName string, expiryTime time.Time) dataset.RecordFuture

	// PurgeDataAssets purges all data assets (resources) for the given revoked lease.
	PurgeDataAssets(recordID string) error
}

DataStore is a direct interface to dataset management operations for the enclosing data wallet.

type DataWallet

type DataWallet interface {
	io.Closer

	// ID returns the account ID.
	ID() string
	// Account returns the full account definition.
	Account() *account.Account
	// ChangePassphrase updates the passphrase for the account. If isHash is true,
	// the provided passphrase is a double SHA256 of the passphrase, not the cleartext
	// passphrase.
	ChangePassphrase(oldPassphrase, newPassphrase string, isHash bool) (DataWallet, error)
	// ChangeEmail changes the email of the account.
	ChangeEmail(email string) error
	// Recover enables account recovery, in the passphrase has been lost.
	Recover(cryptoKey *model.AESKey, newPassphrase string) (DataWallet, error)

	// EncryptionKey derives a deterministic AES key for the given tag. We assume that this derivation
	// can be repeated by the user at any time, producing the same key. Only a party in possession of
	// the user's secrets can produce a key.
	// This is useful for encrypting data stored outside the main MetaLocker platform. For instance,
	// external indexes can rely on this function.
	EncryptionKey(tag string, accessLevel model.AccessLevel) (*model.AESKey, error)

	// Lock locks the data wallet and clears all sensitive information held in memory.
	Lock() error
	// Unlock unlocks the data wallet using a passphrase. Data wallet needs to be unlocked
	// to perform the majority of operations with the underlying account and its data.
	Unlock(passphrase string) error
	// UnlockAsManaged unlocks the data wallet at 'managed' level using the provided key.
	UnlockAsManaged(managedKey *model.AESKey) error
	// UnlockWithAccessKey unlocks the data wallet using an access key. Access level depends on the underlying
	// key's access level.
	UnlockWithAccessKey(apiKey, apiSecret string) error
	// UnlockAsChild unlock the data wallet for sub-account using its parent secret.
	UnlockAsChild(parentNode slip10.Node) error

	CreateSubAccount(accessLevel model.AccessLevel, name string, opts ...account.Option) (DataWallet, error)
	GetSubAccount(id string) (*account.Account, error)
	DeleteSubAccount(id string) error
	SubAccounts() ([]*account.Account, error)
	GetSubAccountWallet(id string) (DataWallet, error)

	CreateAccessKey(accessLevel model.AccessLevel, duration time.Duration) (*model.AccessKey, error)
	GetAccessKey(keyID string) (*model.AccessKey, error)
	RevokeAccessKey(keyID string) error
	AccessKeys() ([]*model.AccessKey, error)

	RestrictedWallet(identities []string) (DataWallet, error)

	NewIdentity(accessLevel model.AccessLevel, name string, options ...IdentityOption) (Identity, error)
	AddIdentity(idy *account.Identity) error
	GetIdentities() (map[string]Identity, error)
	GetIdentity(iid string) (Identity, error)
	GetDID(iid string) (*model.DID, error)
	GetRootIdentity() (Identity, error)

	AddLocker(l *model.Locker) (Locker, error)
	GetLockers() ([]*model.Locker, error)
	GetLocker(lockerID string) (Locker, error)
	GetRootLocker(level model.AccessLevel) (Locker, error)

	GetProperty(key string) (string, error)
	SetProperty(key string, value string, lvl model.AccessLevel) error
	GetProperties() (map[string]string, error)
	DeleteProperty(key string, lvl model.AccessLevel) error

	CreateRootIndex(indexStoreName string) (index.RootIndex, error)
	RootIndex() (index.RootIndex, error)

	CreateIndex(indexStoreName, indexType string, opts ...index.Option) (index.Index, error)
	Index(id string) (index.Index, error)

	IndexUpdater(indexes ...index.Index) (*IndexUpdater, error)

	DataStore() DataStore

	Services() Services

	// Backend function is used to access raw identity and locker storage operations
	// in downstream infrastructure such as Digital Twins.
	Backend() AccountBackend
}

DataWallet is the main interface to the user's account and its data stored in MetaLocker. It incorporates all the complexity of interacting with encrypted resources, the main MetaLocker ledger, indexes, etc.

type DataWalletBackendBuilderFn

type DataWalletBackendBuilderFn func(acct *account.Account) (NodeClient, error)

type Factory

type Factory interface {
	// GetWalletWithAccessKey returns an unlocked data wallet instance for the given access key and secret.
	GetWalletWithAccessKey(apiKey, apiSecret string) (DataWallet, error)
}

Factory provides an interface for creating Data Wallets for the given API key ID and secret. This interface can hide details how the wallet is constructed and whether it's local or remote.

type ForceSyncMessage

type ForceSyncMessage struct {
	Type   string `json:"type"`
	Reason string `json:"reason"`
}

type Identity

type Identity interface {
	// ID returns the identity's ID
	ID() string
	// DID returns the identity's full DID definition, including its keys.
	DID() *model.DID
	// CreatedAt returns the time when the identity was created.
	CreatedAt() *time.Time
	// Name returns the name of the identity (only accessible to the account owner
	// for navigation/documentation purposes).
	Name() string
	// SetName is NOT SUPPORTED YET.
	SetName(name string) error
	// AccessLevel returns the identity's access level. Data wallet needs to
	// be unlocked to a specific access level to gain access to identities
	// at this level or higher.
	AccessLevel() model.AccessLevel
	// Raw returns the raw identity definition (as stored in the backend).
	Raw() *account.Identity
	// NewLocker creates a new locker for the identity. Use Participant option
	// to add other participants to the locker.
	NewLocker(name string, options ...LockerOption) (Locker, error)
}

Identity is an interface to a specific identity, one of many, stored in the account's data wallet.

type IdentityOption

type IdentityOption func(opts *identityOptions) error

IdentityOption is for defining parameters when creating new identities

func WithDID

func WithDID(did *model.DID) IdentityOption

func WithType

func WithType(identityType string) IdentityOption

type IndexUpdater

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

func NewIndexUpdater

func NewIndexUpdater(ledger model.Ledger) *IndexUpdater

func (*IndexUpdater) AddIndexes

func (ixf *IndexUpdater) AddIndexes(dw DataWallet, indexes ...index.Index) error

func (*IndexUpdater) Close

func (ixf *IndexUpdater) Close() error

func (*IndexUpdater) StartSyncOnEvents

func (ixf *IndexUpdater) StartSyncOnEvents(ns notification.Service, syncOnStart bool, forceSyncInterval time.Duration) error

func (*IndexUpdater) StopSyncOnEvents

func (ixf *IndexUpdater) StopSyncOnEvents()

func (*IndexUpdater) Sync

func (ixf *IndexUpdater) Sync() error

func (*IndexUpdater) SyncNoWait

func (ixf *IndexUpdater) SyncNoWait()

type LocalDataWallet

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

func NewLocalDataWallet

func NewLocalDataWallet(acct *account.Account, nodeClient NodeClient, dataStoreFn DataSetStoreConstructor, indexClient index.Client) (*LocalDataWallet, error)

func (*LocalDataWallet) AccessKeys

func (dw *LocalDataWallet) AccessKeys() ([]*model.AccessKey, error)

func (*LocalDataWallet) Account

func (dw *LocalDataWallet) Account() *account.Account

func (*LocalDataWallet) AddIdentity

func (dw *LocalDataWallet) AddIdentity(idy *account.Identity) error

func (*LocalDataWallet) AddLocker

func (dw *LocalDataWallet) AddLocker(locker *model.Locker) (Locker, error)

func (*LocalDataWallet) Backend

func (dw *LocalDataWallet) Backend() AccountBackend

func (*LocalDataWallet) ChangeEmail

func (dw *LocalDataWallet) ChangeEmail(email string) error

func (*LocalDataWallet) ChangePassphrase

func (dw *LocalDataWallet) ChangePassphrase(oldPassphrase, newPassphrase string, isHash bool) (DataWallet, error)

func (*LocalDataWallet) Close

func (dw *LocalDataWallet) Close() error

func (*LocalDataWallet) CreateAccessKey

func (dw *LocalDataWallet) CreateAccessKey(accessLevel model.AccessLevel, duration time.Duration) (*model.AccessKey, error)

func (*LocalDataWallet) CreateIndex

func (dw *LocalDataWallet) CreateIndex(indexStoreName, indexType string, opts ...index.Option) (index.Index, error)

func (*LocalDataWallet) CreateRootIndex

func (dw *LocalDataWallet) CreateRootIndex(indexStoreName string) (index.RootIndex, error)

func (*LocalDataWallet) CreateSubAccount

func (dw *LocalDataWallet) CreateSubAccount(accessLevel model.AccessLevel, name string, opts ...account.Option) (DataWallet, error)

func (*LocalDataWallet) DataStore

func (dw *LocalDataWallet) DataStore() DataStore

func (*LocalDataWallet) DeleteProperty

func (dw *LocalDataWallet) DeleteProperty(key string, lvl model.AccessLevel) error

func (*LocalDataWallet) DeleteSubAccount

func (dw *LocalDataWallet) DeleteSubAccount(id string) error

func (*LocalDataWallet) EncryptionKey

func (dw *LocalDataWallet) EncryptionKey(tag string, accessLevel model.AccessLevel) (*model.AESKey, error)

func (*LocalDataWallet) GetAccessKey

func (dw *LocalDataWallet) GetAccessKey(keyID string) (*model.AccessKey, error)

func (*LocalDataWallet) GetDID

func (dw *LocalDataWallet) GetDID(iid string) (*model.DID, error)

func (*LocalDataWallet) GetIdentities

func (dw *LocalDataWallet) GetIdentities() (map[string]Identity, error)

func (*LocalDataWallet) GetIdentity

func (dw *LocalDataWallet) GetIdentity(iid string) (Identity, error)

func (*LocalDataWallet) GetLocker

func (dw *LocalDataWallet) GetLocker(lockerID string) (Locker, error)

func (*LocalDataWallet) GetLockers

func (dw *LocalDataWallet) GetLockers() ([]*model.Locker, error)

func (*LocalDataWallet) GetProperties

func (dw *LocalDataWallet) GetProperties() (map[string]string, error)

func (*LocalDataWallet) GetProperty

func (dw *LocalDataWallet) GetProperty(key string) (string, error)

func (*LocalDataWallet) GetRootIdentity

func (dw *LocalDataWallet) GetRootIdentity() (Identity, error)

func (*LocalDataWallet) GetRootLocker

func (dw *LocalDataWallet) GetRootLocker(level model.AccessLevel) (Locker, error)

func (*LocalDataWallet) GetSubAccount

func (dw *LocalDataWallet) GetSubAccount(id string) (*account.Account, error)

func (*LocalDataWallet) GetSubAccountWallet

func (dw *LocalDataWallet) GetSubAccountWallet(id string) (DataWallet, error)

func (*LocalDataWallet) ID

func (dw *LocalDataWallet) ID() string

func (*LocalDataWallet) Index

func (dw *LocalDataWallet) Index(id string) (index.Index, error)

func (*LocalDataWallet) IndexUpdater

func (dw *LocalDataWallet) IndexUpdater(indexes ...index.Index) (*IndexUpdater, error)

func (*LocalDataWallet) Lock

func (dw *LocalDataWallet) Lock() error

Lock performs a best try effort to remove and zero all secret keys associated with the wallet.

This function will return an error if invoked on a watching-only wallet.

func (*LocalDataWallet) LockLevel

func (dw *LocalDataWallet) LockLevel() model.AccessLevel

LockLevel returns the current level of wallet access.

func (*LocalDataWallet) NewIdentity

func (dw *LocalDataWallet) NewIdentity(accessLevel model.AccessLevel, name string, options ...IdentityOption) (Identity, error)

func (*LocalDataWallet) Recover

func (dw *LocalDataWallet) Recover(cryptoKey *model.AESKey, newPassphrase string) (DataWallet, error)

func (*LocalDataWallet) RestrictedWallet

func (dw *LocalDataWallet) RestrictedWallet(identities []string) (DataWallet, error)

func (*LocalDataWallet) RevokeAccessKey

func (dw *LocalDataWallet) RevokeAccessKey(keyID string) error

func (*LocalDataWallet) RootIndex

func (dw *LocalDataWallet) RootIndex() (index.RootIndex, error)

func (*LocalDataWallet) Services

func (dw *LocalDataWallet) Services() Services

func (*LocalDataWallet) SetProperty

func (dw *LocalDataWallet) SetProperty(key string, value string, lvl model.AccessLevel) error

func (*LocalDataWallet) SubAccounts

func (dw *LocalDataWallet) SubAccounts() ([]*account.Account, error)

func (*LocalDataWallet) Unlock

func (dw *LocalDataWallet) Unlock(passphrase string) error

func (*LocalDataWallet) UnlockAsChild

func (dw *LocalDataWallet) UnlockAsChild(parentNode slip10.Node) error

func (*LocalDataWallet) UnlockAsManaged

func (dw *LocalDataWallet) UnlockAsManaged(managedKey *model.AESKey) error

func (*LocalDataWallet) UnlockWithAccessKey

func (dw *LocalDataWallet) UnlockWithAccessKey(apiKey, apiSecret string) error

type LocalFactory

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

func NewLocalFactory

func NewLocalFactory(ledger model.Ledger, offChainStorage model.OffChainStorage, blobManager model.BlobManager,
	identityBackend storage.IdentityBackend, notificationService notification.Service, indexClient index.Client, hashFunction account.PasswordHashFunction) (*LocalFactory, error)

func (*LocalFactory) CreateDataWallet

func (lf *LocalFactory) CreateDataWallet(acct *account.Account) (DataWallet, error)

func (*LocalFactory) GetWalletWithAccessKey

func (lf *LocalFactory) GetWalletWithAccessKey(apiKey, apiSecret string) (DataWallet, error)

func (*LocalFactory) RegisterAccount

func (lf *LocalFactory) RegisterAccount(acctTemplate *account.Account, opts ...account.Option) (DataWallet, *RecoveryDetails, error)

func (*LocalFactory) SaveAccount

func (lf *LocalFactory) SaveAccount(acct *account.Account) (DataWallet, error)

type LocalNodeClient

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

func NewLocalNodeClient

func NewLocalNodeClient(accountID string, identityBackend storage.IdentityBackend, ledger model.Ledger, offChainStorage model.OffChainStorage, blobManager model.BlobManager, notificationService notification.Service) *LocalNodeClient

func (*LocalNodeClient) BlobManager

func (lnc *LocalNodeClient) BlobManager() model.BlobManager

func (*LocalNodeClient) Close

func (lnc *LocalNodeClient) Close() error

func (*LocalNodeClient) CreateAccessKey

func (lnc *LocalNodeClient) CreateAccessKey(key *model.AccessKey) (*model.AccessKey, error)

func (*LocalNodeClient) CreateAccount

func (lnc *LocalNodeClient) CreateAccount(acct *account.Account, registrationCode string) error

func (*LocalNodeClient) CreateDIDDocument

func (lnc *LocalNodeClient) CreateDIDDocument(ddoc *model.DIDDocument) error

func (*LocalNodeClient) CreateSubAccount

func (lnc *LocalNodeClient) CreateSubAccount(acct *account.Account) (*account.Account, error)

func (*LocalNodeClient) DIDProvider

func (lnc *LocalNodeClient) DIDProvider() model.DIDProvider

func (*LocalNodeClient) DeleteAccessKey

func (lnc *LocalNodeClient) DeleteAccessKey(keyID string) error

func (*LocalNodeClient) DeleteAccount

func (lnc *LocalNodeClient) DeleteAccount(id string) error

func (*LocalNodeClient) DeleteProperty

func (lnc *LocalNodeClient) DeleteProperty(hash string) error

func (*LocalNodeClient) GetAccessKey

func (lnc *LocalNodeClient) GetAccessKey(keyID string) (*model.AccessKey, error)

func (*LocalNodeClient) GetAccount

func (lnc *LocalNodeClient) GetAccount(id string) (*account.Account, error)

func (*LocalNodeClient) GetDIDDocument

func (lnc *LocalNodeClient) GetDIDDocument(iid string) (*model.DIDDocument, error)

func (*LocalNodeClient) GetIdentity

func (lnc *LocalNodeClient) GetIdentity(hash string) (*account.DataEnvelope, error)

func (*LocalNodeClient) GetLocker

func (lnc *LocalNodeClient) GetLocker(hash string) (*account.DataEnvelope, error)

func (*LocalNodeClient) GetOwnAccount

func (lnc *LocalNodeClient) GetOwnAccount() (*account.Account, error)

func (*LocalNodeClient) GetProperty

func (lnc *LocalNodeClient) GetProperty(hash string) (*account.DataEnvelope, error)

func (*LocalNodeClient) Ledger

func (lnc *LocalNodeClient) Ledger() model.Ledger

func (*LocalNodeClient) ListAccessKeys

func (lnc *LocalNodeClient) ListAccessKeys() ([]*model.AccessKey, error)

func (*LocalNodeClient) ListIdentities

func (lnc *LocalNodeClient) ListIdentities() ([]*account.DataEnvelope, error)

func (*LocalNodeClient) ListLockerHashes

func (lnc *LocalNodeClient) ListLockerHashes() ([]string, error)

func (*LocalNodeClient) ListLockers

func (lnc *LocalNodeClient) ListLockers() ([]*account.DataEnvelope, error)

func (*LocalNodeClient) ListProperties

func (lnc *LocalNodeClient) ListProperties() ([]*account.DataEnvelope, error)

func (*LocalNodeClient) ListSubAccounts

func (lnc *LocalNodeClient) ListSubAccounts(id string) ([]*account.Account, error)

func (*LocalNodeClient) NewInstance

func (lnc *LocalNodeClient) NewInstance(email, passphrase string, isHash bool) (NodeClient, error)

func (*LocalNodeClient) NotificationService

func (lnc *LocalNodeClient) NotificationService() (notification.Service, error)

func (*LocalNodeClient) OffChainStorage

func (lnc *LocalNodeClient) OffChainStorage() model.OffChainStorage

func (*LocalNodeClient) PatchAccount

func (lnc *LocalNodeClient) PatchAccount(email, oldEncryptedPassword, newEncryptedPassword, name, givenName, familyName string) error

func (*LocalNodeClient) StoreIdentity

func (lnc *LocalNodeClient) StoreIdentity(idy *account.DataEnvelope) error

func (*LocalNodeClient) StoreLocker

func (lnc *LocalNodeClient) StoreLocker(l *account.DataEnvelope) error

func (*LocalNodeClient) StoreProperty

func (lnc *LocalNodeClient) StoreProperty(prop *account.DataEnvelope) error

func (*LocalNodeClient) SubAccountInstance

func (lnc *LocalNodeClient) SubAccountInstance(subAccountID string) (NodeClient, error)

func (*LocalNodeClient) UpdateAccount

func (lnc *LocalNodeClient) UpdateAccount(acct *account.Account) error

type Locker

type Locker interface {
	// ID returns the locker ID.
	ID() string
	// CreatedAt returns the locker's creation time. For documentation purposes only.
	CreatedAt() *time.Time
	// Name returns the locker's name. These names are useful for locker documentation purposes.
	// They aren't used in any data processing.
	Name() string
	// SetName is NOT SUPPORTED YET.
	SetName(name string) error
	// AccessLevel returns the locker's access level. Data wallet needs to be unlocked
	// to a specific access level to gain access to lockers at this level or higher.
	AccessLevel() model.AccessLevel
	// Raw returns the raw locker definition (as stored in the backend).
	Raw() *model.Locker

	// IsUniLocker returns true, if the locker has just one participant (is a 'uni-locker').
	IsUniLocker() bool
	// IsThirdParty returns true, if the account doesn't have control over any of the locker
	// participants, but has access to the locker's secrets (a delegated access).
	IsThirdParty() bool
	// Us returns the account controlled locker participant (if any).
	Us() *model.LockerParticipant
	// Them returns a list of all locker participants that aren't controlled by the account.
	Them() []*model.LockerParticipant

	// NewDataSetBuilder returns an instance of dataset.Builder that enables interactive construction
	// of a dataset. This builder assumes the dataset will be stored in this locker.
	NewDataSetBuilder(opts ...dataset.BuilderOption) (dataset.Builder, error)
	// Store is a convenience method that submits a dataset with no attachments to this locker.
	Store(meta any, expiryTime time.Time, opts ...dataset.BuilderOption) dataset.RecordFuture
	// Share shares the dataset from the record with the given id (we assume the account has access
	// to this record) through the locker.
	Share(id, vaultName string, expiryTime time.Time) dataset.RecordFuture
	// HeadID returns the ID of the dataset head for the given asset ID and head name (and linked
	// to the locker).
	HeadID(assetID string, headName string) string
	// SetAssetHead sets the record with the given ID as a head for the dataset with the given asset ID.
	SetAssetHead(assetID, headName, recordID string) dataset.RecordFuture

	// Seal closes the locker. NOT CURRENTLY SUPPORTED.
	Seal() error
}

Locker is an interface to the account's lockers (secure, persistent, bidirectional communication channels between two or more participants).

type LockerOption

type LockerOption func(opts *lockerOptions) error

LockerOption is for defining parameters when creating new lockers

func ExpiresAt

func ExpiresAt(expiresAt time.Time) LockerOption

func FixedSeed

func FixedSeed(seed []byte) LockerOption

func Participant

func Participant(did *model.DID, seed []byte) LockerOption

type NodeClient

type NodeClient interface {
	io.Closer
	AccountBackend
	Services

	NewInstance(email, passphrase string, isHash bool) (NodeClient, error)
	SubAccountInstance(subAccountID string) (NodeClient, error)
}

NodeClient is an interface to a MetaLocker node that data wallets require to perform data management operations.

type RecoveryDetails

type RecoveryDetails struct {
	RecoveryPhrase          string
	SecondLevelRecoveryCode string
}

type RestrictedNodeClient

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

func NewRestrictedNodeClient

func NewRestrictedNodeClient(identities []string, nodeClient NodeClient) *RestrictedNodeClient

NewRestrictedNodeClient is currently not in use, since we moved to encrypted identities/lockers

func (*RestrictedNodeClient) BlobManager

func (r *RestrictedNodeClient) BlobManager() model.BlobManager

func (*RestrictedNodeClient) Close

func (r *RestrictedNodeClient) Close() error

func (*RestrictedNodeClient) CreateAccessKey

func (r *RestrictedNodeClient) CreateAccessKey(key *model.AccessKey) (*model.AccessKey, error)

func (*RestrictedNodeClient) CreateAccount

func (r *RestrictedNodeClient) CreateAccount(acct *account.Account, registrationCode string) error

func (*RestrictedNodeClient) CreateSubAccount

func (r *RestrictedNodeClient) CreateSubAccount(acct *account.Account) (*account.Account, error)

func (*RestrictedNodeClient) DIDProvider

func (r *RestrictedNodeClient) DIDProvider() model.DIDProvider

func (*RestrictedNodeClient) DeleteAccessKey

func (r *RestrictedNodeClient) DeleteAccessKey(keyID string) error

func (*RestrictedNodeClient) DeleteAccount

func (r *RestrictedNodeClient) DeleteAccount(id string) error

func (*RestrictedNodeClient) DeleteProperty

func (r *RestrictedNodeClient) DeleteProperty(hash string) error

func (*RestrictedNodeClient) GetAccessKey

func (r *RestrictedNodeClient) GetAccessKey(aid string) (*model.AccessKey, error)

func (*RestrictedNodeClient) GetAccount

func (r *RestrictedNodeClient) GetAccount(id string) (*account.Account, error)

func (*RestrictedNodeClient) GetIdentity

func (r *RestrictedNodeClient) GetIdentity(hash string) (*account.DataEnvelope, error)

func (*RestrictedNodeClient) GetLocker

func (r *RestrictedNodeClient) GetLocker(hash string) (*account.DataEnvelope, error)

func (*RestrictedNodeClient) GetOwnAccount

func (r *RestrictedNodeClient) GetOwnAccount() (*account.Account, error)

func (*RestrictedNodeClient) GetProperty

func (r *RestrictedNodeClient) GetProperty(hash string) (*account.DataEnvelope, error)

func (*RestrictedNodeClient) Ledger

func (r *RestrictedNodeClient) Ledger() model.Ledger

func (*RestrictedNodeClient) ListAccessKeys

func (r *RestrictedNodeClient) ListAccessKeys() ([]*model.AccessKey, error)

func (*RestrictedNodeClient) ListIdentities

func (r *RestrictedNodeClient) ListIdentities() ([]*account.DataEnvelope, error)

func (*RestrictedNodeClient) ListLockerHashes

func (r *RestrictedNodeClient) ListLockerHashes() ([]string, error)

func (*RestrictedNodeClient) ListLockers

func (r *RestrictedNodeClient) ListLockers() ([]*account.DataEnvelope, error)

func (*RestrictedNodeClient) ListProperties

func (r *RestrictedNodeClient) ListProperties() ([]*account.DataEnvelope, error)

func (*RestrictedNodeClient) ListSubAccounts

func (r *RestrictedNodeClient) ListSubAccounts(id string) ([]*account.Account, error)

func (*RestrictedNodeClient) NewInstance

func (r *RestrictedNodeClient) NewInstance(email, passphrase string, isHash bool) (NodeClient, error)

func (*RestrictedNodeClient) NotificationService

func (r *RestrictedNodeClient) NotificationService() (notification.Service, error)

func (*RestrictedNodeClient) OffChainStorage

func (r *RestrictedNodeClient) OffChainStorage() model.OffChainStorage

func (*RestrictedNodeClient) PatchAccount

func (r *RestrictedNodeClient) PatchAccount(email, oldEncryptedPassword, newEncryptedPassword, name, givenName, familyName string) error

func (*RestrictedNodeClient) StoreIdentity

func (r *RestrictedNodeClient) StoreIdentity(idy *account.DataEnvelope) error

func (*RestrictedNodeClient) StoreLocker

func (r *RestrictedNodeClient) StoreLocker(l *account.DataEnvelope) error

func (*RestrictedNodeClient) StoreProperty

func (r *RestrictedNodeClient) StoreProperty(prop *account.DataEnvelope) error

func (*RestrictedNodeClient) SubAccountInstance

func (r *RestrictedNodeClient) SubAccountInstance(subAccountID string) (NodeClient, error)

func (*RestrictedNodeClient) UpdateAccount

func (r *RestrictedNodeClient) UpdateAccount(acct *account.Account) error

type Services

type Services interface {
	DIDProvider() model.DIDProvider

	OffChainStorage() model.OffChainStorage
	Ledger() model.Ledger
	BlobManager() model.BlobManager
	NotificationService() (notification.Service, error)
}

Services is an interface to MetaLocker services that are necessary for data wallet operations. It is assumed all the operations with these services will be authenticated against the data wallet's account.

Jump to

Keyboard shortcuts

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