Class CaptchaService
- Assembly
- NuvTools.Security.AspNetCore.Blazor.dll
Provides JavaScript interop for the adaptive CAPTCHA (Google reCAPTCHA Enterprise).
public sealed class CaptchaService : ICaptchaService, IAsyncDisposable
- Inheritance
-
CaptchaService
- Implements
- Inherited Members
Remarks
Initializes a new instance of the CaptchaService class.
Constructors
CaptchaService(IJSRuntime)
Provides JavaScript interop for the adaptive CAPTCHA (Google reCAPTCHA Enterprise).
public CaptchaService(IJSRuntime jsRuntime)
Parameters
jsRuntimeIJSRuntimeThe JavaScript runtime for interop operations.
Remarks
Initializes a new instance of the CaptchaService class.
Methods
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
DisposeCheckboxAsync(string, CancellationToken)
Releases the widget bookkeeping for the element. Call it when the host component is disposed.
public 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.
public 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.
public 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.
public 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.
public ValueTask ResetCheckboxAsync(string elementId, CancellationToken cancellationToken = default)
Parameters
elementIdstringId of the element hosting the widget.
cancellationTokenCancellationTokenToken to cancel the operation.