core

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = ""
	Commit    = ""
	BuildTime = ""
	GitState  = ""
)

Set via ldflags during build

View Source
var (
	ErrNotFound = errors.New("credentials not found")
)

Functions

func Authenticate added in v0.1.0

func Authenticate(accountKey, rootPath, apiAddr string) error

Authenticate performs the full authentication flow for a bot account using an account key. This includes wallet recovery, session creation, account recovery, account selection, and config persistence.

func ClientContextWithAuth

func ClientContextWithAuth(token string) context.Context

func ClientContextWithAuthTimeout

func ClientContextWithAuthTimeout(token string, timeout time.Duration) (context.Context, context.CancelFunc)

ClientContextWithAuthTimeout creates a context with both authentication and timeout

func CloseEventReceiver

func CloseEventReceiver()

CloseEventReceiver closes the global event receiver instance if it exists

func CloseGRPCConnection

func CloseGRPCConnection()

CloseGRPCConnection ensures the connection is properly closed

func CreateAPIKey

func CreateAPIKey(name string) (*pb.RpcAccountLocalLinkCreateAppResponse, error)

CreateAPIKey creates a new API key for local app access

func CreateWallet

func CreateWallet(name, rootPath, apiAddr string) (string, string, bool, error)

CreateWallet creates a new wallet and account, establishes a session, saves credentials, and returns the account key, account ID, and whether credentials were saved to keyring.

func DeleteStoredAccountKey added in v0.1.0

func DeleteStoredAccountKey() error

func DeleteStoredSessionToken added in v0.1.0

func DeleteStoredSessionToken() error

func GRPCCall

func GRPCCall(fn func(ctx context.Context, client service.ClientCommandsClient) error) error

GRPCCall is a helper that reduces boilerplate for gRPC calls It gets the client, token, creates context with timeout, and executes the function

func GRPCCallNoAuth

func GRPCCallNoAuth(fn func(ctx context.Context, client service.ClientCommandsClient) error) error

GRPCCallNoAuth is like GRPCCall but without authentication

func GetGRPCClient

func GetGRPCClient() (service.ClientCommandsClient, error)

GetGRPCClient initializes (if needed) and returns the shared gRPC client

func GetHeartVersion added in v0.1.0

func GetHeartVersion() string

func GetReleaseURL

func GetReleaseURL() string

func GetStoredAccountKey added in v0.1.0

func GetStoredAccountKey() (string, bool, error)

GetStoredAccountKey retrieves the account key from keyring if available, otherwise from config file. Returns the account key, true if retrieved from keyring (false if from config file), and any error.

func GetStoredSessionToken added in v0.1.0

func GetStoredSessionToken() (string, bool, error)

GetStoredSessionToken retrieves the session token from keyring if available, otherwise from config file. Returns the token, true if retrieved from keyring (false if from config file), and any error.

func GetVersion

func GetVersion() string

func GetVersionBrief

func GetVersionBrief() string

func GetVersionVerbose

func GetVersionVerbose() string

func JoinSpace

func JoinSpace(networkId, spaceId, inviteCId, inviteFileKey string) error

func LeaveSpace

func LeaveSpace(spaceId string) error

func ListAPIKeys

ListAPIKeys lists all API keys

func Login

func Login(accountKey, rootPath, apiAddr string) error

Login handles user interaction for login by prompting for account key if not provided, validating it, performing authentication, and saving the key to keychain.

func Logout

func Logout() error

Logout logs out the current user by deleting stored credentials, clearing the config, and attempting to stop the account and close the wallet session on the server.

func RevokeAPIKey

func RevokeAPIKey(appId string) error

RevokeAPIKey revokes an API key by appId

func SaveAccountKey added in v0.1.0

func SaveAccountKey(accountKey string) (bool, error)

SaveAccountKey saves the account key to the keyring if available, otherwise to the config file. Returns true if saved to keyring, false if saved to config file.

func SaveSessionToken added in v0.1.0

func SaveSessionToken(token string) (bool, error)

SaveSessionToken saves the session token to the keyring if available, otherwise to the config file. Returns true if saved to keyring, false if saved to config file.

func ValidateAccountKey added in v0.1.0

func ValidateAccountKey(accountKey string) error

ValidateAccountKey checks if the provided account key is valid.

func ViewSpaceInvite

func ViewSpaceInvite(inviteCId, inviteFileKey string) (*pb.RpcSpaceInviteViewResponse, error)

func WaitForAccountId

func WaitForAccountId(er *EventReceiver) (string, error)

WaitForAccountId waits for an accountShow event and returns the account Id

Types

type EventReceiver

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

func ListenForEvents

func ListenForEvents(token string) (*EventReceiver, error)

ListenForEvents ensures a single EventReceiver instance is used.

func (*EventReceiver) Close

func (er *EventReceiver) Close()

Close stops the event receiver

func (*EventReceiver) WaitForEvent

func (er *EventReceiver) WaitForEvent(ctx context.Context, predicate func(*pb.EventMessage) bool) (*pb.EventMessage, error)

WaitForEvent waits for an event matching the predicate

func (*EventReceiver) WaitOne

func (er *EventReceiver) WaitOne(ctx context.Context) (*pb.EventMessage, error)

WaitOne waits for any single event with optional timeout

type SpaceListItem

type SpaceListItem struct {
	SpaceId string
	Name    string
	Status  model.SpaceStatus
}

func ListSpaces

func ListSpaces() ([]SpaceListItem, error)

ListSpaces returns a list of all available spaces

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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