Skip to content

Commit

Permalink
Updated in line with libsignal-protocol-javascript#35
Browse files Browse the repository at this point in the history
  • Loading branch information
elsehow committed Nov 21, 2017
1 parent c19876b commit d7c4171
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/SessionCipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,19 @@ SessionCipher.prototype = {
return this.storage.storeSession(address, record.serialize());
}.bind(this));
}.bind(this));
},
deleteAllSessionsForDevice: function() {
// Used in session reset scenarios, where we really need to delete
var address = this.remoteAddress.toString();
return Internal.SessionLock.queueJobForNumber(address, function() {
return this.getRecord(address).then(function(record) {
if (record === undefined) {
return;
}
record.deleteAllSessions();
return this.storage.storeSession(address, record.serialize());
}.bind(this));
}.bind(this));
}
};

Expand All @@ -392,6 +405,7 @@ var mySessionCipher = function(storage, remoteAddress, options) {
this.getRemoteRegistrationId = cipher.getRemoteRegistrationId.bind(cipher);
this.hasOpenSession = cipher.hasOpenSession.bind(cipher);
this.closeOpenSessionForDevice = cipher.closeOpenSessionForDevice.bind(cipher);
this.deleteAllSessionsForDevice = cipher.deleteAllSessionsForDevice.bind(cipher);
};

module.exports = mySessionCipher;
4 changes: 4 additions & 0 deletions src/SessionRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ var SessionRecord = function() {
delete sessions[util.toString(oldestBaseKey)];
}
},
deleteAllSessions: function() {
// Used primarily in session reset scenarios, where we really delete sessions
this.sessions = {};
}
};

return SessionRecord;
Expand Down

0 comments on commit d7c4171

Please sign in to comment.