Documentation
¶
Index ¶
- Constants
- Variables
- type Info
- func (i *Info) AddPodName(podName string, podInfo *pod.Info)
- func (i *Info) GetAccount() *account.Account
- func (i *Info) GetFeed() *feed.API
- func (i *Info) GetGroup() *pod.Group
- func (i *Info) GetPod() *pod.Pod
- func (i *Info) GetSessionId() string
- func (i *Info) GetUserDirectory() *d.Directory
- func (i *Info) GetUserName() string
- func (i *Info) RemovePodName(podName string)
- type LoginResponse
- type ReceiveFileInfo
- type SharingEntry
- type SharingMetaData
- type SignupResponse
- type Stat
- type Users
- func (u *Users) ConnectWallet(userName, passPhrase, walletAddressHex, signature string, ...) error
- func (u *Users) CreateNewUserV2(userName, passPhrase, mnemonic, sessionId string, tm taskmanager.TaskManagerGO, ...) (*SignupResponse, error)
- func (u *Users) DeleteUserV2(userName, password, sessionId string, ui *Info) error
- func (u *Users) GetLoggedInUserInfo(sessionId string) *Info
- func (u *Users) GetNameHash(username string) ([32]byte, error)
- func (u *Users) GetUserInfoFromENS(nameHash [32]byte) (common.Address, *ecdsa.PublicKey, error)
- func (u *Users) GetUserStat(userInfo *Info) (*Stat, error)
- func (u *Users) GetUsersLoggedIn() map[string]*Info
- func (u *Users) IsUserLoggedIn(sessionId string) bool
- func (u *Users) IsUserNameLoggedIn(userName string) bool
- func (u *Users) IsUsernameAvailableV2(userName string) bool
- func (u *Users) LoadLiteUser(userName, _, mnemonic, sessionId string, tm taskmanager.TaskManagerGO, ...) (string, string, *Info, error)
- func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Client, ...) (*LoginResponse, error)
- func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore.Client, ...) (*Info, string, error)
- func (u *Users) Logout(sessionId string) error
- func (u *Users) LogoutUser(userName, sessionId string) error
- func (u *Users) ReceiveFileFromUser(_ *Info, pd *pod.Pod, podName, ref, podDir string) (string, error)
- func (u *Users) ReceiveFileInfo(ref string) (*ReceiveFileInfo, error)
- func (u *Users) ShareFileWithUser(podName, podPassword, podFileWithPath, destinationRef string, userInfo *Info, ...) (string, error)
Constants ¶
const (
// AuthVersion is used to version the portable account feed topic
AuthVersion = "FDP-login-v1.0"
)
Variables ¶
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
AddPodName adds pod to user pod map
func (*Info) GetAccount ¶
GetAccount returns user account info
func (*Info) GetUserDirectory ¶ added in v0.6.2
GetUserDirectory returns user directory handler
func (*Info) RemovePodName ¶
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"` }
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"` }
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"` 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 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
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 ¶
GetLoggedInUserInfo returns the user info of the user
func (*Users) GetNameHash ¶ added in v0.9.3
func (*Users) GetUserInfoFromENS ¶ added in v0.9.3
func (*Users) GetUserStat ¶
GetUserStat shows the user information like username and his address.
func (*Users) GetUsersLoggedIn ¶ added in v0.10.0
GetUsersLoggedIn returns all the users that are loggedin
func (*Users) IsUserLoggedIn ¶
IsUserLoggedIn checks if the user is logged-in from sessionID
func (*Users) IsUserNameLoggedIn ¶
IsUserNameLoggedIn checks if the user is logged-in from username
func (*Users) IsUsernameAvailableV2 ¶ added in v0.8.0
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 ¶
Logout removes the user information from all the data structures and clears the cookie.
func (*Users) LogoutUser ¶
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.