@nanhanglim/validate-telegram-webapp-data
v2.0.3
Published
to validate data received via telegram web app
Downloads
61
Readme
Validate Telegram WebApp (Mini App) Data
Library to validate Telegram WebApp (Mini App) Data
Installation
npm i --save @nanhanglim/validate-telegram-webapp-data
Demo
Start a chat with @WebAppDataDemoBot on Telegram and tap on the "Demo" button.
Usage
// import library
import ValidateTelegramWebAppData from "@nanhanglim/validate-telegram-webapp-data";
// initialise instance
const VTWAD = new ValidateTelegramWebAppData('BOT_TOKEN_HERE');
...
// check if data is valid/not expired
const validate = VTWAD.ValidateData(initData, 3600); // 1 hour
const isValid = validate.isValid; // boolean
const data = validate.data; // parsed initData in object
You may also set secondsToExpire
to 0 to ignore expiry check
const validate = VTWAD.ValidateData(initData, 0); // never expires
const isValid = validate.isValid; // boolean
const data = validate.data; // parsed initData in object