From 9ddc237f6dab74a56bf00c7c92317d25dae27191 Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Fri, 1 Nov 2019 11:14:56 +1100 Subject: [PATCH] show pairing words instead of pubkeys on the primary device's paired devices list. --- js/views/device_pairing_dialog_view.js | 9 +++------ js/views/standalone_registration_view.js | 6 +----- libloki/modules/mnemonic.js | 8 ++++++++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/js/views/device_pairing_dialog_view.js b/js/views/device_pairing_dialog_view.js index 0ab194776..c4e339c11 100644 --- a/js/views/device_pairing_dialog_view.js +++ b/js/views/device_pairing_dialog_view.js @@ -99,7 +99,8 @@ if (pubKeys && pubKeys.length > 0) { this.$('#pairedPubKeys').empty(); pubKeys.forEach(x => { - this.$('#pairedPubKeys').append(`
  • ${x}
  • `); + const secretWords = window.mnemonic.pubkey_to_secret_words(x); + this.$('#pairedPubKeys').append(`
  • (${secretWords})
  • `); }); } } else if (this.accepted) { @@ -108,11 +109,7 @@ waitingForRequestView.hide(); requestAcceptedView.show(); } else if (this.pubKey) { - const secretWords = window.mnemonic - .mn_encode(this.pubKey.slice(2), 'english') - .split(' ') - .slice(-3) - .join(' '); + const secretWords = window.mnemonic.pubkey_to_secret_words(this.pubKey); this.$('.secretWords').text(secretWords); requestReceivedView.show(); waitingForRequestView.hide(); diff --git a/js/views/standalone_registration_view.js b/js/views/standalone_registration_view.js index 6358f1701..0f3cc0d39 100644 --- a/js/views/standalone_registration_view.js +++ b/js/views/standalone_registration_view.js @@ -268,11 +268,7 @@ ); await this.accountManager.requestPairing(primaryPubKey); const pubkey = textsecure.storage.user.getNumber(); - const words = window.mnemonic - .mn_encode(pubkey.slice(2), 'english') - .split(' ') - .slice(-3) - .join(' '); + const words = window.mnemonic.pubkey_to_secret_words(pubkey); this.$('.standalone-secondary-device #pubkey').text( `Here is your secret:\n${words}` diff --git a/libloki/modules/mnemonic.js b/libloki/modules/mnemonic.js index 4b1863d70..b31a1eeda 100644 --- a/libloki/modules/mnemonic.js +++ b/libloki/modules/mnemonic.js @@ -6,6 +6,7 @@ module.exports = { mn_decode, sc_reduce32, get_languages, + pubkey_to_secret_words, }; class MnemonicError extends Error {} @@ -190,3 +191,10 @@ for (var i in mn_words) { } } } + +function pubkey_to_secret_words(pubKey) { + return mn_encode(pubKey.slice(2), 'english') + .split(' ') + .slice(-3) + .join(' '); +}