{"id":16735671,"url":"https://github.com/merqva/telegram-passport","last_synced_at":"2026-04-13T11:01:49.655Z","repository":{"id":143760762,"uuid":"451518943","full_name":"merqva/telegram-passport","owner":"merqva","description":"Parse/Decrypt incoming Telegram Passport data","archived":false,"fork":false,"pushed_at":"2022-01-31T18:47:22.000Z","size":149,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-01-13T10:14:15.319Z","etag":null,"topics":["crypto","nodejs","npm-package","telegram","telegram-api","telegram-bot","telegram-bot-api","telegram-passport","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/merqva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-24T15:26:21.000Z","updated_at":"2022-02-16T20:33:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"f1a19852-ee24-4a65-971c-f6b4bb4310b9","html_url":"https://github.com/merqva/telegram-passport","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/merqva/telegram-passport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merqva%2Ftelegram-passport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merqva%2Ftelegram-passport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merqva%2Ftelegram-passport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merqva%2Ftelegram-passport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/merqva","download_url":"https://codeload.github.com/merqva/telegram-passport/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merqva%2Ftelegram-passport/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31749763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypto","nodejs","npm-package","telegram","telegram-api","telegram-bot","telegram-bot-api","telegram-passport","typescript"],"created_at":"2024-10-13T00:06:52.647Z","updated_at":"2026-04-13T11:01:49.632Z","avatar_url":"https://github.com/merqva.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Passport\n\n### Parse/Decrypt incoming [Telegram Passport](https://core.telegram.org/passport) data\u003cbr/\u003e\u003cbr/\u003e\n\n#### \\* Note: All the type definitions on this library are in compliance with those defined in the Telegram API specification\u003cbr/\u003e\u003cbr/\u003e\n\n## What does this library do?\n\n### Provided your Bot's Private Key, this library will:\n\n- Decrypt the [EncryptedCredentials](https://core.telegram.org/bots/api#encryptedcredentials) object from the `credentials` field in [PassportData](https://core.telegram.org/bots/api#passportdata)\n- Parse the fields on each [EncryptedPassportElement](https://core.telegram.org/bots/api#encryptedpassportelement) from the `data` field in PassportData\n- Decrypt de `data` field (if present) from the EncryptedPassportElement\n- Validate the integrity of the decryted data\n\n## What doesn't this library do?\n\n- Get the encrypted files corresponding to the requested fields\u003cbr/\u003e\\* Download the encrypted files using the [getFile](https://core.telegram.org/bots/api#getfile) API endpoint, then use the `decryptData` method to decrypt them\n  \u003cbr/\u003e\u003cbr/\u003e\n\n## Usage\n\n- First, create a new instance of the `TelegramPassport` class\n\n```typescript\nconst telegramPassport = new TelegramPassport(\"\u003cbot_private_key\u003e\");\n```\n\n- Parse and decryp de data of all the elements shared with the bot\n\n```typescript\nconst data = telegramPassport.decryptPassportData(\n    update.message.passport_data\n);\n\n// the nonce is retuned within the RequestedFields object\n\nconst nonce = data.nonce;\n```\n\n#### \\* `update` is the object representing the incoming [Update](https://core.telegram.org/bots/api#update) that was sent to the Bot\u003cbr/\u003e\u003cbr/\u003e\n\n- Decryting files\n\n```typescript\n/*\nget the data corresponding to the file you want to decryp\nfor example, the front side of the id card\n*/\n\nconst id_frontSide = data.identity_card.front_side;\n\n// download the file using the getFile API endpoint\n\n...\n\n// decryp the file\n\nconst file = telegramPassport.decryptData(\n  downloaded_file_data,\n  id_fronSide.secret,\n  id_fronSide.file_hash,\n);\n```\n\n- Depending on the fields you requested, you might not need to process the whole `PassportData` object; for example, the \"phone_number\" and \"email\" fields are not encrypted. Thus, you only need to decrypt the credentials to obtain the nonce, then, you can get \"phone_number\" and \"email\" from `passport_data.data`\n\n```typescript\n/*\nin this case, data will look like this\n\ndata: [\n  {\n    \"type\": \"phone_number\",\n    \"phone_number\": \"XXXXXXXXXXX\",\n    \"hash\": \"the_base64-encoded_hash\",\n  },\n  {\n    \"type\": \"email\",\n    \"email\": \"johndoe@example.com\",\n    \"hash\": \"the_base64-encoded_hash\"\n  },\n]\n*/\n\n// decrypt the credentials\n\nconst credentials = telegramPassport.decryptPassportCredentials(\n  update.message.passport_data.credentials,\n);\n```\n\n#### \\* `update` is the object representing the incoming [Update](https://core.telegram.org/bots/api#update) that was sent to the Bot\u003cbr/\u003e\u003cbr/\u003e\n\n## What can be inproved?\n\n- The type \"handling\" in the `decryptData` method\u003cbr/\u003e\\* Need a TS guru that can give me a hand with that, go check the code\u003cbr/\u003e\u003cbr/\u003e\n\n## Found a bug?\n\n### Open an [issue](https://github.com/merqva/telegram-passport/issues) (PRs are welcome)\n\n#### \\* be patient, I might be busy\u003cbr/\u003e\u003cbr/\u003e\n\n## Stay in touch\n\n- Author - [Yoel Navas](mailto:yn4v4s@gmail.com)\n- Website - [merqva.com](https://merqva.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerqva%2Ftelegram-passport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerqva%2Ftelegram-passport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerqva%2Ftelegram-passport/lists"}