WASecretBundle patch

This commit is contained in:
Adhiraj
2020-07-10 12:48:28 +05:30
parent 2a7d179822
commit 969ed87080
2 changed files with 4 additions and 3 deletions

View File

@@ -103,12 +103,13 @@ export default class WAConnectionBase {
const file = fs.readFileSync(authInfo, { encoding: 'utf-8' }) // load a closed session back if it exists
authInfo = JSON.parse(file) as AuthenticationCredentialsBrowser
}
const secretBundle: {encKey: string, macKey: string} = typeof authInfo === 'string' ? JSON.parse (authInfo): authInfo
this.authInfo = {
clientID: authInfo.WABrowserId.replace(/\"/g, ''),
serverToken: authInfo.WAToken2.replace(/\"/g, ''),
clientToken: authInfo.WAToken1.replace(/\"/g, ''),
encKey: Buffer.from(authInfo.WASecretBundle.encKey, 'base64'), // decode from base64
macKey: Buffer.from(authInfo.WASecretBundle.macKey, 'base64'), // decode from base64
encKey: Buffer.from(secretBundle.encKey, 'base64'), // decode from base64
macKey: Buffer.from(secretBundle.macKey, 'base64'), // decode from base64
}
}
/**

View File

@@ -27,7 +27,7 @@ export interface AuthenticationCredentialsBase64 {
}
export interface AuthenticationCredentialsBrowser {
WABrowserId: string
WASecretBundle: {encKey: string, macKey: string}
WASecretBundle: {encKey: string, macKey: string} | string
WAToken1: string
WAToken2: string
}