@telegram-auth/server / AuthDataValidator
Validates the data sent by Telegram Login Widget
See
https://core.telegram.org/widgets/login#checking-authorization
• new AuthDataValidator(«destructured»?
): AuthDataValidator
Name | Type |
---|---|
«destructured» |
AuthDataValidatorOptions |
▸ setBotToken(botToken
): AuthDataValidator
Sets the bot token to be used for validating the data
Name | Type | Description |
---|---|---|
botToken |
string |
The bot token to be used |
▸ setCrypto(subtleCrypto
): AuthDataValidator
Sets the crypto to be used for validating the data
Name | Type | Description |
---|---|---|
subtleCrypto |
SubtleCrypto |
The crypto to be used |
▸ setEncoder(encoder
): AuthDataValidator
Sets the encoder to be used for encoding the data
Name | Type | Description |
---|---|---|
encoder |
TextEncoder |
The encoder to be used |
▸ 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.
Name | Type | Description |
---|---|---|
inValidateDataAfter |
number |
The number of seconds after which the data is considered invalid. |
▸ setThrowIfEmptyData(throwIfEmptyData
): AuthDataValidator
This function sets the throwIfEmptyData property of the class.
Name | Type | Description |
---|---|---|
throwIfEmptyData |
boolean |
Whether to throw an error if the data is empty/incomplete. |
▸ validate<T
>(authDataMap
): Promise
<T
>
It takes a map of auth data received from Telegram, and returns the data if it's valid
Name | Type |
---|---|
T |
extends Object = TelegramUserData |
Name | Type | Description |
---|---|---|
authDataMap |
AuthDataMap |
The data to be validated |
Promise
<T
>
The validated data.
See
https://core.telegram.org/widgets/login#checking-authorization