1023ea1732
DRY up protobuf declarations and move to a slightly briefer naming convention. Also dropped some ArrayBuffer -> string conversions as ProtoBuf.js handles ArrayBuffers just fine, and in fact, more efficiently than strings. Finally, dropped the btoa() wrappers, because that incurs an extra string -> string conversion before the protobuf's internal string -> array buffer conversion. In lieu of btoa, we can simply pass in the optional string encoding argument to the protobuf's decode method, which in these cases should be 'binary'. Related: #17
21 lines
957 B
JavaScript
21 lines
957 B
JavaScript
;(function() {
|
|
|
|
function loadProtoBufs(filename) {
|
|
return dcodeIO.ProtoBuf.loadProtoFile({root: 'protos', file: filename}).build('textsecure');
|
|
};
|
|
|
|
var pushMessages = loadProtoBufs('IncomingPushMessageSignal.proto');
|
|
var protocolMessages = loadProtoBufs('WhisperTextProtocol.proto');
|
|
var deviceMessages = loadProtoBufs('DeviceMessages.proto');
|
|
|
|
window.textsecure = window.textsecure || {};
|
|
window.textsecure.protobuf = {
|
|
IncomingPushMessageSignal : pushMessages.IncomingPushMessageSignal,
|
|
PushMessageContent : pushMessages.PushMessageContent,
|
|
WhisperMessage : protocolMessages.WhisperMessage,
|
|
PreKeyWhisperMessage : protocolMessages.PreKeyWhisperMessage,
|
|
DeviceInit : deviceMessages.DeviceInit,
|
|
IdentityKey : deviceMessages.IdentityKey,
|
|
DeviceControl : deviceMessages.DeviceControl
|
|
};
|
|
})();
|