Commit 7ba19bbb authored by TJ Horner's avatar TJ Horner

bug

parent 22bfb11c
......@@ -29,7 +29,7 @@ class TelegramPassport {
if(!hash.equals(integrityHash))
throw new Error(`The integrity of the data could not be verified (${hash.toString("hex")} != ${integrityHash.toString("hex")}). Please ensure you are passing the correct hash.`)
return JSON.parse(dataCredentialsPadded.slice(dataCredentialsPadded[0], dataCredentialsPadded.byteLength).toString())
return dataCredentialsPadded.slice(dataCredentialsPadded[0], dataCredentialsPadded.byteLength)
}
decrypt(passport) {
......@@ -37,11 +37,11 @@ class TelegramPassport {
var secret = crypto.privateDecrypt({ key: this.privateKey, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING }, Buffer.from(passport.credentials.secret, "base64"))
// Get the data credentials for each data field
var dataCredentials = this.decryptPassportCredentials(
var dataCredentials = JSON.parse(this.decryptPassportCredentials(
Buffer.from(passport.credentials.data, "base64"),
Buffer.from(passport.credentials.hash, "base64"),
secret
)
).toString())
var finalData = { payload: dataCredentials.payload }
......@@ -52,11 +52,11 @@ class TelegramPassport {
// Decrypt the `data` field
if(secureData.data) {
finalData[key].data = this.decryptPassportCredentials(
finalData[key].data = JSON.parse(this.decryptPassportCredentials(
Buffer.from(dataField.data, "base64"),
Buffer.from(secureData.data.data_hash, "base64"),
Buffer.from(secureData.data.secret, "base64")
)
).toString())
}
// Pass the file, secret, and hash for each of these fields
......
{
"name": "telegram-passport",
"version": "1.0.3",
"version": "1.0.4",
"description": "Parse incoming Telegram Passport data",
"main": "index.js",
"homepage": "https://git.horner.tj/tj/node-telegram-passport",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment