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);
|
|
|
|
},
|
|
|
|
|
|
|
|
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 (
|
|
|
|
<div className="mx_EncryptedEventDialog">
|
|
|
|
<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 01:44:55 +00:00
|
|
|
<td><code>{ event.getWireContent().sender_key }</code></td>
|
2016-09-12 22:43:00 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Algorithm</td>
|
|
|
|
<td>{ event.getWireContent().algorithm }</td>
|
|
|
|
</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>
|
|
|
|
<td><code>{ event.getWireContent().session_id }</code></td>
|
|
|
|
</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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|