Using this library in production? Let me know on Telegram (@bcrypt) and I'll be glad to list your project here.
This library lets you parse and use requested data from Telegram Passport that's sent to your bot. (It has no dependencies, too!)
First, create a
TelegramPassport object with your private key.
const TelegramPassport =const passport = yourPrivateKey // The private key must be PEM-encoded
After this, you are ready to decrypt payloads. To decrypt a
PassportData object from Telegram, use the
// Obtain passportData through some meansvar decryptedData = passport
Here is an example of what the
decrypt method will return for the scopes
Files are returned differently than the
PassportFile object. Every file returned by this library is in this format:
To download a file, call
getFile like normal with the file ID. Once you get the file data, however, you must decrypt it. To do so, you can call the
This will return the decrypted JPEG image data.
The source code for this library is available here. Feel free to report issues there as well.
This library is licensed under the GNU GPL 3.0.
node-telegram-passport Copyright (C) 2018 TJ Horner This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.