Table of Contents

Interface IPhoneVerifier

Namespace
NuvTools.Security.Verification
Assembly
NuvTools.Security.dll

Proves that a person holds a phone number: a one-time code is sent to it, and the code the person types back is checked.

public interface IPhoneVerifier

Remarks

The provider generates, sends, stores and expires the code. The application never sees it, so it has nothing to store, compare or leak; it only asks whether what the person typed was right.

Numbers are in E.164 form (+5511987654321). E164PhoneNumber turns what a person types into that form. Both operations fail closed: a provider that cannot be reached answers Unavailable, never success.

Methods

CheckAsync(string, string, CancellationToken)

Checks the code the person typed against the one pending for the number.

Task<PhoneVerification> CheckAsync(string phoneNumber, string code, CancellationToken cancellationToken = default)

Parameters

phoneNumber string

The number in E.164 form, as it was given to StartAsync(string, PhoneVerificationChannelType, string?, CancellationToken).

code string

What the person typed.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<PhoneVerification>

Succeeded only when the code is the pending one. A code is good once: after a success the number has no code pending.

StartAsync(string, PhoneVerificationChannelType, string?, CancellationToken)

Sends a new code to the number, replacing any code still pending for it.

Task<PhoneVerification> StartAsync(string phoneNumber, PhoneVerificationChannelType channel = PhoneVerificationChannelType.Sms, string? locale = null, CancellationToken cancellationToken = default)

Parameters

phoneNumber string

The number in E.164 form.

channel PhoneVerificationChannelType

How the code reaches the person. Defaults to a text message.

locale string

The language of the message, as an IETF tag (pt-BR, en), or null for the provider's choice.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<PhoneVerification>

Whether the code was sent, and why not when it was not.