2016-09-12 22:43:00 +00:00
|
|
|
/*
|
|
|
|
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);
|
2016-09-16 01:26:09 +00:00
|
|
|
|
|
|
|
client.downloadKeys([this.props.event.getSender()], true).done(()=>{
|
|
|
|
var devices = client.getStoredDevicesForUser(this.props.event.getSender());
|
|
|
|
this.setState({ device: this.refreshDevice() });
|
|
|
|
}, (err)=>{
|
|
|
|
console.log("Error downloading devices", err);
|
|
|
|
});
|
2016-09-12 22:43:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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() });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-16 01:26:09 +00:00
|
|
|
onKeyDown: function(e) {
|
|
|
|
if (e.keyCode === 27) { // escape
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onFinished(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-12 22:43:00 +00:00
|
|
|
render: function() {
|
|
|
|
var event = this.props.event;
|
|
|
|
var device = this.state.device;
|
|
|
|
|
|
|
|
var MemberDeviceInfo = sdk.getComponent('rooms.MemberDeviceInfo');
|
|
|
|
|
|
|
|
return (
|
2016-09-16 01:26:09 +00:00
|
|
|
<div className="mx_EncryptedEventDialog" onKeyDown={ this.onKeyDown }>
|
2016-09-12 22:43:00 +00:00
|
|
|
<div className="mx_Dialog_title">
|
|
|
|
End-to-end encryption information
|
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_content">
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>Sent by</td>
|
|
|
|
<td>{ event.getSender() }</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Sender device name</td>
|
2016-09-15 01:44:55 +00:00
|
|
|
<td>{ device ? device.getDisplayName() : <i>unknown device</i>}</td>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Sender device ID</td>
|
2016-09-15 01:44:55 +00:00
|
|
|
<td>{ device ? <code>{ device.deviceId }</code> : <i>unknown device</i>}</td>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2016-09-15 01:44:55 +00:00
|
|
|
<td>Sender device verification</td>
|
2016-09-12 22:43:00 +00:00
|
|
|
<td>{ MatrixClientPeg.get().isEventSenderVerified(event) ? "verified" : <b>NOT verified</b> }</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2016-09-14 17:23:14 +00:00
|
|
|
<td>Sender device ed25519 identity key</td>
|
2016-09-15 01:44:55 +00:00
|
|
|
<td>{ device ? <code>{device.getFingerprint()}</code> : <i>unknown device</i>}</td>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2016-09-14 17:23:14 +00:00
|
|
|
<td>Sender device curve25519 olm key</td>
|
2016-09-15 18:25:53 +00:00
|
|
|
<td><code>{ event.getWireContent().sender_key || <i>none</i> }</code></td>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Algorithm</td>
|
2016-09-15 18:25:53 +00:00
|
|
|
<td>{ event.getWireContent().algorithm || <i>unencrypted</i> }</td>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tr>
|
|
|
|
{
|
|
|
|
event.getContent().msgtype === 'm.bad.encrypted' ? (
|
|
|
|
<tr>
|
|
|
|
<td>Decryption error</td>
|
|
|
|
<td>{ event.getContent().body }</td>
|
|
|
|
</tr>
|
|
|
|
) : ''
|
|
|
|
}
|
2016-09-15 01:44:55 +00:00
|
|
|
<tr>
|
|
|
|
<td>Session ID</td>
|
2016-09-15 18:25:53 +00:00
|
|
|
<td><code>{ event.getWireContent().session_id || <i>none</i> }</code></td>
|
2016-09-15 01:44:55 +00:00
|
|
|
</tr>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_buttons">
|
|
|
|
<button className="mx_Dialog_primary" onClick={ this.props.onFinished } autoFocus={ true }>
|
|
|
|
OK
|
|
|
|
</button>
|
|
|
|
<MemberDeviceInfo ref="memberDeviceInfo" hideInfo={true} device={ this.state.device } userId={ this.props.event.getSender() }/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|