pub struct JsChallengeManager { /* private fields */ }Expand description
Thread-safe JavaScript challenge manager
Implementations§
Source§impl JsChallengeManager
impl JsChallengeManager
Sourcepub fn new(config: JsChallengeConfig) -> Self
pub fn new(config: JsChallengeConfig) -> Self
Create a new JS challenge manager with the given configuration
Sourcepub fn config(&self) -> &JsChallengeConfig
pub fn config(&self) -> &JsChallengeConfig
Get the configuration
Sourcepub fn generate_pow_challenge(&self, actor_id: &str) -> JsChallenge
pub fn generate_pow_challenge(&self, actor_id: &str) -> JsChallenge
Generate a PoW challenge for an actor
Sourcepub fn validate_pow(&self, actor_id: &str, nonce: &str) -> ValidationResult
pub fn validate_pow(&self, actor_id: &str, nonce: &str) -> ValidationResult
Validate a PoW solution
Sourcepub fn generate_challenge_page(&self, challenge: &JsChallenge) -> String
pub fn generate_challenge_page(&self, challenge: &JsChallenge) -> String
Generate the challenge HTML page
Sourcepub fn get_attempts(&self, actor_id: &str) -> u32
pub fn get_attempts(&self, actor_id: &str) -> u32
Get attempt count for an actor
Sourcepub fn has_challenge(&self, actor_id: &str) -> bool
pub fn has_challenge(&self, actor_id: &str) -> bool
Check if actor has active challenge
Sourcepub fn get_challenge(&self, actor_id: &str) -> Option<JsChallenge>
pub fn get_challenge(&self, actor_id: &str) -> Option<JsChallenge>
Get active challenge for actor
Sourcepub fn start_cleanup(self: Arc<Self>)
pub fn start_cleanup(self: Arc<Self>)
Start background cleanup task.
Spawns a background task that periodically removes expired challenges.
The task will exit cleanly when shutdown() is called.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Signal shutdown for background tasks.
This method signals the background cleanup task to stop. The task will exit after completing any in-progress work.
Sourcepub fn cleanup_expired(&self) -> usize
pub fn cleanup_expired(&self) -> usize
Remove expired challenges
Sourcepub fn stats(&self) -> &JsChallengeStats
pub fn stats(&self) -> &JsChallengeStats
Get statistics
Trait Implementations§
Source§impl Interrogator for JsChallengeManager
impl Interrogator for JsChallengeManager
Source§fn challenge_level(&self) -> u8
fn challenge_level(&self) -> u8
Challenge level (1-5, lower = softer)
Source§fn generate_challenge(&self, actor_id: &str) -> ChallengeResponse
fn generate_challenge(&self, actor_id: &str) -> ChallengeResponse
Generate a challenge for the actor
Source§fn validate_response(&self, actor_id: &str, response: &str) -> ValidationResult
fn validate_response(&self, actor_id: &str, response: &str) -> ValidationResult
Validate a challenge response
Source§fn should_escalate(&self, actor_id: &str) -> bool
fn should_escalate(&self, actor_id: &str) -> bool
Check if actor should escalate to next level
Auto Trait Implementations§
impl !Freeze for JsChallengeManager
impl !RefUnwindSafe for JsChallengeManager
impl Send for JsChallengeManager
impl Sync for JsChallengeManager
impl Unpin for JsChallengeManager
impl UnsafeUnpin for JsChallengeManager
impl UnwindSafe for JsChallengeManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more