Documentation ¶
Index ¶
- Variables
- func GenerateToken() string
- type ConnectedWallet
- func (s *ConnectedWallet) CanUseKey(pubKey string) bool
- func (s *ConnectedWallet) Expired(now time.Time) error
- func (s *ConnectedWallet) Permissions() wallet.Permissions
- func (s *ConnectedWallet) ReloadWithWallet(updatedWallet wallet.Wallet) error
- func (s *ConnectedWallet) RequireInteraction() bool
- func (s *ConnectedWallet) UpdatePermissions(perms wallet.Permissions) error
- type Connection
- type Sessions
- func (s *Sessions) ConnectWallet(hostname string, w wallet.Wallet) (string, error)
- func (s *Sessions) ConnectWalletForLongLivingConnection(token string, w wallet.Wallet, now time.Time, expiry *time.Time) error
- func (s *Sessions) DisconnectAllWallets()
- func (s *Sessions) DisconnectWallet(hostname, wallet string)
- func (s *Sessions) DisconnectWalletWithToken(token string) error
- func (s *Sessions) GetConnectedWallet(token string, now time.Time) (*ConnectedWallet, error)
- func (s *Sessions) ListConnections() []Connection
- type Token
- type TokenSummary
- type WalletCredentials
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoWalletConnected = errors.New("no wallet connected") ErrCannotEndLongLivingSessions = errors.New("sessions attached to long-living tokens cannot be ended") ErrGeneratedTokenCollidesWithExistingToken = errors.New("the generated token collides with an existing token") ErrAPITokenExpired = errors.New("the token has expired") )
Functions ¶
func GenerateToken ¶
func GenerateToken() string
Types ¶
type ConnectedWallet ¶
type ConnectedWallet struct { // Hostname is the hostname for which the connection is set. Hostname string // Wallet is the wallet selected by the client for this connection. Wallet wallet.Wallet // RestrictedKeys holds the keys that have been selected by the client // during the permissions request. RestrictedKeys map[string]wallet.KeyPair // An optional expiry date for this token Expiry *time.Time // contains filtered or unexported fields }
ConnectedWallet contains the resources and the information of the current connection, required by the wallet handlers to work, and based on the permissions the client has set.
func NewConnectedWallet ¶
func NewConnectedWallet(hostname string, w wallet.Wallet) (*ConnectedWallet, error)
func (*ConnectedWallet) CanUseKey ¶
func (s *ConnectedWallet) CanUseKey(pubKey string) bool
CanUseKey determines is the permissions allow the specified key to be used, and ensure the key exist and is not tainted.
func (*ConnectedWallet) Permissions ¶
func (s *ConnectedWallet) Permissions() wallet.Permissions
func (*ConnectedWallet) ReloadWithWallet ¶
func (s *ConnectedWallet) ReloadWithWallet(updatedWallet wallet.Wallet) error
func (*ConnectedWallet) RequireInteraction ¶
func (s *ConnectedWallet) RequireInteraction() bool
RequireInteraction tells if an interaction with the user is needed for supervision is required or not. It is related to the type of API token that is used for this connection. If it's a long-living token, then no interaction is required.
func (*ConnectedWallet) UpdatePermissions ¶
func (s *ConnectedWallet) UpdatePermissions(perms wallet.Permissions) error
type Connection ¶
type Sessions ¶
type Sessions struct {
// contains filtered or unexported fields
}
Sessions holds the live sessions.
func NewSessions ¶
func NewSessions() *Sessions
func (*Sessions) ConnectWallet ¶
ConnectWallet initiates a wallet connection and load associated resources in it. If a connection already exists, it's disconnected and a new token is generated.
func (*Sessions) ConnectWalletForLongLivingConnection ¶
func (*Sessions) DisconnectAllWallets ¶
func (s *Sessions) DisconnectAllWallets()
func (*Sessions) DisconnectWallet ¶
DisconnectWallet unloads the connected wallet resources and revokes the token. It does not fail. Non-existing token does nothing. This doesn't work for long-living connections.
func (*Sessions) DisconnectWalletWithToken ¶
DisconnectWalletWithToken looks for the connected wallet associated to the token, unloads its resources, and revokes the token. It does not fail. Non-existing token does nothing.
func (*Sessions) GetConnectedWallet ¶
GetConnectedWallet retrieves the resources and information of the connected wallet, associated to the specified token.
func (*Sessions) ListConnections ¶
func (s *Sessions) ListConnections() []Connection
ListConnections lists all the live connections as a list of pairs of hostname/wallet name. The list is sorted, first, by hostname, and, then, by wallet name.
type Token ¶
type Token struct { Description string `json:"description"` Expiry *int64 `json:"expiry"` Token string `json:"token"` Wallet WalletCredentials `json:"wallet"` }