Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Type string `json:"type"` // Account type (e.g. "Xbox"). ID string `json:"id"` // Account ID. AuthData *string `json:"authData,omitempty"` // Encoded account data. Properties map[string]string `json:"properties"` // Account properties (like avatar or display name). Authorization *Authorization `json:"-"` // Authorization data. }
type AuthFlow ¶
type AuthFlow[I IntermediateState] struct { AccountType string // Accounts type this flow creates. Steps []FlowStep[I] // Every step of the flow to run sequentially. InitialState I // Initial state for every flow run. }
AuthFlow represents an authentication flow. It is used to authenticate new or refresh existing accounts.
func (*AuthFlow[I]) CreateAccount ¶
CreateAccount creates a new account of type specified by the flow.
func (*AuthFlow[I]) RefreshAccount ¶
RefreshAccount refreshes an existing account of type specified by the flow.
type Authorization ¶
type FlowState ¶
type FlowState[I IntermediateState] struct { Account *Account // Account which being authenticated. IntermediateState *I // Shared state between every step of the flow. }
FlowState represents a mutable structure that represents current authentication flow state. It is always passed by reference and supposed to be modified by every authentication step.
type FlowStep ¶
type FlowStep[I IntermediateState] interface { ID() string // ID returns flow step identifier. Authorize(state *FlowState[I]) error // Authorize performs authorization. Refresh(state *FlowState[I]) error // Refresh refreshes the existing token. }
FlowStep represents an authentication step.
type IntermediateState ¶
type IntermediateState interface{}
IntermediateState represents an intermediate state within authentication flow, it can be anything that helps get authentication done, and can be modified throughout the flow.
For example, Xbox authentication stores Authentication data in it, which gets modified with every step adding new data, such as Xbox Live token, Minecraft token. In the end this authentication data gets stored with new account.
type StepError ¶
type StepError struct { StepID string // Identifier of the step that failed. Err error // Error that occurred during running of this step. }
StepError represents an error that occurred during the authentication flow.
type Store ¶
type Store struct { Accounts map[string]Account `json:"accounts"` // Accounts mapped by their IDs. SelectedAccount string `json:"selectedAccount,omitempty"` // ID of the selected account. }
func (*Store) AddAccount ¶
func (*Store) GetSelectedAccount ¶
GetSelectedAccount returns the reference to the selected account or nil if no account is selected.
func (*Store) RemoveAccount ¶
type StoreFile ¶
type StoreFile struct { Store // contains filtered or unexported fields }