Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Telegram Passport support #468

Closed
wants to merge 8 commits into from

Conversation

tjhorner
Copy link

@tjhorner tjhorner commented Jul 26, 2018

Description

This pull request is a work in progress. Still needed:

  • Unit tests
  • getPassportFile method for retrieving + decrypting Passport files all at once

This pull request adds support for Telegram Passport and decryption of Telegram Passport data with the telegram-passport package.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

A simple way to test this change would be:

const Telegraf = require('./telegraf.js')

const bot = new Telegraf("BOT_TOKEN", {
  privateKey: "BOT_PRIVATE_KEY_IN_PEM_FORMAT"
})

bot.on("passport_data", ctx => {
  console.log(ctx.decryptPassportData()) // will print the decrypted Passport data
})

bot.startPolling()

Test Configuration:

  • Node.js Version: v8.4.0
  • Operating System: Windows 10 Home / Ubuntu 16.04

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Member

@dotcypress dotcypress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

core/context.js Outdated Show resolved Hide resolved
core/context.js Outdated Show resolved Hide resolved
@tjhorner
Copy link
Author

tjhorner commented Jul 27, 2018

Do we want something that automatically fetches and then decrypts Passport-related files, maybe an extension to getFile. getPassportFile?

@dotcypress
Copy link
Member

Yes, I think getPassportFile will be useful in some cases! 👍

@Piterden
Copy link
Contributor

Btw guys, it's not fully related, but could be interesting for you sergeysova/telegram-typings#23

@lifehome
Copy link

lifehome commented Jan 1, 2019

Will there be chances this issue get resolved in 2019? :wonder:

@tjhorner
Copy link
Author

tjhorner commented Jan 1, 2019

@lifehome the only thing blocking this PR from being merged is tests. Unfortunately, I don't have the time to write them myself, but if someone else wants to contribute I would be glad to accept a PR into my own branch!

@dotcypress
Copy link
Member

@tjhorner thank you a lot for telegram-passport library and this PR 👍🔥.
I decided to use delegation pattern with passport feature instead of adding new dependency:

const Telegraf = require('telegraf')
const TelegramPassport = require('telegram-passport')

const bot = new Telegraf(process.env.BOT_TOKEN)
const passport = new TelegramPassport("PRIVATE_KEY_IN_PEM_FORMAT")

bot.on('passport_data', (ctx) => {
  const decryptedPasswordData = passport.decrypt(ctx.passportData)
  console.log(decryptedPasswordData)
  return ctx.setPassportDataErrors([
    { source: 'selfie', type: 'driver_license', file_hash: 'file-hash', message: 'Selfie photo is too low quality'}
  ])
})

New version will be published shortly.

@dotcypress dotcypress closed this Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants