Table of Contents

Interface ICaptchaService

Namespace
NuvTools.Security.AspNetCore.Blazor.Captcha
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

elementId string

Id of the element hosting the widget.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

ValueTask

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

scoreKey string

Site key of the score type.

action string

Action name recorded on the assessment. Defaults to submit.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

ValueTask<string>

The token, or an empty string when the provider is unavailable.

GetCheckboxResponseAsync(string, CancellationToken)

Reads the token produced by the checkbox widget.

ValueTask<string?> GetCheckboxResponseAsync(string elementId, CancellationToken cancellationToken = default)

Parameters

elementId string

Id of the element hosting the widget.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

ValueTask<string>

The token, or an empty string when the challenge was not solved.

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

elementId string

Id of the element that hosts the widget.

checkboxKey string

Site key of the checkbox type.

scoreKey string

Site key of the score type, used to load the provider script.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

ValueTask

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

elementId string

Id of the element hosting the widget.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

ValueTask