mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-02-11 18:58:06 -05:00
Updated javascript example usage in README.md for 2.0.0 changes.
Signed-off-by: jacobp <jacobpozaic@gmail.com>
This commit is contained in:
parent
41afb10cb5
commit
a43b18587e
30
README.md
30
README.md
@ -2,12 +2,12 @@
|
|||||||
LibreCaptcha is a framework that allows developers to create their own [CAPTCHA](https://en.wikipedia.org/wiki/CAPTCHA)s.
|
LibreCaptcha is a framework that allows developers to create their own [CAPTCHA](https://en.wikipedia.org/wiki/CAPTCHA)s.
|
||||||
The framework defines the API for a CAPTCHA generator and takes care of mundane details
|
The framework defines the API for a CAPTCHA generator and takes care of mundane details
|
||||||
such as:
|
such as:
|
||||||
* An HTTP interface for serving CAPTCHAs
|
* An HTTP interface for serving CAPTCHAs
|
||||||
* Background workers to pre-compute CAPTCHAs and to store them in a database
|
* Background workers to pre-compute CAPTCHAs and to store them in a database
|
||||||
* Managing secrets for the CAPTCHAs (tokens, expected answers, etc)
|
* Managing secrets for the CAPTCHAs (tokens, expected answers, etc)
|
||||||
* Safe re-impressions of CAPTCHA images (by creating unique tokens for every impression)
|
* Safe re-impressions of CAPTCHA images (by creating unique tokens for every impression)
|
||||||
* Garbage collection of stale CAPTCHAs
|
* Garbage collection of stale CAPTCHAs
|
||||||
* Sandboxed plugin architecture (TBD)
|
* Sandboxed plugin architecture (TBD)
|
||||||
|
|
||||||
Some sample CAPTCHA generators are included in the distribution (see below). We will continue adding more samples to the list. For quick
|
Some sample CAPTCHA generators are included in the distribution (see below). We will continue adding more samples to the list. For quick
|
||||||
deployments the samples themselves might be sufficient. Projects with more resources might want create their own CAPTCHAs
|
deployments the samples themselves might be sufficient. Projects with more resources might want create their own CAPTCHAs
|
||||||
@ -124,7 +124,7 @@ If a sufficient number of users agree on their answer to the unknown word, it is
|
|||||||
The service can be accessed using a simple HTTP API.
|
The service can be accessed using a simple HTTP API.
|
||||||
|
|
||||||
### - `/v1/captcha`: `POST`
|
### - `/v1/captcha`: `POST`
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- `level`: `String` -
|
- `level`: `String` -
|
||||||
The difficulty level of a captcha
|
The difficulty level of a captcha
|
||||||
- easy
|
- easy
|
||||||
@ -144,24 +144,24 @@ The service can be accessed using a simple HTTP API.
|
|||||||
with the `allowedSizes` config setting. Example: `size: "450x200"` which requests an image of width 450 and height
|
with the `allowedSizes` config setting. Example: `size: "450x200"` which requests an image of width 450 and height
|
||||||
200 pixels.
|
200 pixels.
|
||||||
|
|
||||||
- Returns:
|
- Returns:
|
||||||
- `id`: `String` - The uuid of the captcha generated
|
- `id`: `String` - The uuid of the captcha generated
|
||||||
|
|
||||||
|
|
||||||
### - `/v1/media`: `GET`
|
### - `/v1/media`: `GET`
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- `id`: `String` - The uuid of the captcha
|
- `id`: `String` - The uuid of the captcha
|
||||||
|
|
||||||
- Returns:
|
- Returns:
|
||||||
- `image`: `Array[Byte]` - The requested media as bytes
|
- `image`: `Array[Byte]` - The requested media as bytes
|
||||||
|
|
||||||
|
|
||||||
### - `/v1/answer`: `POST`
|
### - `/v1/answer`: `POST`
|
||||||
- Parameter:
|
- Parameter:
|
||||||
- `id`: `String` - The uuid of the captcha that needs to be solved
|
- `id`: `String` - The uuid of the captcha that needs to be solved
|
||||||
- `answer`: `String` - The answer to the captcha that needs to be validated
|
- `answer`: `String` - The answer to the captcha that needs to be validated
|
||||||
|
|
||||||
- Returns:
|
- Returns:
|
||||||
- `result`: `String` - The result after validation/checking of the answer
|
- `result`: `String` - The result after validation/checking of the answer
|
||||||
- True - If the answer is correct
|
- True - If the answer is correct
|
||||||
- False - If the answer is incorrect
|
- False - If the answer is incorrect
|
||||||
@ -173,9 +173,9 @@ The service can be accessed using a simple HTTP API.
|
|||||||
In javascript:
|
In javascript:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const resp = await fetch("/v1/captcha", {
|
const resp = await fetch("/v2/captcha", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({level: "easy", media: "image/png", "input_type" : "text"})
|
body: JSON.stringify({level: "easy", media: "image/png", "input_type" : "text", size: "350x100"})
|
||||||
})
|
})
|
||||||
|
|
||||||
const respJson = await resp.json();
|
const respJson = await resp.json();
|
||||||
@ -193,7 +193,7 @@ if (resp.ok) {
|
|||||||
|
|
||||||
|
|
||||||
// When user submits an answer it can be sent to the server for verification thusly:
|
// When user submits an answer it can be sent to the server for verification thusly:
|
||||||
const resp = await fetch("/v1/answer", {
|
const resp = await fetch("/v2/answer", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({id: captchaId, answer: "user input"})
|
body: JSON.stringify({id: captchaId, answer: "user input"})
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user