codex

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Issuer       = "https://auth.openai.com"
	ClientID     = "app_EMoamEEZ73f0CkXaXp7hrann"
	LoginTimeout = 10 * time.Minute
)

Variables

View Source
var ErrNotLoggedIn = errors.New("codex: account disconnected; run sol auth login ENTRY --method codex")

Functions

This section is empty.

Types

type Access

type Access struct{ Token, AccountID, ComputeResidency string }

Access contains the current bearer token and its Codex routing metadata.

type Client

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

Client implements device authentication and a refreshable Source.

func NewClient

func NewClient(opts ClientOptions) (*Client, error)

NewClient validates explicit dependencies without accessing the store.

func (*Client) Access

func (c *Client) Access(ctx context.Context) (Access, error)

Access reloads credentials under the store's transaction lock. Refresh token rotation is committed before another process may refresh or send a request.

func (*Client) CompleteDeviceAuth

func (c *Client) CompleteDeviceAuth(ctx context.Context, device DeviceAuthorization) (Credential, error)

CompleteDeviceAuth is bounded even when the caller has no deadline. It returns credentials without persisting them; callers explicitly commit successful login.

func (*Client) StartDeviceAuth

func (c *Client) StartDeviceAuth(ctx context.Context) (DeviceAuthorization, error)

StartDeviceAuth creates a device attempt and returns the browser instructions.

type ClientOptions

type ClientOptions struct {
	HTTPClient *http.Client
	Issuer     string
	ClientID   string
	UserAgent  string
	// Store must also implement RefreshStore so accepted token rotations can
	// commit independently of caller cancellation.
	Store Store
}

ClientOptions requires an explicit HTTP client, protocol identity and store. HTTP issuer URLs support local test servers; production uses Issuer.

type Credential

type Credential = localconfig.OAuthCredential

type CredentialStore

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

CredentialStore scopes all credential operations to one named OpenAI account.

func NewStore

func NewStore(store localconfig.Store, entry string) (*CredentialStore, error)

func (*CredentialStore) Load

func (*CredentialStore) Update

func (s *CredentialStore) Update(ctx context.Context, change func(*Credential) (*Credential, error)) (*Credential, error)

func (*CredentialStore) UpdateRefresh

func (s *CredentialStore) UpdateRefresh(ctx context.Context, change func(*Credential) (*Credential, error)) (*Credential, error)

type DeviceAuthorization

type DeviceAuthorization struct {
	DeviceAuthID    string
	UserCode        string
	VerificationURL string
	PollInterval    time.Duration
}

DeviceAuthorization is a transient login attempt, never a persisted credential.

type RefreshStore

type RefreshStore interface {
	Store
	UpdateRefresh(context.Context, func(*Credential) (*Credential, error)) (*Credential, error)
}

type Source

type Source interface {
	Access(context.Context) (Access, error)
}

Source supplies credentials explicitly at the request boundary.

type Store

type Store interface {
	Load(context.Context) (Credential, error)
	Update(context.Context, func(*Credential) (*Credential, error)) (*Credential, error)
}

Jump to

Keyboard shortcuts

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