user

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// AuthVersion is used to version the portable account feed topic
	AuthVersion = "FDP-login-v1.0"
)

Variables

View Source
var (
	// ErrUserAlreadyLoggedIn is returned if username is already logged-in
	ErrUserAlreadyLoggedIn = errors.New("user already logged-in")

	// ErrInvalidUserName is returned if the username is invalid
	ErrInvalidUserName = errors.New("invalid user name")

	// ErrUserNameNotFound is returned if the username is invalid
	ErrUserNameNotFound = errors.New("no user available")

	// ErrUserAlreadyPresent is returned if username is already taken while signup
	ErrUserAlreadyPresent = errors.New("user name already present")

	// ErrUserNotLoggedIn is returned if user is not logged-in
	ErrUserNotLoggedIn = errors.New("user not logged-in")

	// ErrInvalidPassword is returned if password is invalid
	ErrInvalidPassword = errors.New("invalid password")

	// ErrPasswordTooSmall is returned if password is invalid
	ErrPasswordTooSmall = errors.New("password should be at least 12 characters long")

	// ErrBlankPassword is returned if dfs.API CreateAccountV2 is called with a blank password
	ErrBlankPassword = errors.New("password is blank")

	// ErrBlankUsername is returned if dfs.API CreateAccountV2 is called with a blank username
	ErrBlankUsername = errors.New("username is blank")
)

Functions

This section is empty.

Types

type Info

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

Info is user information on fairOS

func (*Info) AddPodName added in v0.6.2

func (i *Info) AddPodName(podName string, podInfo *pod.Info)

AddPodName adds pod to user pod map

func (*Info) GetAccount

func (i *Info) GetAccount() *account.Account

GetAccount returns user account info

func (*Info) GetFeed

func (i *Info) GetFeed() *feed.API

GetFeed returns user feed handler

func (*Info) GetGroup added in v0.10.0

func (i *Info) GetGroup() *pod.Group

GetGroup returns user group handler

func (*Info) GetPod

func (i *Info) GetPod() *pod.Pod

GetPod returns user pod handler

func (*Info) GetSessionId

func (i *Info) GetSessionId() string

GetSessionId get sessionId

func (*Info) GetUserDirectory added in v0.6.2

func (i *Info) GetUserDirectory() *d.Directory

GetUserDirectory returns user directory handler

func (*Info) GetUserName

func (i *Info) GetUserName() string

GetUserName return username

func (*Info) RemovePodName

func (i *Info) RemovePodName(podName string)

RemovePodName removes pod from user pod map

type LoginResponse added in v0.9.4

type LoginResponse struct {
	Address     string `json:"address"`
	NameHash    string `json:"nameHash"`
	PublicKey   string `json:"publicKey"`
	UserInfo    *Info  `json:"userInfo"`
	AccessToken string `json:"accessToken"`
}

LoginResponse is the response of a successful login

type ReceiveFileInfo

type ReceiveFileInfo struct {
	FileName       string `json:"name"`
	Size           string `json:"size"`
	BlockSize      string `json:"blockSize"`
	NumberOfBlocks string `json:"numberOfBlocks"`
	ContentType    string `json:"contentType"`
	Compression    string `json:"compression"`
	Sender         string `json:"sourceAddress"`
	Receiver       string `json:"destAddress"`
	SharedTime     string `json:"sharedTime"`
}

ReceiveFileInfo is the structure of the file info received from the user

type SharingEntry

type SharingEntry struct {
	Meta       *f.MetaData `json:"meta"`
	Sender     string      `json:"sourceAddress"`
	Receiver   string      `json:"destAddress"`
	SharedTime string      `json:"sharedTime"`
}

SharingEntry is the structure of the sharing entry

type SharingMetaData added in v0.9.1

type SharingMetaData struct {
	Version          uint8  `json:"version"`
	Path             string `json:"filePath"`
	Name             string `json:"fileName"`
	SharedPassword   string `json:"sharedPassword"`
	Size             uint64 `json:"fileSize"`
	BlockSize        uint32 `json:"blockSize"`
	ContentType      string `json:"contentType"`
	Compression      string `json:"compression"`
	CreationTime     int64  `json:"creationTime"`
	AccessTime       int64  `json:"accessTime"`
	ModificationTime int64  `json:"modificationTime"`
	InodeAddress     []byte `json:"fileInodeReference"`
}

SharingMetaData is the structure of the sharing metadata

type SignupResponse added in v0.9.4

type SignupResponse struct {
	Address   string `json:"address"`
	Mnemonic  string `json:"mnemonic"`
	NameHash  string `json:"nameHash"`
	PublicKey string `json:"publicKey"`
	UserInfo  *Info  `json:"userInfo"`
}

