Drop support of PniIdentity sync message

This commit is contained in:
Fedor Indutny 2023-05-10 10:02:32 -07:00 committed by GitHub
parent 748c56d825
commit 22e1ff9b50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 140 deletions

View file

@ -695,77 +695,6 @@ export default class AccountManager extends EventTarget {
]);
}
async updatePNIIdentity(identityKeyPair: KeyPairType): Promise<void> {
const { storage } = window.textsecure;
log.info('AccountManager.updatePNIIdentity: generating new keys');
await this.queueTask(async () => {
// Server has accepted our keys which means we have the latest PNI identity
// now that doesn't conflict the PNI identity of the primary device.
log.info(
'AccountManager.updatePNIIdentity: updating identity key ' +
'and registration id'
);
const pni = storage.user.getCheckedUuid(UUIDKind.PNI);
const identityKeyMap = {
...(storage.get('identityKeyMap') || {}),
[pni.toString()]: identityKeyPair,
};
await storage.put('identityKeyMap', identityKeyMap);
await storage.protocol.hydrateCaches();
});
// Intentionally not awaiting because `updatePNIIdentity` runs on an
// Encrypted queue of MessageReceiver and we don't want to await remote
// endpoints and block message processing.
void this.queueTask(async () => {
try {
const keys = await this.generateKeys(
SIGNED_KEY_GEN_BATCH_SIZE,
UUIDKind.PNI,
identityKeyPair
);
await this.server.registerKeys(keys, UUIDKind.PNI);
await this.confirmKeys(keys, UUIDKind.PNI);
const pni = storage.user.getCheckedUuid(UUIDKind.PNI);
// Repair registration id
const deviceId = storage.user.getDeviceId();
const { devices } = await this.server.getKeysForIdentifier(
pni.toString(),
deviceId
);
const us = devices.find(
remoteDevice => remoteDevice.deviceId === deviceId
);
if (us) {
const oldRegistrationIdMap = storage.get('registrationIdMap') || {};
const oldRegistrationId = oldRegistrationIdMap[pni.toString()];
if (oldRegistrationId !== us.registrationId) {
log.warn(
'updatePNIIdentity: repairing PNI registration id from ' +
`${oldRegistrationId} to ${us.registrationId}`
);
}
const registrationIdMap = {
...oldRegistrationIdMap,
[pni.toString()]: us.registrationId,
};
await storage.put('registrationIdMap', registrationIdMap);
}
} catch (error) {
log.error(
'updatePNIIdentity: Failed to upload PNI prekeys. Moving on',
Errors.toLogFormat(error)
);
}
});
}
// Takes the same object returned by generateKeys
async confirmKeys(
keys: GeneratedKeysType,