Drop support of PniIdentity sync message
This commit is contained in:
parent
748c56d825
commit
22e1ff9b50
5 changed files with 1 additions and 140 deletions
|
@ -512,11 +512,6 @@ message SyncMessage {
|
||||||
optional bytes storageService = 1;
|
optional bytes storageService = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PniIdentity {
|
|
||||||
optional bytes publicKey = 1;
|
|
||||||
optional bytes privateKey = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Read {
|
message Read {
|
||||||
optional string sender = 1;
|
optional string sender = 1;
|
||||||
optional string senderUuid = 3;
|
optional string senderUuid = 3;
|
||||||
|
@ -630,7 +625,7 @@ message SyncMessage {
|
||||||
optional MessageRequestResponse messageRequestResponse = 14;
|
optional MessageRequestResponse messageRequestResponse = 14;
|
||||||
reserved 15; // not yet added
|
reserved 15; // not yet added
|
||||||
repeated Viewed viewed = 16;
|
repeated Viewed viewed = 16;
|
||||||
optional PniIdentity pniIdentity = 17;
|
reserved 17; // pniIdentity
|
||||||
optional PniChangeNumber pniChangeNumber = 18;
|
optional PniChangeNumber pniChangeNumber = 18;
|
||||||
optional CallEvent callEvent = 19;
|
optional CallEvent callEvent = 19;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2640,17 +2640,6 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
void routineProfileRefresher.start();
|
void routineProfileRefresher.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we have the PNI identity
|
|
||||||
|
|
||||||
const pni = storage.user.getCheckedUuid(UUIDKind.PNI);
|
|
||||||
const pniIdentity = await storage.protocol.getIdentityKeyPair(pni);
|
|
||||||
if (!pniIdentity) {
|
|
||||||
log.info('Requesting PNI identity sync');
|
|
||||||
await singleProtoJobQueue.add(
|
|
||||||
MessageSender.getRequestPniIdentitySyncMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let initialStartupCount = 0;
|
let initialStartupCount = 0;
|
||||||
|
|
|
@ -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
|
// Takes the same object returned by generateKeys
|
||||||
async confirmKeys(
|
async confirmKeys(
|
||||||
keys: GeneratedKeysType,
|
keys: GeneratedKeysType,
|
||||||
|
|
|
@ -1533,13 +1533,6 @@ export default class MessageReceiver
|
||||||
// Some sync messages have to be fully processed in the middle of
|
// Some sync messages have to be fully processed in the middle of
|
||||||
// decryption queue since subsequent envelopes use their key material.
|
// decryption queue since subsequent envelopes use their key material.
|
||||||
const { syncMessage } = content;
|
const { syncMessage } = content;
|
||||||
if (syncMessage?.pniIdentity) {
|
|
||||||
inProgressMessageType = 'pni identity';
|
|
||||||
await this.handlePNIIdentity(envelope, syncMessage.pniIdentity);
|
|
||||||
this.removeFromCache(envelope);
|
|
||||||
return { plaintext: undefined, envelope };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncMessage?.pniChangeNumber) {
|
if (syncMessage?.pniChangeNumber) {
|
||||||
inProgressMessageType = 'pni change number';
|
inProgressMessageType = 'pni change number';
|
||||||
await this.handlePNIChangeNumber(envelope, syncMessage.pniChangeNumber);
|
await this.handlePNIChangeNumber(envelope, syncMessage.pniChangeNumber);
|
||||||
|
@ -2888,9 +2881,6 @@ export default class MessageReceiver
|
||||||
if (envelope.sourceDevice == ourDeviceId) {
|
if (envelope.sourceDevice == ourDeviceId) {
|
||||||
throw new Error('Received sync message from our own device');
|
throw new Error('Received sync message from our own device');
|
||||||
}
|
}
|
||||||
if (syncMessage.pniIdentity) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (syncMessage.sent) {
|
if (syncMessage.sent) {
|
||||||
const sentMessage = syncMessage.sent;
|
const sentMessage = syncMessage.sent;
|
||||||
|
|
||||||
|
@ -3200,24 +3190,6 @@ export default class MessageReceiver
|
||||||
return this.dispatchAndWait(logId, ev);
|
return this.dispatchAndWait(logId, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs on TaskType.Encrypted queue
|
|
||||||
private async handlePNIIdentity(
|
|
||||||
envelope: ProcessedEnvelope,
|
|
||||||
{ publicKey, privateKey }: Proto.SyncMessage.IPniIdentity
|
|
||||||
): Promise<void> {
|
|
||||||
log.info('MessageReceiver: got pni identity sync message');
|
|
||||||
|
|
||||||
logUnexpectedUrgentValue(envelope, 'pniIdentitySync');
|
|
||||||
|
|
||||||
if (!publicKey || !privateKey) {
|
|
||||||
log.warn('MessageReceiver: empty pni identity sync message');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const manager = window.getAccountManager();
|
|
||||||
await manager.updatePNIIdentity({ privKey: privateKey, pubKey: publicKey });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Runs on TaskType.Encrypted queue
|
// Runs on TaskType.Encrypted queue
|
||||||
private async handlePNIChangeNumber(
|
private async handlePNIChangeNumber(
|
||||||
envelope: ProcessedEnvelope,
|
envelope: ProcessedEnvelope,
|
||||||
|
|
|
@ -1384,30 +1384,6 @@ export default class MessageSender {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static getRequestPniIdentitySyncMessage(): SingleProtoJobData {
|
|
||||||
const myUuid = window.textsecure.storage.user.getCheckedUuid();
|
|
||||||
|
|
||||||
const request = new Proto.SyncMessage.Request();
|
|
||||||
request.type = Proto.SyncMessage.Request.Type.PNI_IDENTITY;
|
|
||||||
const syncMessage = this.createSyncMessage();
|
|
||||||
syncMessage.request = request;
|
|
||||||
const contentMessage = new Proto.Content();
|
|
||||||
contentMessage.syncMessage = syncMessage;
|
|
||||||
|
|
||||||
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
|
||||||
|
|
||||||
return {
|
|
||||||
contentHint: ContentHint.RESENDABLE,
|
|
||||||
identifier: myUuid.toString(),
|
|
||||||
isSyncMessage: true,
|
|
||||||
protoBase64: Bytes.toBase64(
|
|
||||||
Proto.Content.encode(contentMessage).finish()
|
|
||||||
),
|
|
||||||
type: 'pniIdentitySyncRequest',
|
|
||||||
urgent: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static getFetchManifestSyncMessage(): SingleProtoJobData {
|
static getFetchManifestSyncMessage(): SingleProtoJobData {
|
||||||
const myUuid = window.textsecure.storage.user.getCheckedUuid();
|
const myUuid = window.textsecure.storage.user.getCheckedUuid();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue