6c5ab6c36b7af7840004527384bbb5e21bb5032a
[akkoma] / lib / pleroma / captcha / captcha_service.ex
1 defmodule Pleroma.Captcha.Service do
2 @doc """
3 Request new captcha from a captcha service.
4
5 Returns:
6
7 Type/Name of the service, the token to identify the captcha,
8 the data of the answer and service-specific data to use the newly created captcha
9 """
10 @callback new() :: %{
11 type: atom(),
12 token: String.t(),
13 answer_data: any()
14 }
15
16 @doc """
17 Validated the provided captcha solution.
18
19 Arguments:
20 * `token` the captcha is associated with
21 * `captcha` solution of the captcha to validate
22 * `answer_data` is the data needed to validate the answer (presumably encrypted)
23
24 Returns:
25
26 `true` if captcha is valid, `false` if not
27 """
28 @callback validate(
29 token :: String.t(),
30 captcha :: String.t(),
31 answer_data :: any()
32 ) :: :ok | {:error, String.t()}
33 end