hcaptcha

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(ctx context.Context, response string) (bool, error)

Verify calls hCaptcha API to verify token

func WithContext added in v1.19.0

func WithContext(ctx context.Context) func(*Client)

WithContext sets the context.Context of a Client

func WithHTTP added in v1.19.0

func WithHTTP(httpClient *http.Client) func(*Client)

WithHTTP sets the http.Client of a Client

Types

type Client added in v1.19.0

type Client struct {
	// contains filtered or unexported fields
}

Client is an hCaptcha client

func New added in v1.19.0

func New(secret string, options ...ClientOption) (*Client, error)

New returns a new hCaptcha Client

func (*Client) Verify added in v1.19.0

func (c *Client) Verify(token string, opts PostOptions) (*Response, error)

Verify checks the response against the hCaptcha API

type ClientOption added in v1.19.0

type ClientOption func(*Client)

ClientOption is a func to modify a new Client

type ErrorCode added in v1.19.0

type ErrorCode string

ErrorCode is any possible error from hCaptcha

const (
	ErrMissingInputSecret           ErrorCode = "missing-input-secret"
	ErrInvalidInputSecret           ErrorCode = "invalid-input-secret"
	ErrMissingInputResponse         ErrorCode = "missing-input-response"
	ErrInvalidInputResponse         ErrorCode = "invalid-input-response"
	ErrBadRequest                   ErrorCode = "bad-request"
	ErrInvalidOrAlreadySeenResponse ErrorCode = "invalid-or-already-seen-response"
	ErrNotUsingDummyPasscode        ErrorCode = "not-using-dummy-passcode"
	ErrSitekeySecretMismatch        ErrorCode = "sitekey-secret-mismatch"
)

func (ErrorCode) Error added in v1.19.0

func (err ErrorCode) Error() string

Error fulfills the error interface

func (ErrorCode) String added in v1.19.0

func (err ErrorCode) String() string

String fulfills the Stringer interface

type PostOptions added in v1.19.0

type PostOptions struct {
	RemoteIP string
	Sitekey  string
}

PostOptions are optional post form values

type Response added in v1.19.0

type Response struct {
	Success     bool        `json:"success"`
	ChallengeTS string      `json:"challenge_ts"`
	Hostname    string      `json:"hostname"`
	Credit      bool        `json:"credit,omitempty"`
	ErrorCodes  []ErrorCode `json:"error-codes"`
}

Response is an hCaptcha response

Jump to

Keyboard shortcuts

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