auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteAPIKey

func DeleteAPIKey(profile string) error

DeleteAPIKey removes the API key for a profile.

func ExportAPIKey

func ExportAPIKey(apiKey string, dest ExportDestination) error

ExportAPIKey exports the API key to the specified destination.

func GetAPIKey

func GetAPIKey(profile string) (string, error)

GetAPIKey retrieves the API key for a profile, checking PE_API_KEY first.

func GetActiveProfile

func GetActiveProfile() string

GetActiveProfile returns the currently active profile name.

func GetStoredAPIKey

func GetStoredAPIKey(profile string) (string, error)

GetStoredAPIKey retrieves the API key from the credential store only, ignoring PE_API_KEY.

func InitStore

func InitStore() error

InitStore initializes the file-based credential store.

func IsInteractiveTerminal

func IsInteractiveTerminal() bool

IsInteractiveTerminal returns true if stdin is a terminal.

func ListProfiles

func ListProfiles() (profiles []string, activeProfile string, err error)

ListProfiles returns all stored profile names and the active profile.

func Login

func Login(profile, operatorID, keyTitle string, progress *LoginProgress) (string, error)

Login authenticates via browser and stores the API key for the given profile. If progress is nil, no progress messages are printed.

func SetActiveProfile

func SetActiveProfile(profile string) error

SetActiveProfile sets the active profile.

func StoreAPIKey

func StoreAPIKey(apiKey, profile string) error

StoreAPIKey stores an API key for a profile.

Types

type ExportDestination

type ExportDestination string

ExportDestination represents where to export the API key beyond the keyring.

const (
	ExportOpenClaw ExportDestination = "openclaw"
	ExportShell    ExportDestination = "shell"
	ExportNone     ExportDestination = "none"
)

func PromptExportDestination

func PromptExportDestination(in io.Reader, out io.Writer) ExportDestination

PromptExportDestination shows an interactive menu and returns the user's choice.

type LoginProgress

type LoginProgress struct {
	// OnBrowserOpen is called when the browser is about to open, with the fallback URL.
	OnBrowserOpen func(loginURL string)
	// OnWaiting is called when polling starts.
	OnWaiting func()
}

LoginProgress reports login progress to the caller.

type LoginResponse

type LoginResponse struct {
	SessionToken string    `json:"sessionToken"`
	PollSecret   string    `json:"pollSecret"`
	LoginURL     string    `json:"loginUrl"`
	ExpiresAt    time.Time `json:"expiresAt"`
	Message      string    `json:"message"`
}

type PollResponse

type PollResponse struct {
	Status string  `json:"status"`
	ApiKey *string `json:"apiKey,omitempty"`
	Error  *string `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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