2018-07-21 21:51:20 +00:00
|
|
|
/* global textsecure, window */
|
2015-03-24 22:48:59 +00:00
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
// eslint-disable-next-line func-names
|
2018-05-02 16:51:22 +00:00
|
|
|
(function() {
|
2018-07-21 21:51:20 +00:00
|
|
|
/** *******************************************
|
2018-05-02 16:51:22 +00:00
|
|
|
*** Utilities to store data about the user ***
|
2018-07-21 21:51:20 +00:00
|
|
|
********************************************* */
|
2018-05-02 16:51:22 +00:00
|
|
|
window.textsecure = window.textsecure || {};
|
|
|
|
window.textsecure.storage = window.textsecure.storage || {};
|
2015-03-24 22:48:59 +00:00
|
|
|
|
2018-05-02 16:51:22 +00:00
|
|
|
window.textsecure.storage.user = {
|
2018-07-21 21:51:20 +00:00
|
|
|
setNumberAndDeviceId(number, deviceId, deviceName) {
|
|
|
|
textsecure.storage.put('number_id', `${number}.${deviceId}`);
|
2018-05-02 16:51:22 +00:00
|
|
|
if (deviceName) {
|
|
|
|
textsecure.storage.put('device_name', deviceName);
|
|
|
|
}
|
|
|
|
},
|
2015-03-24 22:48:59 +00:00
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
getNumber() {
|
|
|
|
const numberId = textsecure.storage.get('number_id');
|
|
|
|
if (numberId === undefined) return undefined;
|
|
|
|
return textsecure.utils.unencodeNumber(numberId)[0];
|
2018-05-02 16:51:22 +00:00
|
|
|
},
|
2015-03-24 22:48:59 +00:00
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
getDeviceId() {
|
|
|
|
const numberId = textsecure.storage.get('number_id');
|
|
|
|
if (numberId === undefined) return undefined;
|
|
|
|
return textsecure.utils.unencodeNumber(numberId)[1];
|
2018-05-02 16:51:22 +00:00
|
|
|
},
|
2015-06-18 18:00:58 +00:00
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
getDeviceName() {
|
2018-05-02 16:51:22 +00:00
|
|
|
return textsecure.storage.get('device_name');
|
|
|
|
},
|
2018-12-13 19:12:33 +00:00
|
|
|
|
|
|
|
setDeviceNameEncrypted() {
|
|
|
|
return textsecure.storage.put('deviceNameEncrypted', true);
|
|
|
|
},
|
|
|
|
|
|
|
|
getDeviceNameEncrypted() {
|
|
|
|
return textsecure.storage.get('deviceNameEncrypted');
|
|
|
|
},
|
2019-01-11 16:53:35 +00:00
|
|
|
|
|
|
|
getSignalingKey() {
|
|
|
|
return textsecure.storage.get('signaling_key');
|
|
|
|
},
|
2018-05-02 16:51:22 +00:00
|
|
|
};
|
2015-03-24 22:48:59 +00:00
|
|
|
})();
|