You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/libaxolotl/test/fake_api.js

44 lines
1.3 KiB
JavaScript

'use strict';
var testSessionMap = {};
;(function() {
window.axolotl = window.axolotl || {};
window.axolotl.api = {
getMyRegistrationId: function() {
return window.myRegistrationId;
},
storage: {
put: function(key, value) {
if (value === undefined)
throw new Error("Tried to store undefined");
localStorage.setItem(key, textsecure.utils.jsonThing(value));
},
get: function(key, defaultValue) {
var value = localStorage.getItem(key);
if (value === null)
return defaultValue;
return JSON.parse(value);
},
remove: function(key) {
localStorage.removeItem(key);
},
sessions: {
get: function(identifier) {
return testSessionMap[identifier];
},
put: function(identifier, record) {
testSessionMap[identifier] = record;
}
}
},
updateKeys: function(keys) {
return textsecure.api.registerKeys(keys).catch(function(e) {
//TODO: Notify the user somehow?
console.error(e);
});
},
};
})();