Documentation
¶
Overview ¶
Parse, classify, and persist the OpenAI ChatGPT session stored as plaintext under auth.openai-chatgpt in the global settings file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete removes auth.openai-chatgpt from the global settings file at settingsPath through the shared persistence chokepoint (logout), preserving API keys, permissions, model state, and unrelated settings. It is idempotent: with no stored session it succeeds without writing a file. Returns config.Persist's reason, error category, and error.
func Load ¶
Load reads the global settings file at settingsPath and classifies the stored OpenAI ChatGPT session relative to now, without exposing credential values. It returns StatusPresent or StatusExpired with the parsed Session, StatusNone with a zero Session when nothing is stored, or StatusInvalid with a zero Session for corrupted/unreadable/malformed state. The returned error is non-nil only for an unexpected file read failure (paired with StatusInvalid); it never carries credential content. A missing file is StatusNone, not an error.
func Write ¶
Write persists s as auth.openai-chatgpt in the global settings file at settingsPath through the shared config persistence chokepoint, so it serializes behind the same sidecar lock and atomic 0600 rewrite as permission and model writes. It returns config.Persist's reason, error category, and error; on success reason is config.ReasonNone, errCat is empty, and err is nil.
Types ¶
type Session ¶
Session is the parsed auth.openai-chatgpt state. Its fields hold the stored plaintext credential values verbatim; they must never be logged, printed, embedded in errors, or written to events or session records. ExpiresAt is the stored RFC3339 string, preserved exactly on write/read.
func (Session) ApplyRefresh ¶
ApplyRefresh returns a copy of s updated with the result of a successful token refresh. The new access token and expiry always replace the prior values; refreshToken replaces the prior token only when it is non-empty, because a refresh response that omits a rotated token means the existing refresh token stays valid and must be preserved. account_id and every other field are carried over unchanged, so a refresh never drops the account context required for ChatGPT requests. It mutates nothing on disk; the caller persists the result through Write.
type Status ¶
type Status string
Status classifies a loaded OpenAI ChatGPT session without exposing any credential-derived value. Only StatusPresent denotes a usable session; every other value is unauthenticated.
const ( // StatusNone means no session is stored: the settings file, the auth block, // or the openai-chatgpt entry is absent. StatusNone Status = "no_local_session" // StatusPresent means a complete, non-expired session is stored. StatusPresent Status = "local_session_present" // StatusExpired means the session parses but its expiry is in the past. The // parsed Session (including its refresh token) is returned so a refresh can // be attempted. StatusExpired Status = "local_session_expired" // StatusInvalid means the stored state is unusable: corrupted/unreadable // file, wrong shape, or a missing, wrong-type, empty, or non-RFC3339 field. // Treated as unauthenticated and never as a partially usable session. StatusInvalid Status = "local_session_invalid" )