-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a14910
commit 75543c9
Showing
5 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod solution; | ||
mod task; | ||
|
||
pub use solution::*; | ||
pub use task::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use std::borrow::Cow; | ||
|
||
#[derive(serde::Deserialize, Debug)] | ||
pub struct FriendlyCaptchaSolution<'a> { | ||
pub token: Cow<'a, str>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use captcha_oxide_derive::proxy_task; | ||
use std::borrow::Cow; | ||
use url::Url; | ||
|
||
use crate::CaptchaTask; | ||
|
||
/// Represents the data required by the 2captcha API to solve a | ||
/// FriendlyCaptcha challenge | ||
/// | ||
/// # Example | ||
/// ``` | ||
/// use captcha_oxide::{CaptchaTask, captcha_types::friendly_captcha::FriendlyCaptcha}; | ||
/// | ||
/// # fn main() -> Result<(), captcha_oxide::Error> { | ||
/// let captcha = FriendlyCaptcha::builder() | ||
/// .website_url("http://someurl.com") | ||
/// .website_key("SOME_KEY") | ||
/// .build()?; | ||
/// # Ok(()) | ||
/// # } | ||
/// ``` | ||
#[proxy_task(with_proxy = "FriendlyCaptchaTask", proxyless = "FriendlyCaptchaTaskProxyless", crate = crate)] | ||
#[derive(serde::Serialize, CaptchaTask)] | ||
#[task(timeout = 20, solution = super::solution::FriendlyCaptchaSolution<'a>, crate = crate)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct FriendlyCaptcha<'a> { | ||
/// The full URL of target web page where the captcha is loaded. | ||
/// We do not open the page, so it is not a problem if it is available | ||
/// only for authenticated users | ||
#[serde(rename = "websiteURL")] | ||
#[task(builder_type = &'a str, parse_with = { fallible({ path = url::Url::parse }) })] | ||
pub(super) website_url: Url, | ||
|
||
pub(super) website_key: Cow<'a, str>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters