Enforce stronger types for ArrayBuffers and storage
This commit is contained in:
parent
61ac79e9ae
commit
8f5086227a
56 changed files with 748 additions and 675 deletions
|
@ -1,12 +1,9 @@
|
|||
// Copyright 2016-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global window, textsecure, SignalProtocolStore */
|
||||
/* global window, SignalProtocolStore */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function () {
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.storage = window.textsecure.storage || {};
|
||||
|
||||
textsecure.storage.protocol = new SignalProtocolStore();
|
||||
window.textsecure.storage.protocol = new SignalProtocolStore();
|
||||
})();
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright 2017-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global window, textsecure */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function () {
|
||||
/** ***************************************
|
||||
*** Not-yet-processed message storage ***
|
||||
**************************************** */
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.storage = window.textsecure.storage || {};
|
||||
|
||||
window.textsecure.storage.unprocessed = {
|
||||
getCount() {
|
||||
return textsecure.storage.protocol.getUnprocessedCount();
|
||||
},
|
||||
getAll() {
|
||||
return textsecure.storage.protocol.getAllUnprocessed();
|
||||
},
|
||||
get(id) {
|
||||
return textsecure.storage.protocol.getUnprocessedById(id);
|
||||
},
|
||||
updateAttempts(id, attempts) {
|
||||
return textsecure.storage.protocol.updateUnprocessedAttempts(
|
||||
id,
|
||||
attempts
|
||||
);
|
||||
},
|
||||
addDecryptedData(id, data) {
|
||||
return textsecure.storage.protocol.updateUnprocessedWithData(id, data);
|
||||
},
|
||||
addDecryptedDataToList(array) {
|
||||
return textsecure.storage.protocol.updateUnprocessedsWithData(array);
|
||||
},
|
||||
remove(idOrArray) {
|
||||
return textsecure.storage.protocol.removeUnprocessed(idOrArray);
|
||||
},
|
||||
removeAll() {
|
||||
return textsecure.storage.protocol.removeAllUnprocessed();
|
||||
},
|
||||
};
|
||||
})();
|
|
@ -1,70 +0,0 @@
|
|||
// Copyright 2015-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global textsecure, window */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function () {
|
||||
/** *******************************************
|
||||
*** Utilities to store data about the user ***
|
||||
********************************************* */
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.storage = window.textsecure.storage || {};
|
||||
|
||||
window.textsecure.storage.user = {
|
||||
setNumberAndDeviceId(number, deviceId, deviceName) {
|
||||
textsecure.storage.put('number_id', `${number}.${deviceId}`);
|
||||
if (deviceName) {
|
||||
textsecure.storage.put('device_name', deviceName);
|
||||
}
|
||||
},
|
||||
|
||||
setUuidAndDeviceId(uuid, deviceId) {
|
||||
textsecure.storage.put('uuid_id', `${uuid}.${deviceId}`);
|
||||
},
|
||||
|
||||
getNumber() {
|
||||
const numberId = textsecure.storage.get('number_id');
|
||||
if (numberId === undefined) return undefined;
|
||||
return textsecure.utils.unencodeNumber(numberId)[0];
|
||||
},
|
||||
|
||||
getUuid() {
|
||||
const uuid = textsecure.storage.get('uuid_id');
|
||||
if (uuid === undefined) return undefined;
|
||||
return textsecure.utils.unencodeNumber(uuid.toLowerCase())[0];
|
||||
},
|
||||
|
||||
getDeviceId() {
|
||||
return this._getDeviceIdFromUuid() || this._getDeviceIdFromNumber();
|
||||
},
|
||||
|
||||
_getDeviceIdFromUuid() {
|
||||
const uuid = textsecure.storage.get('uuid_id');
|
||||
if (uuid === undefined) return undefined;
|
||||
return textsecure.utils.unencodeNumber(uuid)[1];
|
||||
},
|
||||
|
||||
_getDeviceIdFromNumber() {
|
||||
const numberId = textsecure.storage.get('number_id');
|
||||
if (numberId === undefined) return undefined;
|
||||
return textsecure.utils.unencodeNumber(numberId)[1];
|
||||
},
|
||||
|
||||
getDeviceName() {
|
||||
return textsecure.storage.get('device_name');
|
||||
},
|
||||
|
||||
setDeviceNameEncrypted() {
|
||||
return textsecure.storage.put('deviceNameEncrypted', true);
|
||||
},
|
||||
|
||||
getDeviceNameEncrypted() {
|
||||
return textsecure.storage.get('deviceNameEncrypted');
|
||||
},
|
||||
|
||||
getSignalingKey() {
|
||||
return textsecure.storage.get('signaling_key');
|
||||
},
|
||||
};
|
||||
})();
|
|
@ -22,18 +22,12 @@
|
|||
|
||||
<script type="text/javascript" src="../components.js"></script>
|
||||
<script type="text/javascript" src="../protobufs.js" data-cover></script>
|
||||
<script type="text/javascript" src="../storage/user.js" data-cover></script>
|
||||
<script type="text/javascript" src="../storage/unprocessed.js" data-cover></script>
|
||||
<script type="text/javascript" src="../protocol_wrapper.js" data-cover></script>
|
||||
|
||||
<script type="text/javascript" src="../../js/libphonenumber-util.js"></script>
|
||||
<script type="text/javascript" src="../../js/components.js" data-cover></script>
|
||||
<script type="text/javascript" src="../../js/signal_protocol_store.js" data-cover></script>
|
||||
<script type="text/javascript" src="../../js/storage.js" data-cover></script>
|
||||
<script type="text/javascript" src="../../js/models/blockedNumbers.js" data-cover></script>
|
||||
|
||||
<script type="text/javascript" src="helpers_test.js"></script>
|
||||
<script type="text/javascript" src="storage_test.js"></script>
|
||||
<script type="text/javascript" src="crypto_test.js"></script>
|
||||
<script type="text/javascript" src="contacts_parser_test.js"></script>
|
||||
<script type="text/javascript" src="generate_keys_test.js"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue