diff --git a/src/components/views/dialogs/EncryptedEventDialog.js b/src/components/views/dialogs/EncryptedEventDialog.js new file mode 100644 index 0000000000..c8bcc52a06 --- /dev/null +++ b/src/components/views/dialogs/EncryptedEventDialog.js @@ -0,0 +1,123 @@ +/* +Copyright 2015, 2016 OpenMarket Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +var React = require("react"); +var sdk = require('../../../index'); +var MatrixClientPeg = require("../../../MatrixClientPeg"); + +module.exports = React.createClass({ + displayName: 'EncryptedEventDialog', + + propTypes: { + onFinished: React.PropTypes.func, + }, + + componentWillMount: function() { + var client = MatrixClientPeg.get(); + client.on("deviceVerificationChanged", this.onDeviceVerificationChanged); + }, + + componentWillUnmount: function() { + var client = MatrixClientPeg.get(); + if (client) { + client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged); + } + }, + + refreshDevice: function() { + // XXX: gutwrench - is there any reason not to expose this on MatrixClient itself? + return MatrixClientPeg.get()._crypto.getDeviceByIdentityKey( + this.props.event.getSender(), + this.props.event.getWireContent().algorithm, + this.props.event.getWireContent().sender_key + ); + }, + + getInitialState: function() { + return { device: this.refreshDevice() }; + }, + + onDeviceVerificationChanged: function(userId, device) { + if (userId == this.props.event.getSender()) { + this.setState({ device: this.refreshDevice() }); + } + }, + + render: function() { + var event = this.props.event; + var device = this.state.device; + + var MemberDeviceInfo = sdk.getComponent('rooms.MemberDeviceInfo'); + + return ( +
Sent by | +{ event.getSender() } | +
Sender device name | +{ device.getDisplayName() } | +
Sender device ID | +{ device.deviceId } | +
Sender device verification: | +{ MatrixClientPeg.get().isEventSenderVerified(event) ? "verified" : NOT verified } | +
Sender device ed25519 fingerprint | +{ device.getFingerprint() } | +
Sender device curve25519 identity key | +{ event.getWireContent().sender_key } | +
Algorithm | +{ event.getWireContent().algorithm } | +
Decryption error | +{ event.getContent().body } | +