Add loadSignedPreKeys to SignalProtocolStore
This commit is contained in:
parent
37ad742ccf
commit
e0fd188d42
1 changed files with 23 additions and 0 deletions
|
@ -70,6 +70,11 @@
|
||||||
var Model = Backbone.Model.extend({ database: Whisper.Database });
|
var Model = Backbone.Model.extend({ database: Whisper.Database });
|
||||||
var PreKey = Model.extend({ storeName: 'preKeys' });
|
var PreKey = Model.extend({ storeName: 'preKeys' });
|
||||||
var SignedPreKey = Model.extend({ storeName: 'signedPreKeys' });
|
var SignedPreKey = Model.extend({ storeName: 'signedPreKeys' });
|
||||||
|
var SignedPreKeyCollection = Backbone.Collection.extend({
|
||||||
|
storeName: 'signedPreKeys',
|
||||||
|
database: Whisper.Database,
|
||||||
|
model: SignedPreKey
|
||||||
|
});
|
||||||
var Session = Model.extend({ storeName: 'sessions' });
|
var Session = Model.extend({ storeName: 'sessions' });
|
||||||
var SessionCollection = Backbone.Collection.extend({
|
var SessionCollection = Backbone.Collection.extend({
|
||||||
storeName: 'sessions',
|
storeName: 'sessions',
|
||||||
|
@ -156,6 +161,24 @@
|
||||||
}).fail(resolve);
|
}).fail(resolve);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
loadSignedPreKeys: function() {
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
return Promise.reject(new Error("loadSignedPreKeys takes no arguments"));
|
||||||
|
}
|
||||||
|
var signedPreKeys = new SignedPreKeyCollection();
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
signedPreKeys.fetch().then(function() {
|
||||||
|
resolve(signedPreKeys.map(function(prekey) {
|
||||||
|
return {
|
||||||
|
pubKey : prekey.get('publicKey'),
|
||||||
|
privKey : prekey.get('privateKey'),
|
||||||
|
created_at : prekey.get('created_at'),
|
||||||
|
keyId : prekey.get('id')
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
storeSignedPreKey: function(keyId, keyPair) {
|
storeSignedPreKey: function(keyId, keyPair) {
|
||||||
var prekey = new SignedPreKey({
|
var prekey = new SignedPreKey({
|
||||||
id : keyId,
|
id : keyId,
|
||||||
|
|
Loading…
Reference in a new issue