mirror of https://github.com/vector-im/riot-web
Generate a QR code for apps to scan
parent
586a240e41
commit
b682e7d908
|
@ -24,15 +24,13 @@ import QRCode from "qrcode-react";
|
||||||
export default class VerificationQRCode extends React.PureComponent {
|
export default class VerificationQRCode extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
// Common for all kinds of QR codes
|
// Common for all kinds of QR codes
|
||||||
keys: PropTypes.array.isRequired, // array of [Key ID, Key] pairs
|
keys: PropTypes.array.isRequired, // array of [Key ID, Base64 Key] pairs
|
||||||
action: PropTypes.string.isRequired,
|
action: PropTypes.string.isRequired,
|
||||||
keyholderUserId: PropTypes.string.isRequired,
|
keyholderUserId: PropTypes.string.isRequired,
|
||||||
|
|
||||||
// User verification use case only
|
// User verification use case only
|
||||||
secret: PropTypes.string,
|
secret: PropTypes.string,
|
||||||
otherUserKey: PropTypes.string,
|
otherUserKey: PropTypes.string, // Base64 key being verified
|
||||||
verificationKey: PropTypes.string,
|
|
||||||
verificationAlgorithms: PropTypes.array,
|
|
||||||
requestEventId: PropTypes.string,
|
requestEventId: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,8 +42,6 @@ export default class VerificationQRCode extends React.PureComponent {
|
||||||
const query = {
|
const query = {
|
||||||
request: this.props.requestEventId,
|
request: this.props.requestEventId,
|
||||||
action: this.props.action,
|
action: this.props.action,
|
||||||
verification_algorithms: this.props.verificationAlgorithms,
|
|
||||||
verification_key: this.props.verificationKey,
|
|
||||||
other_user_key: this.props.otherUserKey,
|
other_user_key: this.props.otherUserKey,
|
||||||
};
|
};
|
||||||
for (const key of this.props.keys) {
|
for (const key of this.props.keys) {
|
||||||
|
|
|
@ -45,22 +45,28 @@ export default class VerificationPanel extends React.PureComponent {
|
||||||
if (request.requested) {
|
if (request.requested) {
|
||||||
return (<p>Waiting for {request.otherUserId} to accept ... <Spinner /></p>);
|
return (<p>Waiting for {request.otherUserId} to accept ... <Spinner /></p>);
|
||||||
} else if (request.ready) {
|
} else if (request.ready) {
|
||||||
const keyId = `ed25519:${MatrixClientPeg.get().getCrossSigningId()}`;
|
|
||||||
const qrCodeKeys = [
|
|
||||||
[MatrixClientPeg.get().getDeviceId(), MatrixClientPeg.get().getDeviceEd25519Key()],
|
|
||||||
[keyId, MatrixClientPeg.get().getCrossSigningId()],
|
|
||||||
];
|
|
||||||
const qrCode = <VerificationQRCode
|
|
||||||
keyholderUserId={MatrixClientPeg.get().getUserId()}
|
|
||||||
requestEventId={request.event.eventId}
|
|
||||||
otherUserKey={"todo"}
|
|
||||||
secret={request.encodedSharedSecret}
|
|
||||||
keys={qrCodeKeys}
|
|
||||||
/>;
|
|
||||||
const verifyButton = <AccessibleButton kind="primary" onClick={this._startSAS}>
|
const verifyButton = <AccessibleButton kind="primary" onClick={this._startSAS}>
|
||||||
Verify by emoji
|
Verify by emoji
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
return (<p>{request.otherUserId} is ready, start {verifyButton} or have them scan: {qrCode}</p>);
|
|
||||||
|
if (request.requestEvent && request.requestEvent.getId()) {
|
||||||
|
const keyId = `ed25519:${MatrixClientPeg.get().getCrossSigningId()}`;
|
||||||
|
const qrCodeKeys = [
|
||||||
|
[MatrixClientPeg.get().getDeviceId(), MatrixClientPeg.get().getDeviceEd25519Key()],
|
||||||
|
[keyId, MatrixClientPeg.get().getCrossSigningId()],
|
||||||
|
];
|
||||||
|
const crossSigningInfo = MatrixClientPeg.get().getStoredCrossSigningForUser(request.otherUserId);
|
||||||
|
const qrCode = <VerificationQRCode
|
||||||
|
keyholderUserId={MatrixClientPeg.get().getUserId()}
|
||||||
|
requestEventId={request.requestEvent.getId()}
|
||||||
|
otherUserKey={crossSigningInfo.getId("master")}
|
||||||
|
secret={request.encodedSharedSecret}
|
||||||
|
keys={qrCodeKeys}
|
||||||
|
/>;
|
||||||
|
return (<p>{request.otherUserId} is ready, start {verifyButton} or have them scan: {qrCode}</p>);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<p>{request.otherUserId} is ready, start {verifyButton}</p>);
|
||||||
} else if (request.started) {
|
} else if (request.started) {
|
||||||
if (this.state.sasWaitingForOtherParty) {
|
if (this.state.sasWaitingForOtherParty) {
|
||||||
return <p>Waiting for {request.otherUserId} to confirm ...</p>;
|
return <p>Waiting for {request.otherUserId} to confirm ...</p>;
|
||||||
|
|
Loading…
Reference in New Issue