diff --git a/js/views/key_verification_view.js b/js/views/key_verification_view.js index 665831ec9..22901b86d 100644 --- a/js/views/key_verification_view.js +++ b/js/views/key_verification_view.js @@ -20,18 +20,21 @@ this.theirKey = options.newKey; } + this.loadTheirKey(); + this.loadOurKey(); + + this.render(); + if (options.onLoad) { + options.onLoad(); + } + this.loadKeys().then(() => { this.listenTo(this.model, 'change', this.render); - if (options.onLoad) { - options.onLoad(); - } }); }, - loadKeys() { - return Promise.all([this.loadTheirKey(), this.loadOurKey()]) - .then(this.generateSecurityNumber.bind(this)) - .then(this.render.bind(this)); - // .then(this.makeQRCode.bind(this)); + async loadKeys() { + await this.generateSecurityNumber(); + this.render(); }, makeQRCode() { // Per Lilia: We can't turn this on until it generates a Latin1 string, as is @@ -41,18 +44,12 @@ ); }, loadTheirKey() { - return textsecure.storage.protocol - .loadIdentityKey(this.model.id) - .then(theirKey => { - this.theirKey = theirKey; - }); + const item = textsecure.storage.protocol.identityKeys[this.model.id]; + this.theirKey = item ? item.publicKey : null; }, loadOurKey() { - return textsecure.storage.protocol - .loadIdentityKey(this.ourNumber) - .then(ourKey => { - this.ourKey = ourKey; - }); + const item = textsecure.storage.protocol.identityKeys[this.ourNumber]; + this.ourKey = item ? item.publicKey : null; }, generateSecurityNumber() { return new libsignal.FingerprintGenerator(5200) @@ -113,8 +110,14 @@ render_attributes() { const s = this.securityNumber; const chunks = []; - for (let i = 0; i < s.length; i += 5) { - chunks.push(s.substring(i, i + 5)); + if (s) { + for (let i = 0; i < s.length; i += 5) { + chunks.push(s.substring(i, i + 5)); + } + } else { + for (let i = 0; i < 12; i += 1) { + chunks.push('XXXXX'); + } } const name = this.model.getTitle(); const yourSafetyNumberWith = i18n( diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index d3f120a26..41cec89a2 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -711,7 +711,7 @@ "rule": "jQuery-$(", "path": "js/views/key_verification_view.js", "line": " new QRCode(this.$('.qr')[0]).makeCode(", - "lineNumber": 39, + "lineNumber": 42, "reasonCategory": "usageTrusted", "updated": "2019-07-31T00:19:18.696Z", "reasonDetail": "Hardcoded selector" @@ -720,7 +720,7 @@ "rule": "jQuery-wrap(", "path": "js/views/key_verification_view.js", "line": " dcodeIO.ByteBuffer.wrap(this.ourKey).toString('base64')", - "lineNumber": 40, + "lineNumber": 43, "reasonCategory": "falseMatch", "updated": "2019-07-31T00:19:18.696Z" }, @@ -728,7 +728,7 @@ "rule": "jQuery-insertBefore(", "path": "js/views/key_verification_view.js", "line": " dialog.$el.insertBefore(this.el);", - "lineNumber": 75, + "lineNumber": 72, "reasonCategory": "usageTrusted", "updated": "2019-07-31T00:19:18.696Z", "reasonDetail": "Known DOM elements" @@ -737,7 +737,7 @@ "rule": "jQuery-$(", "path": "js/views/key_verification_view.js", "line": " this.$('button.verify').attr('disabled', true);", - "lineNumber": 79, + "lineNumber": 76, "reasonCategory": "usageTrusted", "updated": "2019-07-31T00:19:18.696Z", "reasonDetail": "Hardcoded selector" @@ -746,7 +746,7 @@ "rule": "jQuery-$(", "path": "js/views/key_verification_view.js", "line": " this.$('button.verify').removeAttr('disabled');", - "lineNumber": 110, + "lineNumber": 107, "reasonCategory": "usageTrusted", "updated": "2019-07-31T00:19:18.696Z", "reasonDetail": "Hardcoded selector"