UUID-keyed lookups in SignalProtocolStore

This commit is contained in:
Fedor Indutny 2021-09-09 19:38:11 -07:00 committed by GitHub
parent 6323aedd9b
commit c7e7d55af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 2094 additions and 1447 deletions

View file

@ -5,6 +5,7 @@ import { WebAPICredentials } from '../Types.d';
import { strictAssert } from '../../util/assert';
import { StorageInterface } from '../../types/Storage.d';
import { UUID } from '../../types/UUID';
import Helpers from '../Helpers';
@ -56,10 +57,16 @@ export class User {
return Helpers.unencodeNumber(numberId)[0];
}
public getUuid(): string | undefined {
public getUuid(): UUID | undefined {
const uuid = this.storage.get('uuid_id');
if (uuid === undefined) return undefined;
return Helpers.unencodeNumber(uuid.toLowerCase())[0];
return new UUID(Helpers.unencodeNumber(uuid.toLowerCase())[0]);
}
public getCheckedUuid(): UUID {
const uuid = this.getUuid();
strictAssert(uuid !== undefined, 'Must have our own uuid');
return uuid;
}
public getDeviceId(): number | undefined {