Table of Contents

Class CaptchaService

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

jsRuntime IJSRuntime

The 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

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.

public 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.

public 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.

public 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.

public 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