Skip to content

Latest commit

 

History

History
185 lines (104 loc) · 4.74 KB

AuthDataValidator.md

File metadata and controls

185 lines (104 loc) · 4.74 KB

@telegram-auth/server / AuthDataValidator

Class: AuthDataValidator

Validates the data sent by Telegram Login Widget

See

https://core.telegram.org/widgets/login#checking-authorization

Table of contents

Constructors

Methods

Constructors

constructor

new AuthDataValidator(«destructured»?)

Parameters

Name Type
«destructured» AuthDataValidatorOptions

Defined in

AuthDataValidator.ts:55

Methods

setBotToken

setBotToken(botToken): AuthDataValidator

Sets the bot token to be used for validating the data

Parameters

Name Type Description
botToken string The bot token to be used

Returns

AuthDataValidator

Defined in

AuthDataValidator.ts:96


setCrypto

setCrypto(subtleCrypto): AuthDataValidator

Sets the crypto to be used for validating the data

Parameters

Name Type Description
subtleCrypto SubtleCrypto The crypto to be used

Returns

AuthDataValidator

Defined in

AuthDataValidator.ts:107


setEncoder

setEncoder(encoder): AuthDataValidator

Sets the encoder to be used for encoding the data

Parameters

Name Type Description
encoder TextEncoder The encoder to be used

Returns

AuthDataValidator

Defined in

AuthDataValidator.ts:118


setInValidateDataAfter

setInValidateDataAfter(inValidateDataAfter): AuthDataValidator

This function sets the inValidateDataAfter property of the class which is the number of seconds after which the data is considered invalid.

Parameters

Name Type Description
inValidateDataAfter number The number of seconds after which the data is considered invalid.

Returns

AuthDataValidator

Defined in

AuthDataValidator.ts:131


setThrowIfEmptyData

setThrowIfEmptyData(throwIfEmptyData): AuthDataValidator

This function sets the throwIfEmptyData property of the class.

Parameters

Name Type Description
throwIfEmptyData boolean Whether to throw an error if the data is empty/incomplete.

Returns

AuthDataValidator

Defined in

AuthDataValidator.ts:142


validate

validate<T>(authDataMap): Promise<T>

It takes a map of auth data received from Telegram, and returns the data if it's valid

Type parameters

Name Type
T extends Object = TelegramUserData

Parameters

Name Type Description
authDataMap AuthDataMap The data to be validated

Returns

Promise<T>

The validated data.

See

https://core.telegram.org/widgets/login#checking-authorization

Defined in

AuthDataValidator.ts:156