Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

escwxyz/init-data-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

66 Commits

Repository files navigation

Telegram Mini Apps Init Data Parser for Rust

Crates.io Documentation License: MIT Build Status codecov

A Rust library for parsing and validating Telegram Mini Apps init data. This library helps you work with the data passed from Telegram to your Mini App, ensuring its authenticity and integrity.

Features

  • Parse init data from query string format
  • Validate init data signature using bot token
  • Support for third-party bot validation
  • Type-safe data structures
  • Comprehensive error handling
  • 100% test coverage

Installation

Add this to your Cargo.toml:

[dependencies]
init-data-rs = "0.1.2"

Usage

use init_data_rs::{validate, InitData};
fn main() -> Result<(), Box<dyn std::error::Error>> {
 let init_data = "query_id=AAHdF6IQAAAAAN0XohDhrOrc&user=%7B%22id%22%3A279058397%7D&auth_date=1662771648&hash=...";
 let bot_token = "YOUR_BOT_TOKEN";
 // Validate and parse init data
 let data: InitData = validate(init_data, bot_token, None)?;
 // Access parsed data
 if let Some(user) = data.user {
 println!("User ID: {}", user.id);
 }
 Ok(())
}

Third-party Bot Validation

use init_data_rs::validate_third_party;
let data = validate_third_party(init_data, bot_id, None)?;

Documentation

For detailed documentation, visit docs.rs/init-data-rs.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

This is a Rust port of the official Golang implementation.

About

Telegram Mini App Init Data Parser for Rust

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

Languages

AltStyle によって変換されたページ (->オリジナル) /