| Crates.io | hcaptcha-no-wasm |
| lib.rs | hcaptcha-no-wasm |
| version | 3.0.1 |
| created_at | 2024-12-14 16:34:38.811937+00 |
| updated_at | 2024-12-14 16:42:34.105531+00 |
| description | hCaptcha client response verification. Validate the hCaptcha response submitted from to your server from the client. |
| homepage | |
| repository | https://github.com/jerusdp/hcaptcha-rs |
| max_upload_size | |
| id | 1483252 |
| size | 218,213 |
The rust library hcaptcha is used with your backend service to verify the hcaptcha response provided from the client.
This fork doesn't implement wasm as a target in order to keep the types Send.
To use hcaptcha, add the following to your Cargo.toml:
[dependencies]
hcaptcha-no-wasm = "3.0.0"
Hcaptcha prefix has been removed from all types.rustls-backend and not the nativetls-backend.verify_client_response method has been deprecated in favour or the verify method.Derive a validation method on the data structure representing your data, marking the captcha components in the data structure.
# use hcaptcha_no_wasm::Hcaptcha;
#[derive(Debug, Deserialize, Hcaptcha)]
pub struct ContactForm {
name: String,
phone: String,
email: String,
message: String,
#[captcha]
token: String,
}
Validate the captcha data.
# #[tokio::main]
# async main() -> Result<(), Box<dyn std::error::Error>> {
let contact_form: ContactForm = serde_json::from_str(e.body_string())?;
contact_form.valid_response(&secret, None).await?;
# }
# fn get_your_secret() -> String {
# "0x123456789abcde0f123456789abcdef012345678".to_string()
# }
See the examples folder for an AWS Lambda contact form example.
Hcaptcha has been tested in a web assembly project using wasm-bindgen and node.
See the hcaptcha-wasm example for a sample project which can be run using wasm-pack test --node.
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Initial version based on recaptcha-rs by panicbit.