You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Update QR code handling for new URL
This doesn't have any meaningful change on the process, just makes it more in line with what we do.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018 New Vector Ltd
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -26,6 +27,7 @@ import {
|
|||||||
newUserCancelledError,
|
newUserCancelledError,
|
||||||
newUserMismatchError,
|
newUserMismatchError,
|
||||||
} from './Error';
|
} from './Error';
|
||||||
|
import * as qs from "qs";
|
||||||
|
|
||||||
const MATRIXTO_REGEXP = /^(?:https?:\/\/)?(?:www\.)?matrix\.to\/#\/([#@!+][^?]+)\?(.+)$/;
|
const MATRIXTO_REGEXP = /^(?:https?:\/\/)?(?:www\.)?matrix\.to\/#\/([#@!+][^?]+)\?(.+)$/;
|
||||||
const KEY_REGEXP = /^key_([^:]+:.+)$/;
|
const KEY_REGEXP = /^key_([^:]+:.+)$/;
|
||||||
@@ -39,13 +41,25 @@ const newQRCodeError = errorFactory("m.qr_code.invalid", "Invalid QR code");
|
|||||||
export class ShowQRCode extends Base {
|
export class ShowQRCode extends Base {
|
||||||
_doVerification() {
|
_doVerification() {
|
||||||
if (!this._done) {
|
if (!this._done) {
|
||||||
const url = "https://matrix.to/#/" + this._baseApis.getUserId()
|
const crossSigningInfo = this._baseApis.getStoredCrossSigningForUser(this.request.otherUserId);
|
||||||
+ "?device=" + encodeURIComponent(this._baseApis.deviceId)
|
const myKeyId = this._baseApis.getCrossSigningId();
|
||||||
+ "&action=verify&key_ed25519%3A"
|
const qrCodeKeys = [
|
||||||
+ encodeURIComponent(this._baseApis.deviceId) + "="
|
[this._baseApis.getDeviceId(), this._baseApis.getDeviceEd25519Key()],
|
||||||
+ encodeURIComponent(this._baseApis.getDeviceEd25519Key());
|
[myKeyId, myKeyId],
|
||||||
|
];
|
||||||
|
const query = {
|
||||||
|
request: this.request.requestEvent.getId(),
|
||||||
|
action: "verify",
|
||||||
|
secret: this.request.encodedSharedSecret,
|
||||||
|
other_user_key: crossSigningInfo.getId("master"),
|
||||||
|
};
|
||||||
|
for (const key of qrCodeKeys) {
|
||||||
|
query[`key_${key[0]}`] = key[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
const uri = `https://matrix.to/#/${this._baseApis.getUserId()}?${qs.stringify(query)}`;
|
||||||
this.emit("show_qr_code", {
|
this.emit("show_qr_code", {
|
||||||
url: url,
|
url: uri,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user