Account setup: confirm first signed prekey, clear prekeys (#1979)

This commit is contained in:
Scott Nonnenberg
2018-01-17 15:28:32 -08:00
committed by GitHub
parent c70fb3a254
commit 33fd9c5dd4
2 changed files with 100 additions and 51 deletions

View File

@@ -89,6 +89,11 @@
var Model = Backbone.Model.extend({ database: Whisper.Database });
var PreKey = Model.extend({ storeName: 'preKeys' });
var PreKeyCollection = Backbone.Collection.extend({
storeName: 'preKeys',
database: Whisper.Database,
model: PreKey
});
var SignedPreKey = Model.extend({ storeName: 'signedPreKeys' });
var SignedPreKeyCollection = Backbone.Collection.extend({
storeName: 'signedPreKeys',
@@ -229,6 +234,12 @@
});
});
},
clearPreKeyStore: function() {
return new Promise(function(resolve) {
var preKeys = new PreKeyCollection();
preKeys.sync('delete', preKeys, {}).always(resolve);
});
},
/* Returns a signed keypair object or undefined */
loadSignedPreKey: function(keyId) {
@@ -293,6 +304,12 @@
deferred.then(resolve, reject);
});
},
clearSignedPreKeysStore: function() {
return new Promise(function(resolve) {
var signedPreKeys = new SignedPreKeyCollection();
signedPreKeys.sync('delete', signedPreKeys, {}).always(resolve);
});
},
loadSession: function(encodedNumber) {
if (encodedNumber === null || encodedNumber === undefined) {
@@ -392,7 +409,6 @@
var sessions = new SessionCollection();
sessions.sync('delete', sessions, {}).always(resolve);
});
},
isTrustedIdentity: function(identifier, publicKey, direction) {
if (identifier === null || identifier === undefined) {