Interface ICaptchaService
- Assembly
- NuvTools.Security.AspNetCore.Blazor.dll
Provides JavaScript interop for the adaptive CAPTCHA (Google reCAPTCHA Enterprise).
public interface ICaptchaService : IAsyncDisposable
- Inherited Members
Remarks
When the provider script cannot be loaded, the token-producing members return an empty string rather than failing. The server treats an empty token as invalid, so the outcome is fail-closed.
Methods
DisposeCheckboxAsync(string, CancellationToken)
Releases the widget bookkeeping for the element. Call it when the host component is disposed.
ValueTask DisposeCheckboxAsync(string elementId, CancellationToken cancellationToken = default)
Parameters
elementIdstringId of the element hosting the widget.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
ExecuteAsync(string, string, CancellationToken)
Produces an invisible (score) token. Nothing is shown to the user.
ValueTask<string?> ExecuteAsync(string scoreKey, string action = "submit", CancellationToken cancellationToken = default)
Parameters
scoreKeystringSite key of the score type.
actionstringAction name recorded on the assessment. Defaults to
submit.cancellationTokenCancellationTokenToken to cancel the operation.
Returns
GetCheckboxResponseAsync(string, CancellationToken)
Reads the token produced by the checkbox widget.
ValueTask<string?> GetCheckboxResponseAsync(string elementId, CancellationToken cancellationToken = default)
Parameters
elementIdstringId of the element hosting the widget.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
RenderCheckboxAsync(string, string, string, CancellationToken)
Renders the "I'm not a robot" checkbox into the given element, as the step-up challenge.
ValueTask RenderCheckboxAsync(string elementId, string checkboxKey, string scoreKey, CancellationToken cancellationToken = default)
Parameters
elementIdstringId of the element that hosts the widget.
checkboxKeystringSite key of the checkbox type.
scoreKeystringSite key of the score type, used to load the provider script.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
ResetCheckboxAsync(string, CancellationToken)
Clears the checkbox challenge so the user can try again — the token is single-use.
ValueTask ResetCheckboxAsync(string elementId, CancellationToken cancellationToken = default)
Parameters
elementIdstringId of the element hosting the widget.
cancellationTokenCancellationTokenToken to cancel the operation.