2.0.3 • Published 4 months ago

@nanhanglim/validate-telegram-webapp-data v2.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Validate Telegram WebApp (Mini App) Data

npm version

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. Demo button on the left of the Attachment button, highlighted by a red box

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
2.0.3

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago