Verifies tokens of the CaptchaFox widget with siteverify, with the secret key of a site.
Create a client once with new/2 and reuse it; it holds no process and can be shared freely.
Summary
Types
@type outcome() :: {:ok, CaptchaFox.Passed.t() | CaptchaFox.Rejected.t()} | {:error, CaptchaFox.UnavailableError.t()}
@opaque t()
@type verify_option() :: {:sitekey, String.t() | nil} | {:remote_ip, String.t() | :inet.ip_address() | nil}
Functions
@spec new(String.t(), [{:timeout, pos_integer()}]) :: t()
Creates a client with the secret key of the site.
Options
:timeout- how long a verification may take in milliseconds, from connecting to siteverify to the end of its answer. Defaults to 5000.
Raises ArgumentError if the secret key is empty or no string, or the timeout is no positive integer.
@spec verify(t(), String.t() | nil, [verify_option()]) :: outcome()
Verifies a token.
Returns {:ok, %CaptchaFox.Passed{}} or {:ok, %CaptchaFox.Rejected{}} when siteverify evaluated
the token, and {:error, %CaptchaFox.UnavailableError{}} when siteverify cannot be evaluated.
An empty or nil token is rejected with missing-input-response without a request.
Options
:sitekey- the site key the token was issued for; not sent whennilor empty.:remote_ip- the IP address of the visitor, as a string or a tuple such asconn.remote_ip; not sent whennilor empty.
Raises ArgumentError if an argument has the wrong type, and RuntimeError if the operating system
provides no CA certificates to check the certificate of siteverify with.