Documentation
¶
Index ¶
- func ClearAllCredentials() error
- func FormatWalletAddress(address string) string
- func GenerateRandomString(length int) (string, error)
- func GetCredentialsPath() (string, error)
- func GetDefaultGatewayURL() string
- func HasValidCredentials() (bool, error)
- func HasValidEnhancedCredentials() (bool, error)
- func SaveCredentialsForDefaultGateway(creds *Credentials) error
- func ValidateWalletAddress(address string) bool
- type AuthChoice
- type AuthServer
- type CredentialStore
- func (store *CredentialStore) GetCredentialsForGateway(gatewayURL string) (*Credentials, bool)
- func (store *CredentialStore) RemoveCredentialsForGateway(gatewayURL string)
- func (store *CredentialStore) SaveCredentials() error
- func (store *CredentialStore) SetCredentialsForGateway(gatewayURL string, creds *Credentials)
- type Credentials
- type EnhancedCredentialStore
- func (store *EnhancedCredentialStore) AddCredential(gatewayURL string, creds *Credentials)
- func (store *EnhancedCredentialStore) ClearAllCredentials()
- func (store *EnhancedCredentialStore) DisplayCredentialMenu(gatewayURL string) (AuthChoice, int, error)
- func (store *EnhancedCredentialStore) GetDefaultCredential(gatewayURL string) *Credentials
- func (store *EnhancedCredentialStore) Save() error
- func (store *EnhancedCredentialStore) SetDefaultCredential(gatewayURL string, index int) bool
- type GatewayCredentials
- type WalletAuthResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearAllCredentials ¶
func ClearAllCredentials() error
ClearAllCredentials removes all stored credentials
func FormatWalletAddress ¶
FormatWalletAddress formats a wallet address consistently
func GenerateRandomString ¶
GenerateRandomString generates a cryptographically secure random string
func GetCredentialsPath ¶
GetCredentialsPath returns the path to the credentials file
func GetDefaultGatewayURL ¶
func GetDefaultGatewayURL() string
GetDefaultGatewayURL returns the default gateway URL from environment or fallback
func HasValidCredentials ¶
HasValidCredentials checks if there are valid credentials for the default gateway
func HasValidEnhancedCredentials ¶
HasValidEnhancedCredentials checks if there are valid credentials for the default gateway
func SaveCredentialsForDefaultGateway ¶
func SaveCredentialsForDefaultGateway(creds *Credentials) error
SaveCredentialsForDefaultGateway saves credentials for the default gateway
func ValidateWalletAddress ¶
ValidateWalletAddress validates that a wallet address is properly formatted
Types ¶
type AuthChoice ¶
type AuthChoice int
AuthChoice represents user's choice during authentication
const ( AuthChoiceUseCredential AuthChoice = iota AuthChoiceAddCredential AuthChoiceLogout AuthChoiceExit )
type AuthServer ¶
type AuthServer struct {
// contains filtered or unexported fields
}
AuthServer handles the local HTTP server for receiving auth callbacks
func NewAuthServer ¶
func NewAuthServer() (*AuthServer, error)
NewAuthServer creates a new authentication callback server
func (*AuthServer) Close ¶
func (as *AuthServer) Close() error
Close shuts down the authentication server
func (*AuthServer) GetPort ¶
func (as *AuthServer) GetPort() int
GetPort returns the port the server is listening on
type CredentialStore ¶
type CredentialStore struct {
Gateways map[string]*Credentials `json:"gateways"`
Version string `json:"version"`
}
CredentialStore manages credentials for multiple gateways
func LoadCredentials ¶
func LoadCredentials() (*CredentialStore, error)
LoadCredentials loads credentials from ~/.debros/credentials.json
func (*CredentialStore) GetCredentialsForGateway ¶
func (store *CredentialStore) GetCredentialsForGateway(gatewayURL string) (*Credentials, bool)
GetCredentialsForGateway returns credentials for a specific gateway URL
func (*CredentialStore) RemoveCredentialsForGateway ¶
func (store *CredentialStore) RemoveCredentialsForGateway(gatewayURL string)
RemoveCredentialsForGateway removes credentials for a specific gateway URL
func (*CredentialStore) SaveCredentials ¶
func (store *CredentialStore) SaveCredentials() error
SaveCredentials saves credentials to ~/.debros/credentials.json
func (*CredentialStore) SetCredentialsForGateway ¶
func (store *CredentialStore) SetCredentialsForGateway(gatewayURL string, creds *Credentials)
SetCredentialsForGateway stores credentials for a specific gateway URL
type Credentials ¶
type Credentials struct {
APIKey string `json:"api_key"`
RefreshToken string `json:"refresh_token,omitempty"`
Namespace string `json:"namespace"`
UserID string `json:"user_id,omitempty"`
Wallet string `json:"wallet,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
IssuedAt time.Time `json:"issued_at"`
LastUsedAt time.Time `json:"last_used_at,omitempty"`
Plan string `json:"plan,omitempty"`
}
Credentials represents authentication credentials for a specific gateway
func GetOrPromptForCredentials ¶
func GetOrPromptForCredentials(gatewayURL string) (*Credentials, error)
GetOrPromptForCredentials handles the complete authentication flow
func GetValidEnhancedCredentials ¶
func GetValidEnhancedCredentials() (*Credentials, error)
GetValidEnhancedCredentials returns valid credentials for the default gateway
func PerformSimpleAuthentication ¶ added in v0.69.13
func PerformSimpleAuthentication(gatewayURL string) (*Credentials, error)
PerformSimpleAuthentication performs a simple authentication flow where the user provides a wallet address and receives an API key without signature verification
func PerformWalletAuthentication ¶
func PerformWalletAuthentication(gatewayURL string) (*Credentials, error)
PerformWalletAuthentication starts the complete wallet authentication flow
func (*Credentials) IsExpired ¶
func (creds *Credentials) IsExpired() bool
IsExpired checks if credentials are expired
func (*Credentials) IsValid ¶
func (creds *Credentials) IsValid() bool
IsValid checks if credentials are valid (not empty and not expired)
func (*Credentials) UpdateLastUsed ¶
func (creds *Credentials) UpdateLastUsed()
UpdateLastUsed updates the last used timestamp
type EnhancedCredentialStore ¶
type EnhancedCredentialStore struct {
Gateways map[string]*GatewayCredentials `json:"gateways"`
Version string `json:"version"`
}
EnhancedCredentialStore manages multiple credentials per gateway
func LoadEnhancedCredentials ¶
func LoadEnhancedCredentials() (*EnhancedCredentialStore, error)
LoadEnhancedCredentials loads the enhanced credential store, with migration support from legacy v2.0 format
func (*EnhancedCredentialStore) AddCredential ¶
func (store *EnhancedCredentialStore) AddCredential(gatewayURL string, creds *Credentials)
AddCredential adds a new credential for the gateway
func (*EnhancedCredentialStore) ClearAllCredentials ¶
func (store *EnhancedCredentialStore) ClearAllCredentials()
ClearAllCredentials removes all credentials
func (*EnhancedCredentialStore) DisplayCredentialMenu ¶
func (store *EnhancedCredentialStore) DisplayCredentialMenu(gatewayURL string) (AuthChoice, int, error)
DisplayCredentialMenu shows the interactive credential selection menu
func (*EnhancedCredentialStore) GetDefaultCredential ¶
func (store *EnhancedCredentialStore) GetDefaultCredential(gatewayURL string) *Credentials
GetDefaultCredential returns the default credential for a gateway
func (*EnhancedCredentialStore) Save ¶
func (store *EnhancedCredentialStore) Save() error
Save saves the enhanced credential store
func (*EnhancedCredentialStore) SetDefaultCredential ¶
func (store *EnhancedCredentialStore) SetDefaultCredential(gatewayURL string, index int) bool
SetDefaultCredential sets the default credential by index
type GatewayCredentials ¶
type GatewayCredentials struct {
Credentials []*Credentials `json:"credentials"`
DefaultIndex int `json:"default_index"`
LastUsedIndex int `json:"last_used_index"`
}
GatewayCredentials holds multiple credentials for a single gateway
type WalletAuthResult ¶
type WalletAuthResult struct {
APIKey string `json:"api_key"`
RefreshToken string `json:"refresh_token,omitempty"`
Namespace string `json:"namespace"`
Wallet string `json:"wallet"`
Plan string `json:"plan,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
}
WalletAuthResult represents the result of wallet authentication