Add isTrustedIdentity to SignalProtocolStore

Adds a new required storage method for the protocol library.

// FREEBIE
This commit is contained in:
lilia 2016-05-03 23:58:57 -07:00
parent 0dc5a0488c
commit e659104cbf
2 changed files with 26 additions and 0 deletions

View file

@ -250,6 +250,19 @@
});
},
isTrustedIdentity: function(identifier, publicKey) {
if (identifier === null || identifier === undefined) {
throw new Error("Tried to get identity key for undefined/null key");
}
var number = textsecure.utils.unencodeNumber(identifier)[0];
return new Promise(function(resolve) {
var identityKey = new IdentityKey({id: number});
identityKey.fetch().always(function() {
var oldpublicKey = identityKey.get('publicKey');
resolve(!oldpublicKey || equalArrayBuffers(oldpublicKey, publicKey));
});
});
},
loadIdentityKey: function(identifier) {
if (identifier === null || identifier === undefined) {
throw new Error("Tried to get identity key for undefined/null key");