move appstatesynckey to keys

This commit is contained in:
Adhiraj Singh
2021-09-26 12:35:56 +05:30
parent a46a07fe45
commit 23101f87a1
8 changed files with 56 additions and 42 deletions

View File

@@ -83,19 +83,22 @@ export const generateRegistrationNode = (
}
export const initInMemoryKeyStore = (
{ preKeys, sessions, senderKeys }: {
{ preKeys, sessions, senderKeys, appStateSyncKeys }: {
preKeys?: { [k: number]: KeyPair },
sessions?: { [k: string]: any },
senderKeys?: { [k: string]: any }
appStateSyncKeys?: { [k: string]: proto.IAppStateSyncKeyData }
} = { },
) => {
preKeys = preKeys || { }
sessions = sessions || { }
senderKeys = senderKeys || { }
appStateSyncKeys = appStateSyncKeys || { }
return {
preKeys,
sessions,
senderKeys,
appStateSyncKeys,
getPreKey: keyId => preKeys[keyId],
setPreKey: (keyId, pair) => {
if(pair) preKeys[keyId] = pair
@@ -112,6 +115,16 @@ export const initInMemoryKeyStore = (
setSenderKey: (id, item) => {
if(item) senderKeys[id] = item
else delete senderKeys[id]
},
getAppStateSyncKey: id => {
const obj = appStateSyncKeys[id]
if(obj) {
return proto.AppStateSyncKeyData.fromObject(obj)
}
},
setAppStateSyncKey: (id, item) => {
if(item) appStateSyncKeys[id] = item
else delete appStateSyncKeys[id]
}
} as SignalKeyStore
}