2018-07-21 21:51:20 +00:00
|
|
|
/* global window, dcodeIO, textsecure */
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2018-05-02 16:51:22 +00:00
|
|
|
(function() {
|
|
|
|
window.textsecure = window.textsecure || {};
|
|
|
|
window.textsecure.protobuf = {};
|
2014-10-20 08:21:23 +00:00
|
|
|
|
2018-05-02 16:51:22 +00:00
|
|
|
function loadProtoBufs(filename) {
|
|
|
|
return dcodeIO.ProtoBuf.loadProtoFile(
|
|
|
|
{ root: window.PROTO_ROOT, file: filename },
|
2018-07-21 21:51:20 +00:00
|
|
|
(error, result) => {
|
2018-05-02 16:51:22 +00:00
|
|
|
if (error) {
|
2018-07-21 21:51:20 +00:00
|
|
|
const text = `Error loading protos from ${filename} (root: ${
|
|
|
|
window.PROTO_ROOT
|
|
|
|
}) ${error && error.stack ? error.stack : error}`;
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.error(text);
|
2018-05-02 16:51:22 +00:00
|
|
|
throw error;
|
|
|
|
}
|
2018-07-21 21:51:20 +00:00
|
|
|
const protos = result.build('signalservice');
|
2018-05-02 16:51:22 +00:00
|
|
|
if (!protos) {
|
2020-09-09 02:25:05 +00:00
|
|
|
const text = `Error loading protos from ${filename} - no exported types! (root: ${window.PROTO_ROOT})`;
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.error(text);
|
2018-05-02 16:51:22 +00:00
|
|
|
throw new Error(text);
|
|
|
|
}
|
2018-07-21 21:51:20 +00:00
|
|
|
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
|
|
for (const protoName in protos) {
|
2018-05-02 16:51:22 +00:00
|
|
|
textsecure.protobuf[protoName] = protos[protoName];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2014-10-20 08:21:23 +00:00
|
|
|
|
2018-05-02 16:51:22 +00:00
|
|
|
loadProtoBufs('SignalService.proto');
|
2020-07-07 00:56:56 +00:00
|
|
|
loadProtoBufs('SignalStorage.proto');
|
2018-05-02 16:51:22 +00:00
|
|
|
loadProtoBufs('SubProtocol.proto');
|
|
|
|
loadProtoBufs('DeviceMessages.proto');
|
2019-05-16 22:32:11 +00:00
|
|
|
loadProtoBufs('Stickers.proto');
|
2018-10-18 01:01:21 +00:00
|
|
|
|
2018-12-13 19:12:33 +00:00
|
|
|
// Just for encrypting device names
|
|
|
|
loadProtoBufs('DeviceName.proto');
|
|
|
|
|
2018-10-18 01:01:21 +00:00
|
|
|
// Metadata-specific protos
|
|
|
|
loadProtoBufs('UnidentifiedDelivery.proto');
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
// Groups
|
|
|
|
loadProtoBufs('Groups.proto');
|
2014-10-20 08:21:23 +00:00
|
|
|
})();
|