store

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateName added in v0.3.0

func ValidateName(name string) error

Types

type Check

type Check struct {
	Message string
	Warning bool
}

type DaemonState added in v0.2.1

type DaemonState struct {
	daemon.Status
	// Stale means running and started before auth.json last changed.
	Stale bool
	// Profile is "" if the change signed Codex out.
	Profile string
}

type Identity added in v0.2.0

type Identity struct {
	AuthMode    string `json:"auth_mode,omitempty"`
	AccountID   string `json:"account_id,omitempty"`
	Email       string `json:"email,omitempty"`
	Plan        string `json:"plan,omitempty"`
	LastRefresh string `json:"last_refresh,omitempty"`
}

Identity never carries tokens or API keys, so it is safe to print.

type Profile added in v0.2.0

type Profile struct {
	Name     string `json:"name"`
	Selected bool   `json:"selected"`
	Valid    bool   `json:"valid"`
	Identity
}

type Result added in v0.3.1

type Result struct {
	// Profile is the new name for a rename.
	Profile  string
	Warnings []string
	// AuthChanged includes finishing an interrupted switch.
	AuthChanged bool
}

type Store

type Store struct {
	CodexHome string
	StateHome string
	// DetectDaemon is daemon.Detect when nil.
	DetectDaemon func(codexHome string) daemon.Status
}

func NewFromEnvironment

func NewFromEnvironment() (*Store, error)

func (*Store) AuthPath added in v0.3.0

func (s *Store) AuthPath() string

func (*Store) Current

func (s *Store) Current() (string, bool, error)

func (*Store) Daemon added in v0.2.1

func (s *Store) Daemon() DaemonState

func (*Store) Doctor

func (s *Store) Doctor() []Check

func (*Store) Import added in v0.2.0

func (s *Store) Import(name string) (Result, error)

Import is for accounts logged in with plain `codex login`.

func (*Store) List

func (s *Store) List() ([]string, string, error)

func (*Store) Login

func (s *Store) Login(name string, runLogin func(home string) error) (Result, error)

func (*Store) Logout added in v0.2.0

func (s *Store) Logout(name string, runLogout func(home string) error) (Result, error)

Logout revokes the session in an isolated home, then deletes the profile and an active auth.json of the same account.

func (*Store) Profiles added in v0.2.0

func (s *Store) Profiles() ([]Profile, error)

func (*Store) Purge added in v0.3.0

func (s *Store) Purge(before func() error) error

Purge leaves the Codex home alone. before runs under the lock; if it fails nothing is removed.

func (*Store) Remove added in v0.2.0

func (s *Store) Remove(name string) (Result, error)

Remove leaves the active auth.json, so Codex stays logged in.

func (*Store) Rename added in v0.2.0

func (s *Store) Rename(oldName, newName string) (Result, error)

Rename does not touch the active auth.json.

func (*Store) Show added in v0.2.0

func (s *Store) Show(name string) (Profile, error)

func (*Store) Sync added in v0.2.0

func (s *Store) Sync() (Result, error)

func (*Store) Use

func (s *Store) Use(name string) (Result, error)

Jump to

Keyboard shortcuts

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