state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultPath = ".mcp-oauth-cli/state.json"

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(secret string) string

func Redacted

func Redacted(secret string) string

func Save

func Save(path string, st *State) error

func SetServerInstructions

func SetServerInstructions(st *State, instructions string)

func SetToken

func SetToken(st *State, tok TokenState)

func SetTools

func SetTools(st *State, tools []*mcp.Tool)

Types

type AuthorizationState

type AuthorizationState struct {
	AuthURL    string    `json:"auth_url,omitempty"`
	Code       string    `json:"code,omitempty"`
	State      string    `json:"state,omitempty"`
	ReceivedAt time.Time `json:"received_at,omitempty"`
}

type CallRecord

type CallRecord struct {
	Method    string    `json:"method"`
	OK        bool      `json:"ok"`
	Summary   string    `json:"summary,omitempty"`
	Error     string    `json:"error,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

type ClientState

type ClientState struct {
	Mode                    string                              `json:"mode,omitempty"`
	ClientID                string                              `json:"client_id,omitempty"`
	ClientSecret            string                              `json:"client_secret,omitempty"`
	TokenEndpointAuthMethod string                              `json:"token_endpoint_auth_method,omitempty"`
	Registration            *oauthex.ClientRegistrationResponse `json:"registration,omitempty"`
}

type DiscoveryState

type DiscoveryState struct {
	ServerURL  string                  `json:"server_url,omitempty"`
	Protected  *ProtectedResourceState `json:"protected_resource,omitempty"`
	AuthServer *oauthex.AuthServerMeta `json:"auth_server,omitempty"`
}

type OldRefreshTokenCheck

type OldRefreshTokenCheck struct {
	HistoryIndex          int       `json:"history_index"`
	OriginalReceivedAt    time.Time `json:"original_received_at,omitempty"`
	RefreshFingerprint    string    `json:"refresh_fingerprint,omitempty"`
	Usable                bool      `json:"usable"`
	NewAccessFingerprint  string    `json:"new_access_fingerprint,omitempty"`
	NewRefreshFingerprint string    `json:"new_refresh_fingerprint,omitempty"`
	RefreshTokenRotated   bool      `json:"refresh_token_rotated"`
	RefreshTokenReused    bool      `json:"refresh_token_reused"`
	Error                 string    `json:"error,omitempty"`
	CheckedAt             time.Time `json:"checked_at"`
}

type ProtectedResourceState

type ProtectedResourceState struct {
	MetadataURL string                             `json:"metadata_url,omitempty"`
	Metadata    *oauthex.ProtectedResourceMetadata `json:"metadata,omitempty"`
}

type RotationAttempt

type RotationAttempt struct {
	Iteration         int       `json:"iteration"`
	BeforeFingerprint string    `json:"before_fingerprint,omitempty"`
	AfterFingerprint  string    `json:"after_fingerprint,omitempty"`
	Rotated           bool      `json:"rotated"`
	Error             string    `json:"error,omitempty"`
	CreatedAt         time.Time `json:"created_at"`
}

type State

type State struct {
	RedirectURL          string                 `json:"redirect_url,omitempty"`
	Discovery            *DiscoveryState        `json:"discovery,omitempty"`
	Client               *ClientState           `json:"client,omitempty"`
	Authorization        *AuthorizationState    `json:"authorization,omitempty"`
	CurrentToken         *TokenState            `json:"current_token,omitempty"`
	PreviousTokens       []TokenState           `json:"previous_tokens,omitempty"`
	Tools                []*mcp.Tool            `json:"tools,omitempty"`
	ToolsListedAt        time.Time              `json:"tools_listed_at,omitempty"`
	ServerInstructions   string                 `json:"server_instructions,omitempty"`
	ServerInstructionsAt time.Time              `json:"server_instructions_at,omitempty"`
	Calls                []CallRecord           `json:"calls,omitempty"`
	RotationAttempts     []RotationAttempt      `json:"rotation_attempts,omitempty"`
	OldRefreshChecks     []OldRefreshTokenCheck `json:"old_refresh_checks,omitempty"`
}

func Load

func Load(path string) (*State, error)

func RedactState

func RedactState(st *State) *State

func (*State) RequireAuthServer

func (s *State) RequireAuthServer() error

func (*State) RequireClient

func (s *State) RequireClient() error

func (*State) RequireServer

func (s *State) RequireServer() error

func (*State) RequireToken

func (s *State) RequireToken() error

type TokenState

type TokenState struct {
	AccessToken        string          `json:"access_token,omitempty"`
	TokenType          string          `json:"token_type,omitempty"`
	RefreshToken       string          `json:"refresh_token,omitempty"`
	Expiry             time.Time       `json:"expiry,omitempty"`
	Scope              string          `json:"scope,omitempty"`
	AccessFingerprint  string          `json:"access_fingerprint,omitempty"`
	RefreshFingerprint string          `json:"refresh_fingerprint,omitempty"`
	ReceivedAt         time.Time       `json:"received_at,omitempty"`
	Raw                json.RawMessage `json:"raw,omitempty"`
}

func RedactToken

func RedactToken(tok *TokenState) *TokenState

func (*TokenState) EffectiveAccessFingerprint

func (t *TokenState) EffectiveAccessFingerprint() string

func (*TokenState) EffectiveRefreshFingerprint

func (t *TokenState) EffectiveRefreshFingerprint() string

Jump to

Keyboard shortcuts

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