From 20f4d48991edba2298d13be4f7a5b6825c1bc60d Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 19 Jun 2017 09:08:16 -0700 Subject: [PATCH] Protos: Move to latest iteration of verification protos FREEBIE --- js/background.js | 18 ++++++++-------- js/libtextsecure.js | 28 ++++++++++++------------ libtextsecure/message_receiver.js | 18 ++++++++-------- libtextsecure/sendmessage.js | 10 ++++----- protos/IncomingPushMessageSignal.proto | 30 +++++++++++++------------- 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/js/background.js b/js/background.js index d976827d63ac..16d6d0f11ab8 100644 --- a/js/background.js +++ b/js/background.js @@ -119,7 +119,7 @@ messageReceiver.addEventListener('group', onGroupReceived); messageReceiver.addEventListener('sent', onSentMessage); messageReceiver.addEventListener('read', onReadReceipt); - messageReceiver.addEventListener('verification', onVerification); + messageReceiver.addEventListener('verified', onVerified); messageReceiver.addEventListener('error', onError); @@ -291,21 +291,21 @@ }); } - function onVerification(ev) { - var number = ev.verification.destination; - var key = ev.verification.identityKey; + function onVerified(ev) { + var number = ev.verified.destination; + var key = ev.verified.identityKey; var state; - console.log('got verification sync for', number, state); + console.log('got verified sync for', number, state); - switch(ev.verification.state) { - case textsecure.protobuf.SyncMessage.Verification.State.DEFAULT: + switch(ev.verified.state) { + case textsecure.protobuf.SyncMessage.Verified.State.DEFAULT: state = 'DEFAULT'; break; - case textsecure.protobuf.SyncMessage.Verification.State.VERIFIED: + case textsecure.protobuf.SyncMessage.Verified.State.VERIFIED: state = 'VERIFIED'; break; - case textsecure.protobuf.SyncMessage.Verification.State.NO_LONGER_VERIFIED: + case textsecure.protobuf.SyncMessage.Verified.State.UNVERIFIED: state = 'UNVERIFIED'; break; } diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 9bbf3e711d5f..f5ee4b5f82f9 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38481,19 +38481,19 @@ MessageReceiver.prototype.extend({ console.log('read messages', 'from', envelope.source + '.' + envelope.sourceDevice); this.handleRead(syncMessage.read, envelope.timestamp); - } else if (syncMessage.verification) { - this.handleVerification(syncMessage.verification); + } else if (syncMessage.verified) { + this.handleVerified(syncMessage.verified); } else { throw new Error('Got empty SyncMessage'); } }, - handleVerification: function(verification) { - for (var i = 0; i < verification.length; ++i) { - var ev = new Event('verification'); - ev.verification = { - state: verification[i].state, - destination: verification[i].destination, - identityKey: verification[i].identityKey.toArrayBuffer() + handleVerified: function(verified) { + for (var i = 0; i < verified.length; ++i) { + var ev = new Event('verified'); + ev.verified = { + state: verified[i].state, + destination: verified[i].destination, + identityKey: verified[i].identityKey.toArrayBuffer() }; this.dispatchEvent(ev); } @@ -39271,13 +39271,13 @@ MessageSender.prototype = { var myNumber = textsecure.storage.user.getNumber(); var myDevice = textsecure.storage.user.getDeviceId(); if (myDevice != 1) { - var verification = new textsecure.protobuf.SyncMessage.Verification(); - verification.state = state; - verification.destination = destination; - verification.identityKey = identityKey; + var verified = new textsecure.protobuf.SyncMessage.Verified(); + verified.state = state; + verified.destination = destination; + verified.identityKey = identityKey; var syncMessage = new textsecure.protobuf.SyncMessage(); - syncMessage.verification = verification; + syncMessage.verified = verified; var contentMessage = new textsecure.protobuf.Content(); contentMessage.syncMessage = syncMessage; diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 045f0adb7880..a6af2e227f70 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -272,19 +272,19 @@ MessageReceiver.prototype.extend({ console.log('read messages', 'from', envelope.source + '.' + envelope.sourceDevice); this.handleRead(syncMessage.read, envelope.timestamp); - } else if (syncMessage.verification) { - this.handleVerification(syncMessage.verification); + } else if (syncMessage.verified) { + this.handleVerified(syncMessage.verified); } else { throw new Error('Got empty SyncMessage'); } }, - handleVerification: function(verification) { - for (var i = 0; i < verification.length; ++i) { - var ev = new Event('verification'); - ev.verification = { - state: verification[i].state, - destination: verification[i].destination, - identityKey: verification[i].identityKey.toArrayBuffer() + handleVerified: function(verified) { + for (var i = 0; i < verified.length; ++i) { + var ev = new Event('verified'); + ev.verified = { + state: verified[i].state, + destination: verified[i].destination, + identityKey: verified[i].identityKey.toArrayBuffer() }; this.dispatchEvent(ev); } diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 4e69857890bb..3332db8f0921 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -309,13 +309,13 @@ MessageSender.prototype = { var myNumber = textsecure.storage.user.getNumber(); var myDevice = textsecure.storage.user.getDeviceId(); if (myDevice != 1) { - var verification = new textsecure.protobuf.SyncMessage.Verification(); - verification.state = state; - verification.destination = destination; - verification.identityKey = identityKey; + var verified = new textsecure.protobuf.SyncMessage.Verified(); + verified.state = state; + verified.destination = destination; + verified.identityKey = identityKey; var syncMessage = new textsecure.protobuf.SyncMessage(); - syncMessage.verification = verification; + syncMessage.verified = verified; var contentMessage = new textsecure.protobuf.Content(); contentMessage.syncMessage = syncMessage; diff --git a/protos/IncomingPushMessageSignal.proto b/protos/IncomingPushMessageSignal.proto index ded3f7fbee2a..a3563f49e19f 100644 --- a/protos/IncomingPushMessageSignal.proto +++ b/protos/IncomingPushMessageSignal.proto @@ -111,26 +111,26 @@ message SyncMessage { optional uint64 timestamp = 2; } - message Verification { + message Verified { enum State { - DEFAULT = 0; - VERIFIED = 1; - NO_LONGER_VERIFIED = 2; + DEFAULT = 0; + VERIFIED = 1; + UNVERIFIED = 2; } - optional State state = 1; - // The e164 phone number of the user. - optional string destination = 2; - optional bytes identityKey = 3; + optional string destination = 1; + optional bytes identityKey = 2; + optional State state = 3; } - optional Sent sent = 1; - optional Contacts contacts = 2; - optional Groups groups = 3; - optional Request request = 4; - repeated Read read = 5; - optional Blocked blocked = 6; - repeated Verification verification = 7; + optional Sent sent = 1; + optional Contacts contacts = 2; + optional Groups groups = 3; + optional Request request = 4; + repeated Read read = 5; + optional Blocked blocked = 6; + repeated Verified verified = 7; + optional bytes padding = 8; } message AttachmentPointer {