Fix a few issues with linking a new Desktop instance

This commit is contained in:
Scott Nonnenberg 2021-01-15 08:57:09 -08:00
parent 8bff6e24f0
commit 4eb49ff304
5 changed files with 32 additions and 22 deletions

View File

@ -544,8 +544,13 @@
const identityRecord = this.getIdentityRecord(identifier);
if (isOurIdentifier) {
const existing = identityRecord ? identityRecord.publicKey : null;
return equalArrayBuffers(existing, publicKey);
if (identityRecord && identityRecord.publicKey) {
return equalArrayBuffers(identityRecord.publicKey, publicKey);
}
window.log.warn(
'isTrustedIdentity: No local record for our own identifier. Returning true.'
);
return true;
}
switch (direction) {

View File

@ -32,7 +32,7 @@
getUuid() {
const uuid = textsecure.storage.get('uuid_id');
if (uuid === undefined) return undefined;
return textsecure.utils.unencodeNumber(uuid)[0];
return textsecure.utils.unencodeNumber(uuid.toLowerCase())[0];
},
getDeviceId() {

View File

@ -166,7 +166,7 @@ export default class AccountManager extends EventTarget {
.then(async (keys: GeneratedKeysType) =>
registerKeys(keys).then(async () => confirmKeys(keys))
)
.then(async () => registrationDone({ number }));
.then(async () => registrationDone());
}
)
);
@ -274,9 +274,7 @@ export default class AccountManager extends EventTarget {
confirmKeys(keys)
)
)
.then(async () =>
registrationDone(provisionMessage)
);
.then(registrationDone);
}
)
)
@ -582,10 +580,23 @@ export default class AccountManager extends EventTarget {
);
}
// This needs to be done very early, because it changes how things are saved in the
// database. Your identity, for example, in the saveIdentityWithAttributes call
// below.
const conversationId = window.ConversationController.ensureContactIds({
e164: number,
uuid,
highTrust: true,
});
if (!conversationId) {
throw new Error('registrationDone: no conversationId!');
}
// update our own identity key, which may have changed
// if we're relinking after a reinstall on the master device
await window.textsecure.storage.protocol.saveIdentityWithAttributes(
number,
uuid || number,
{
publicKey: identityKeyPair.pubKey,
firstUse: true,
@ -714,20 +725,8 @@ export default class AccountManager extends EventTarget {
});
}
async registrationDone({ uuid, number }: { uuid?: string; number?: string }) {
async registrationDone() {
window.log.info('registration done');
const conversationId = window.ConversationController.ensureContactIds({
e164: number,
uuid,
highTrust: true,
});
if (!conversationId) {
throw new Error('registrationDone: no conversationId!');
}
window.log.info('dispatching registration event');
this.dispatchEvent(new Event('registration'));
}
}

View File

@ -63,6 +63,12 @@ class ProvisioningCipherInner {
return window.libsignal.Curve.async
.createKeyPair(privKey)
.then(keyPair => {
window.normalizeUuids(
provisionMessage,
['uuid'],
'ProvisioningCipher.decrypt'
);
const ret: ProvisionDecryptResult = {
identityKeyPair: keyPair,
number: provisionMessage.number,

View File

@ -326,7 +326,7 @@
"rule": "jQuery-load(",
"path": "js/signal_protocol_store.js",
"line": " await ConversationController.load();",
"lineNumber": 1019,
"lineNumber": 1024,
"reasonCategory": "falseMatch",
"updated": "2020-06-12T14:20:09.936Z"
},