UUID-keyed lookups in SignalProtocolStore
This commit is contained in:
parent
6323aedd9b
commit
c7e7d55af4
46 changed files with 2094 additions and 1447 deletions
|
@ -10,6 +10,9 @@ import {
|
|||
|
||||
import { UnregisteredUserError } from './Errors';
|
||||
import { Sessions, IdentityKeys } from '../LibSignalStores';
|
||||
import { Address } from '../types/Address';
|
||||
import { QualifiedAddress } from '../types/QualifiedAddress';
|
||||
import { UUID } from '../types/UUID';
|
||||
import { ServerKeysType, WebAPIType } from './WebAPI';
|
||||
|
||||
export async function getKeysForIdentifier(
|
||||
|
@ -32,7 +35,11 @@ export async function getKeysForIdentifier(
|
|||
};
|
||||
} catch (error) {
|
||||
if (error.name === 'HTTPError' && error.code === 404) {
|
||||
await window.textsecure.storage.protocol.archiveAllSessions(identifier);
|
||||
const theirUuid = UUID.lookup(identifier);
|
||||
|
||||
if (theirUuid) {
|
||||
await window.textsecure.storage.protocol.archiveAllSessions(theirUuid);
|
||||
}
|
||||
}
|
||||
throw new UnregisteredUserError(identifier, error);
|
||||
}
|
||||
|
@ -72,8 +79,9 @@ async function handleServerKeys(
|
|||
response: ServerKeysType,
|
||||
devicesToUpdate?: Array<number>
|
||||
): Promise<void> {
|
||||
const sessionStore = new Sessions();
|
||||
const identityKeyStore = new IdentityKeys();
|
||||
const ourUuid = window.textsecure.storage.user.getCheckedUuid();
|
||||
const sessionStore = new Sessions({ ourUuid });
|
||||
const identityKeyStore = new IdentityKeys({ ourUuid });
|
||||
|
||||
await Promise.all(
|
||||
response.devices.map(async device => {
|
||||
|
@ -95,7 +103,11 @@ async function handleServerKeys(
|
|||
`getKeysForIdentifier/${identifier}: Missing signed prekey for deviceId ${deviceId}`
|
||||
);
|
||||
}
|
||||
const protocolAddress = ProtocolAddress.new(identifier, deviceId);
|
||||
const theirUuid = UUID.checkedLookup(identifier);
|
||||
const protocolAddress = ProtocolAddress.new(
|
||||
theirUuid.toString(),
|
||||
deviceId
|
||||
);
|
||||
const preKeyId = preKey?.keyId || null;
|
||||
const preKeyObject = preKey
|
||||
? PublicKey.deserialize(Buffer.from(preKey.publicKey))
|
||||
|
@ -118,7 +130,10 @@ async function handleServerKeys(
|
|||
identityKey
|
||||
);
|
||||
|
||||
const address = `${identifier}.${deviceId}`;
|
||||
const address = new QualifiedAddress(
|
||||
ourUuid,
|
||||
new Address(theirUuid, deviceId)
|
||||
);
|
||||
await window.textsecure.storage.protocol
|
||||
.enqueueSessionJob(address, () =>
|
||||
processPreKeyBundle(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue