sessions

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sessions manages authenticated sessions for HTTP providers that require it. It handles session cookies, authentication tokens, and other state required to make authenticated requests to the provider.

Index

Constants

This section is empty.

Variables

View Source
var ErrDomainSessionNotFound = errors.New("session for domain not found")

Functions

This section is empty.

Types

type ErrCookieNotFound

type ErrCookieNotFound struct {
	CookieName string
}

func (ErrCookieNotFound) Error

func (e ErrCookieNotFound) Error() string

type Session

type Session struct {
	Domain         string `json:"domain"`
	CookieHeader   string `json:"cookie_header"`
	UserAgent      string `json:"user_agent"`
	AcquiredAtUnix int64  `json:"acquired_at_unix"`

	*httpclient.Client `json:"-"`
}

type SessionManager

type SessionManager struct {
	// Directory where the sessions should be stored or are currently stored
	CacheDir string
	// After how long should saved sessions be considered expired and hence force refresh
	SessionTTL time.Duration
	// Cookies that must exist in session for domains
	MustHaveCookies map[string][]string
	// Time to wait for clearance cookies if any
	WaitDuration time.Duration
}

func NewSessionManager

func NewSessionManager() *SessionManager

func (SessionManager) GetSession

func (m SessionManager) GetSession(domain, challengeURL string, forceRefresh bool) (Session, error)

GetSession returns a session for the specified domain. challengeURL specifies the full URL of the page containing any challenge that must be completed to obtain valid session cookies. If challengeURL is empty, it defaults to "https://<domain>".

func (*SessionManager) WithCacheDir

func (m *SessionManager) WithCacheDir(cacheDir string) *SessionManager

func (*SessionManager) WithMustHaveCookies

func (m *SessionManager) WithMustHaveCookies(domain string, cookieNames ...string) *SessionManager

func (*SessionManager) WithSessionTTL

func (m *SessionManager) WithSessionTTL(sessionTTL time.Duration) *SessionManager

func (*SessionManager) WithWaitDuration

func (m *SessionManager) WithWaitDuration(waitDuration time.Duration) *SessionManager

Jump to

Keyboard shortcuts

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