UselessStudio / TeleOTP

Telegram Mini App that allows you to generate one-time passwords inside Telegram
https://t.me/TeleOTPAppBot
BSD 3-Clause "New" or "Revised" License
95 stars 13 forks source link
otp otp-generator telegram telegram-mini-app telegram-miniapp-contest-2023

πŸ” TeleOTP

Build Telegram bot image Telegram channel Plausible analytics Crowdin

Telegram Mini App that allows you to generate one-time 2FA passwords inside Telegram.

➑️ OPEN

✨ Features

Table of contents

βš™οΈ Setup guide

πŸ“± Mini App

TeleOTP is made with React, Typescript, and Material UI. Vite frontend tooling is used for rapid development and easy deployment.

Installing the dependencies

To begin working with the project, you should install the dependencies by running this command:

npm install

Configuring the environment

Before starting the server or building the app, make sure that your project directory has a file named .env. It should follow the .env.example file structure. You could also set these variables directly when running the app.

The app uses following environment variables:

Starting the development server

To start the development server with hot reload, run:

npm run dev

After that, the server will be accessible on http://localhost:5173/

[!NOTE] If you want the app to be accessible on your local network, you should add --host argument to the command

npm run dev -- --host

Building the app

npm run build

After a successful build, app bundle will be available in ./dist.

πŸ” CI/CD

The app is built and deployed automatically using Cloudflare Pages.

πŸ’¬ Bot

TeleOTP uses a helper bot to send user a link to the app and assist with account migration. The bot is written in Python using Python Telegram Bot library.

Starting bot

To start the bot, you have to run the main.py script with environment variables.

python main.py

Environment variables

[!NOTE] Make sure that WEBAPP_URL doesn't end with a /! It is added automatically by the bot.

Running in Docker

We recommend running the bot inside the Docker container. The latest image is available at ghcr.io/uselessstudio/teleotp-bot:main.

Example docker-compose.yml file:

services:
  bot:
    image: ghcr.io/uselessstudio/teleotp-bot:main
    restart: unless-stopped
    environment:
      - TG_APP=https://t.me/TeleOTPAppBot/app
      - WEBAPP_URL=https://uselessstudio.github.io/TeleOTP
      - TOKEN=<insert your token>

And running is as simple as:

docker compose up

πŸ” CI/CD

GitHub Actions is used to automate the building of the bot container. The workflow is defined in the bot.yml file and ran on every push to main. After a successful build, the container is published in the GitHub Container Registry.

πŸ’» Structure

πŸ›£οΈ Routing

TeleOTP uses React Router to switch between pages. Routes are specified in the main.tsx file.

✈️ Migration

TeleOTP implements the otpauth-migration URI standard. During the migration, accounts are (de)serialized using Protocol Buffers.

πŸ€— Icons and colors

All generic icons and colors for accounts are defined in the globals.tsx file. Available icons are exported in the icons const, colors are available in the colors const. Icon and Color types are provided for checking the validity of the corresponding item.

🌍 Translating

TeleOTP is officially translated only to Russian. If you have spare time and would like to help out the project, please add translations at Crowdin.

Currently supported languages:

If you need to add new strings:

  1. Modify the file src/lang/en.ts to have a new string with a descriptive key.
    1. If a string needs to have variables, put them in braces like {this}
  2. Use the useL10n() hook to get the translation.

πŸ‘‹ Acknowledgements

πŸ–ŒοΈ Content

πŸ“š Libraries used

πŸ† TeleOTP won first place in the Telegram Mini App Contest.

Designed by @lunnaholy, implemented by @LowderPlay & @lenchq with ❀️