fix: decode app state key correctly

This commit is contained in:
Adhiraj Singh
2021-12-12 11:18:04 +05:30
parent f284217d35
commit 0650c10c73

View File

@@ -1,6 +1,7 @@
import { Boom } from '@hapi/boom'
import { randomBytes } from 'crypto'
import type { Logger } from 'pino'
import { proto } from '../../WAProto'
import type { AuthenticationCreds, AuthenticationState, SignalDataTypeMap, SignalDataSet, SignalKeyStore, SignalKeyStoreWithTransaction } from "../Types"
import { Curve, signedKeyPair } from './crypto'
import { generateRegistrationId, BufferJSON } from './generics'
@@ -144,8 +145,11 @@ export const useSingleFileAuthState = (filename: string): { state: Authenticatio
const key = KEY_MAP[type]
return ids.reduce(
(dict, id) => {
const value = keys[key]?.[id]
let value = keys[key]?.[id]
if(value) {
if(type === 'app-state-sync-key') {
value = proto.AppStateSyncKeyData.fromObject(value)
}
dict[id] = value
}
return dict