Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrorFromCodes(codes ...string) error
- type Cache
- type Error
- type HumanityTokenExtractor
- type MapCache
- type OakBotSWAT
- type Option
- func WithCache(c Cache) Option
- func WithCookieHumanityTokenExtractor(name string) Option
- func WithDefaultCookieHumanityTokenExtractor() Option
- func WithDefaultHeaderHumanityTokenExtractor() Option
- func WithHeaderHumanityTokenExtractor(name string) Option
- func WithHumanityTokenExtractor(e HumanityTokenExtractor) Option
- func WithVerifier(v Verifier) Option
- type TemplateOption
- type TemplateOptions
- type UserData
- type Verifier
Constants ¶
View Source
const ( DefaultCookieName = "HumanityToken" DefaultHeaderName = "HumanityToken" )
Variables ¶
View Source
var ErrCacheFull = errors.New("there are too many cache records")
View Source
var ErrTokenEmpty = errors.New("cannot recover request token proving humanity: token is empty")
View Source
var Template string
Functions ¶
func NewErrorFromCodes ¶
Types ¶
type Error ¶
type Error string
const ( ErrMissingInputSecret Error = "missing-input-secret" ErrInvalidInputSecret Error = "invalid-input-secret" ErrMissingInputResponse Error = "missing-input-response" ErrInvalidInputResponse Error = "invalid-input-response" ErrBadRequest Error = "bad-request" ErrTimeoutOrDuplicate Error = "timeout-or-duplicate" ErrInternalError Error = "internal-error" )
type HumanityTokenExtractor ¶ added in v0.0.6
type MapCache ¶
type MapCache struct {
// contains filtered or unexported fields
}
type OakBotSWAT ¶ added in v0.0.6
type OakBotSWAT struct {
// contains filtered or unexported fields
}
func New ¶
func New(withOptions ...Option) (b *OakBotSWAT, err error)
func (*OakBotSWAT) Gate ¶ added in v0.0.6
func (b *OakBotSWAT) Gate(onError oakhttp.Encoder) oakhttp.Middleware
func (*OakBotSWAT) IsHuman ¶ added in v0.0.6
func (b *OakBotSWAT) IsHuman(r *http.Request) error
IsHuman returns `nil` for human agents, an Error if humanity Verifier was not passed, or an [error] for any other condition. In rare cases when you need access to user data proven by the UI library, such as the Turnstile implementation, use that Verifier directly.
func (*OakBotSWAT) Middleware ¶ added in v0.0.6
func (b *OakBotSWAT) Middleware() oakhttp.Middleware
type Option ¶
type Option func(*options) error
func WithCookieHumanityTokenExtractor ¶ added in v0.0.6
func WithDefaultCookieHumanityTokenExtractor ¶ added in v0.0.6
func WithDefaultCookieHumanityTokenExtractor() Option
func WithDefaultHeaderHumanityTokenExtractor ¶ added in v0.0.6
func WithDefaultHeaderHumanityTokenExtractor() Option
func WithHeaderHumanityTokenExtractor ¶ added in v0.0.6
func WithHumanityTokenExtractor ¶ added in v0.0.6
func WithHumanityTokenExtractor(e HumanityTokenExtractor) Option
func WithVerifier ¶
type TemplateOption ¶
type TemplateOption func(*TemplateOptions) error
func WithCookieDuration ¶
func WithCookieDuration(d time.Duration) TemplateOption
func WithCookieName ¶
func WithCookieName(name string) TemplateOption
func WithDescription ¶
func WithDescription(description string) TemplateOption
func WithErrorURL ¶
func WithErrorURL(URL string) TemplateOption
func WithLocale ¶
func WithLocale(key string) TemplateOption
func WithTitle ¶
func WithTitle(title string) TemplateOption
type TemplateOptions ¶
type TemplateOptions struct { Locale string Title string Description string ErrorURL string CookieName string CookieDuration time.Duration }
func NewTemplateOptions ¶
func NewTemplateOptions(all ...TemplateOption) (*TemplateOptions, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.