account

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package account coordinates official-service credentials outside relay handshakes.

Index

Constants

View Source
const (
	CacheLoadTimeout = 100 * time.Millisecond
	RequestTimeout   = 8 * time.Second
	RefreshInterval  = time.Minute
	PollInterval     = 5 * time.Second
	MinimumRetry     = time.Second
	MaximumRetry     = time.Minute
	TicketMargin     = time.Minute
)

Variables

View Source
var ErrNotConfigured = errors.New("official account service is not configured")
View Source
var ErrSuperseded = errors.New("account changed while the operation was in progress")

Functions

This section is empty.

Types

type Challenge

type Challenge struct {
	ID        string `json:"id"`
	Mode      string `json:"mode"`
	Bits      uint8  `json:"bits"`
	ExpiresAt uint64 `json:"expires_at"`
}

type Config

type Config struct {
	URL         string
	Root        [32]byte
	Store       Store
	Client      HTTPClient
	Now         func() time.Time
	ResolveNode func(string) (Node, bool)
}

type Credential

type Credential struct {
	Account  [16]byte `json:"account"`
	ID       [16]byte `json:"id"`
	Secret   string   `json:"secret"`
	Username string   `json:"username,omitempty"`
}

type FileStore

type FileStore struct{ Path string }

func (FileStore) Update

func (store FileStore) Update(ctx context.Context, apply func(Record) (Record, error)) (Record, error)

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type MemoryStore

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

func (*MemoryStore) Update

func (store *MemoryStore) Update(ctx context.Context, apply func(Record) (Record, error)) (Record, error)

type Node

type Node struct{ Key [32]byte }

type Proof

type Proof struct {
	Challenge Challenge `json:"challenge"`
	Solution  string    `json:"solution"`
}

type Record

type Record struct {
	Issuer      string                       `json:"issuer"`
	SetupSecret string                       `json:"setup_secret,omitempty"`
	Credential  *Credential                  `json:"credential,omitempty"`
	Certificate string                       `json:"certificate,omitempty"`
	Ticket      string                       `json:"ticket,omitempty"`
	Entitlement serviceauthority.Entitlement `json:"entitlement"`
	Denial      string                       `json:"denial,omitempty"`
	Proof       *Proof                       `json:"proof,omitempty"`
}

type Service

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

func New

func New(config Config) (*Service, error)

func (*Service) Close

func (service *Service) Close()

func (*Service) Login

func (service *Service) Login(ctx context.Context, username, password string) error

func (*Service) RequestEmail

func (service *Service) RequestEmail(ctx context.Context, email string) error

func (*Service) Retry

func (service *Service) Retry()

func (*Service) RevokeCredential

func (service *Service) RevokeCredential(ctx context.Context, credential [16]byte) error

func (*Service) SetPassword

func (service *Service) SetPassword(ctx context.Context, username, password string) error

func (*Service) Snapshot

func (service *Service) Snapshot() (Snapshot, <-chan struct{})

func (*Service) Source

func (service *Service) Source(address string) *Source

func (*Service) Start

func (service *Service) Start()

func (*Service) VerifyEmail

func (service *Service) VerifyEmail(ctx context.Context, code string) error

type Snapshot

type Snapshot struct {
	Active         bool                       `json:"active"`
	State          State                      `json:"state"`
	Account        string                     `json:"account,omitempty"`
	Credential     string                     `json:"credential,omitempty"`
	Username       string                     `json:"username,omitempty"`
	Allowance      serviceauthority.Allowance `json:"allowance"`
	RemainingBytes uint64                     `json:"remaining_bytes"`
	ResetAt        time.Time                  `json:"reset_at"`
	ValidUntil     time.Time                  `json:"valid_until"`
	TicketExpires  time.Time                  `json:"ticket_expires"`
	RetryAt        time.Time                  `json:"retry_at"`
	Hashes         uint64                     `json:"hashes,omitempty"`
	ProofElapsed   time.Duration              `json:"proof_elapsed,omitempty"`
	Reason         string                     `json:"reason,omitempty"`
}

type Source

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

func (*Source) RegistrationAuthorization

func (source *Source) RegistrationAuthorization() serviceauthority.RegistrationAuthorization

type State

type State string
const (
	Pending       State = "pending_setup"
	Verifying     State = "proof_of_work"
	EmailRequired State = "email_required"
	Ready         State = "ready"
	Refreshing    State = "refreshing"
	Unavailable   State = "temporarily_unavailable"
	Denied        State = "denied"
)

type Store

type Store interface {
	Update(context.Context, func(Record) (Record, error)) (Record, error)
}

Jump to

Keyboard shortcuts

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