account

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound = errors.New("no such account")
)
View Source
var ErrInvalidType = errors.New("invalid account type")
View Source
var ErrNoCredentials = errors.New("no credentials found")

Functions

This section is empty.

Types

type Account

type Account struct {
	UUID    string `json:"uuid"`
	Profile struct {
		Username string `json:"username"`
	} `json:"profile"`

	Type Type `json:"type"`
	// Source is the token data for the auth Type.
	// Either MicrosoftTokenData or (todo) MojangTokenData.
	Source interface{} `json:"source"`
}

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(data []byte) error

type Credentials

type Credentials struct {
	AccessToken     string    `json:"accessToken"`
	TokenExpiration time.Time `json:"accessExpiration"`
	RefreshToken    string    `json:"refreshToken"`
}

type Keychain

type Keychain interface {
	Get(key string) (*Credentials, error)
	Set(key string, credentials *Credentials) error
}

Keychain is an interface for storing and retrieving account credentials, with support for using both a high security system keyring (eg Keychain on macOS, gnome keyring) and a local file.

func NewKeychain

func NewKeychain(dataDir string, useSystemKeyring bool) Keychain

type MSOBeginPolling

type MSOBeginPolling func()

type MSOPromptCallback

type MSOPromptCallback func(verificationUrl, userCode string)

type Manager

type Manager interface {
	// GetDefault returns the default account, or the empty string if there is no account set
	GetDefault() string
	// SetDefault replaces the default account with the given account, or an error if the account
	// does not exist (ErrAccountNotFound) or another error occurred
	//
	// The Manager is not resposible for persisting the change, Save should be called afterwards.
	SetDefault(uuid string) error

	Accounts() []string
	// GetAccount returns the account with the given value, or nil if it cannot be found.
	// Either a (case-insensitive) name, or a UUID (with/without dashes) can be matched
	GetAccount(value string) *Account
	// GetAccountToken returns a _minecraft_ access token for the given account.
	// The given value may be a (case-insensitive) name, or a UUID (with/without dashes).
	//
	// This function will always return an active token, using the refresh token if necessary.
	GetAccountToken(value string) (string, error)

	// LoginMicrosoft handles logging into a new Microsoft account
	//
	// The Manager is not responsible for persisting the account to its storage mechanism, Save should be called.
	LoginMicrosoft(promptCallback MSOPromptCallback) (*Account, error)

	Save() error
}

func NewManager

func NewManager(dataDir string, config *config.Config) (Manager, error)

type MicrosoftTokenData

type MicrosoftTokenData struct {
	UserHash string `json:"userHash"`
}

type Type

type Type string
const (
	Microsoft Type = "microsoft"
	Mojang    Type = "mojang"
)

func ParseType

func ParseType(s string) (Type, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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