Unread fix + regen QR code changes + Browser message decoding

This commit is contained in:
Adhiraj
2020-07-10 12:27:18 +05:30
parent 08919e51bb
commit 2dad372e75
12 changed files with 150 additions and 3239 deletions
@@ -0,0 +1,39 @@
import fs from 'fs'
import { decryptWA } from './Utils'
import Decoder from '../Binary/Decoder'
interface BrowserMessagesInfo {
encKey: string,
macKey: string,
messages: string[]
}
const file = fs.readFileSync ('./browser-messages.json', {encoding: 'utf-8'})
const json: BrowserMessagesInfo = JSON.parse (file)
const encKey = Buffer.from (json.encKey, 'base64')
const macKey = Buffer.from (json.macKey, 'base64')
const decrypt = buffer => {
try {
return decryptWA (buffer, macKey, encKey, new Decoder())
} catch {
return decryptWA (buffer, macKey, encKey, new Decoder(), true)
}
}
json.messages.forEach ((str, i) => {
const buffer = Buffer.from (str, 'hex')
try {
const [tag, json, binaryTags] = decrypt (buffer)
console.log (
`
${i}.
messageTag: ${tag}
output: ${JSON.stringify(json)}
binaryTags: ${binaryTags}
`
)
} catch (error) {
console.error (`received error in decoding ${i}: ${error}`)
}
})