SignupResponse is the response of a successful signup

type Stat

type Stat struct {
	Name      string `json:"userName"`
	Reference string `json:"address"`
}

Stat is the structure of the user information.

type Users

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

Users is the main object which stores all the logged-in users and there respective

func NewUsers

func NewUsers(client blockstore.Client, ens ensm.ENSManager, feedCacheSize int, feedCacheTTL time.Duration, logger logging.Logger) *Users

NewUsers creates the main user object which stores all the logged-in users and there respective other data structures.

func (*Users) ConnectWallet added in v0.9.3

func (u *Users) ConnectWallet(userName, passPhrase, walletAddressHex, signature string, client blockstore.Client) error

ConnectWallet connects user with wallet.

func (*Users) CreateNewUserV2 added in v0.8.0

func (u *Users) CreateNewUserV2(userName, passPhrase, mnemonic, sessionId string, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager) (*SignupResponse, error)

CreateNewUserV2 creates a new user with the given username and password. if a mnemonic is passed then it is used instead of creating a new one.

func (*Users) DeleteUserV2 added in v0.8.0

func (u *Users) DeleteUserV2(userName, password, sessionId string, ui *Info) error

DeleteUserV2 deletes a user from the Swarm network. Logs him out if he is logged-in and remove from all the data structures.

func (*Users) GetLoggedInUserInfo

func (u *Users) GetLoggedInUserInfo(sessionId string) *Info

GetLoggedInUserInfo returns the user info of the user

func (*Users) GetNameHash added in v0.9.3

func (u *Users) GetNameHash(username string) ([32]byte, error)

func (*Users) GetUserInfoFromENS added in v0.9.3

func (u *Users) GetUserInfoFromENS(nameHash [32]byte) (common.Address, *ecdsa.PublicKey, error)

func (*Users) GetUserStat

func (u *Users) GetUserStat(userInfo *Info) (*Stat, error)

GetUserStat shows the user information like username and his address.

func (*Users) GetUsersLoggedIn added in v0.10.0

func (u *Users) GetUsersLoggedIn() map[string]*Info

GetUsersLoggedIn returns all the users that are loggedin

func (*Users) IsUserLoggedIn

func (u *Users) IsUserLoggedIn(sessionId string) bool

IsUserLoggedIn checks if the user is logged-in from sessionID

func (*Users) IsUserNameLoggedIn

func (u *Users) IsUserNameLoggedIn(userName string) bool

IsUserNameLoggedIn checks if the user is logged-in from username

func (*Users) IsUsernameAvailableV2 added in v0.8.0

func (u *Users) IsUsernameAvailableV2(userName string) bool

IsUsernameAvailableV2 checks if a supplied username is present in blockchain

func (*Users) LoadLiteUser added in v0.9.2

func (u *Users) LoadLiteUser(userName, _, mnemonic, sessionId string, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager) (string, string, *Info, error)

LoadLiteUser creates an off chain user, that has no ens or soc in the swarm. It only creates the required information to execute user function and stores it in memory.

func (*Users) LoginUserV2 added in v0.8.0

func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*LoginResponse, error)

LoginUserV2 checks if the user is present and logs in the user. It also creates the required information to execute user function and stores it in memory.

func (*Users) LoginWithWallet added in v0.9.3

func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*Info, string, error)

LoginWithWallet logs user in with wallet and signature

func (*Users) Logout

func (u *Users) Logout(sessionId string) error

Logout removes the user information from all the data structures and clears the cookie.

func (*Users) LogoutUser

func (u *Users) LogoutUser(userName, sessionId string) error

LogoutUser logs out a giver user from the system and clean him from all the data structures.

func (*Users) ReceiveFileFromUser

func (u *Users) ReceiveFileFromUser(_ *Info, pd *pod.Pod, podName, ref, podDir string) (string, error)

ReceiveFileFromUser imports an exported file in to the current user and pod by reading the sharing file entry.

func (*Users) ReceiveFileInfo

func (u *Users) ReceiveFileInfo(ref string) (*ReceiveFileInfo, error)

ReceiveFileInfo displays the information of the exported file. This is used to decide whether to import the file or not.

func (*Users) ShareFileWithUser

func (u *Users) ShareFileWithUser(podName, podPassword, podFileWithPath, destinationRef string, userInfo *Info, pod *pod.Pod, userAddress utils.Address) (string, error)

ShareFileWithUser exports a file to another user by creating and uploading a new encrypted sharing file entry.

Jump to

Keyboard shortcuts

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