credentials

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChatGPTCredentialsExist added in v0.0.32

func ChatGPTCredentialsExist() bool

ChatGPTCredentialsExist returns true if ChatGPT credentials are stored.

func ClearChatGPTCredentials added in v0.0.32

func ClearChatGPTCredentials() error

ClearChatGPTCredentials removes the stored ChatGPT credentials.

func ClearChatGPTCredentialsIfRefreshToken added in v0.0.334

func ClearChatGPTCredentialsIfRefreshToken(refreshToken string) error

ClearChatGPTCredentialsIfRefreshToken removes credentials only if they still contain the refresh token that was rejected. A concurrent refresh or login therefore cannot be deleted by a stale provider's authentication retry.

func ClearCopilotCredentials added in v0.0.34

func ClearCopilotCredentials() error

ClearCopilotCredentials removes the stored Copilot credentials.

func ClearGrokCredentials added in v0.0.404

func ClearGrokCredentials() error

func ClearGrokCredentialsIfRefreshToken added in v0.0.404

func ClearGrokCredentialsIfRefreshToken(refreshToken string) error

func CopilotCredentialsExist added in v0.0.34

func CopilotCredentialsExist() bool

CopilotCredentialsExist returns true if Copilot credentials are stored.

func GrokCredentialsExist added in v0.0.404

func GrokCredentialsExist() bool

func RefreshChatGPTCredentials added in v0.0.32

func RefreshChatGPTCredentials(creds *ChatGPTCredentials) error

RefreshChatGPTCredentials refreshes the access token using the refresh token. Remote OAuth I/O deliberately runs outside the process and file locks. A short compare-and-swap commit prevents a stale refresh from overwriting a concurrent login, logout, or refresh.

func RefreshGrokCredentials added in v0.0.404

func RefreshGrokCredentials(ctx context.Context, creds *GrokCredentials, force bool) error

func RefreshGrokCredentialsWithClient added in v0.0.404

func RefreshGrokCredentialsWithClient(ctx context.Context, creds *GrokCredentials, force bool, client GrokOAuthClient) error

func SaveChatGPTCredentials added in v0.0.32

func SaveChatGPTCredentials(creds *ChatGPTCredentials) error

SaveChatGPTCredentials saves ChatGPT OAuth credentials to storage.

func SaveCopilotCredentials added in v0.0.34

func SaveCopilotCredentials(creds *CopilotCredentials) error

SaveCopilotCredentials saves Copilot OAuth credentials to storage.

func SaveGrokCredentials added in v0.0.404

func SaveGrokCredentials(creds *GrokCredentials) error

Types

type ChatGPTCredentials added in v0.0.32

type ChatGPTCredentials struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresAt    int64  `json:"expires_at"` // Unix timestamp in seconds
	AccountID    string `json:"account_id"` // ChatGPT account ID from JWT
}

ChatGPTCredentials holds the OAuth tokens for ChatGPT

func GetChatGPTCredentials added in v0.0.32

func GetChatGPTCredentials() (*ChatGPTCredentials, error)

GetChatGPTCredentials retrieves the ChatGPT OAuth credentials from storage. Returns an error if credentials don't exist or are invalid.

func (*ChatGPTCredentials) IsExpired added in v0.0.32

func (c *ChatGPTCredentials) IsExpired() bool

IsExpired returns true if the access token is expired or will expire within 5 minutes

type CopilotCredentials added in v0.0.34

type CopilotCredentials struct {
	AccessToken string `json:"access_token"`
	ExpiresAt   int64  `json:"expires_at"` // Unix timestamp in seconds, 0 = no expiry
}

CopilotCredentials holds the OAuth token for GitHub Copilot

func GetCopilotCredentials added in v0.0.34

func GetCopilotCredentials() (*CopilotCredentials, error)

GetCopilotCredentials retrieves the Copilot OAuth credentials from storage. Returns an error if credentials don't exist or are invalid.

func (*CopilotCredentials) IsExpired added in v0.0.34

func (c *CopilotCredentials) IsExpired() bool

IsExpired returns true if the access token is expired or will expire within 5 minutes. GitHub OAuth tokens are typically long-lived, so this usually returns false.

type GrokCredentials added in v0.0.404

type GrokCredentials struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresAt    int64  `json:"expires_at"`
	AccountID    string `json:"account_id"`
}

func GetGrokCredentials added in v0.0.404

func GetGrokCredentials() (*GrokCredentials, error)

func (*GrokCredentials) IsExpired added in v0.0.404

func (c *GrokCredentials) IsExpired() bool

type GrokOAuthClient added in v0.0.404

type GrokOAuthClient interface {
	RefreshToken(context.Context, string) (*oauth.GrokTokenResponse, error)
	UserInfo(context.Context, string) (string, error)
}

Jump to

Keyboard shortcuts

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