From cd82d97c3eb3c1035cbbe73f6f4741665b3f3b45 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 15 Feb 2021 08:53:37 -0700 Subject: [PATCH 1/2] Use randomly generated conference names for Jitsi Fixes https://github.com/vector-im/element-web/issues/15205 Replaces https://github.com/matrix-org/matrix-react-sdk/pull/5322 This change uses a random ID for the Jitsi conference name to avoid any badly-named Jitsi calls, and overrides the "subject" (title) of the call so end users aren't typically exposed to the random ID. --- package.json | 1 - src/CallHandler.tsx | 5 +++-- src/utils/NamingUtils.ts | 29 ----------------------------- src/utils/WidgetUtils.ts | 1 + yarn.lock | 13 ------------- 5 files changed, 4 insertions(+), 45 deletions(-) delete mode 100644 src/utils/NamingUtils.ts diff --git a/package.json b/package.json index 2263c7de32..61c8cb7a2c 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,6 @@ "pako": "^2.0.3", "parse5": "^6.0.1", "png-chunks-extract": "^1.0.0", - "project-name-generator": "^2.1.9", "prop-types": "^15.7.2", "qrcode": "^1.4.4", "qs": "^6.9.6", diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index 41a5941092..e09a47cf97 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -64,7 +64,6 @@ import dis from './dispatcher/dispatcher'; import WidgetUtils from './utils/WidgetUtils'; import WidgetEchoStore from './stores/WidgetEchoStore'; import SettingsStore from './settings/SettingsStore'; -import {generateHumanReadableId} from "./utils/NamingUtils"; import {Jitsi} from "./widgets/Jitsi"; import {WidgetType} from "./widgets/WidgetType"; import {SettingLevel} from "./settings/SettingLevel"; @@ -86,6 +85,7 @@ import DesktopCapturerSourcePicker from "./components/views/elements/DesktopCapt import { Action } from './dispatcher/actions'; import { roomForVirtualRoom, getOrCreateVirtualRoomForRoom } from './VoipUserMapper'; import { addManagedHybridWidget, isManagedHybridWidgetEnabled } from './widgets/ManagedHybrid'; +import { randomString } from "matrix-js-sdk/lib/randomstring"; const CHECK_PSTN_SUPPORT_ATTEMPTS = 3; @@ -780,7 +780,7 @@ export default class CallHandler { confId = base32.stringify(Buffer.from(roomId), { pad: false }); } else { // Create a random human readable conference ID - confId = `JitsiConference${generateHumanReadableId()}`; + confId = `JitsiConference${randomString(32)}`; } let widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl({auth: jitsiAuth}); @@ -796,6 +796,7 @@ export default class CallHandler { isAudioOnly: type === 'voice', domain: jitsiDomain, auth: jitsiAuth, + roomName: room.name, }; const widgetId = ( diff --git a/src/utils/NamingUtils.ts b/src/utils/NamingUtils.ts deleted file mode 100644 index 44ccb9b030..0000000000 --- a/src/utils/NamingUtils.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2020 The Matrix.org Foundation C.I.C. - -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. -*/ - -import * as projectNameGenerator from "project-name-generator"; - -/** - * Generates a human readable identifier. This should not be used for anything - * which needs secure/cryptographic random: just a level uniquness that is offered - * by something like Date.now(). - * @returns {string} The randomly generated ID - */ -export function generateHumanReadableId(): string { - return projectNameGenerator({words: 3}).raw.map(w => { - return w[0].toUpperCase() + w.substring(1).toLowerCase(); - }).join(''); -} diff --git a/src/utils/WidgetUtils.ts b/src/utils/WidgetUtils.ts index db2b10b295..c67f3bad13 100644 --- a/src/utils/WidgetUtils.ts +++ b/src/utils/WidgetUtils.ts @@ -477,6 +477,7 @@ export default class WidgetUtils { 'userId=$matrix_user_id', 'roomId=$matrix_room_id', 'theme=$theme', + 'roomName=$roomName', ]; if (opts.auth) { queryStringParts.push(`auth=${opts.auth}`); diff --git a/yarn.lock b/yarn.lock index 1a350f697a..9bd51f16a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2477,11 +2477,6 @@ commander@^4.0.1: resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== -commander@^6.1.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" - integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== - commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -6453,14 +6448,6 @@ progress@^2.0.0: resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== -project-name-generator@^2.1.9: - version "2.1.9" - resolved "https://registry.yarnpkg.com/project-name-generator/-/project-name-generator-2.1.9.tgz#959177f1feb2355d74fa98745d72a65a5f75b674" - integrity sha512-QmLHqz2C4VHmAyDEAFlVfnuWAHr4vwZhK2bbm4IrwuHNzNKOdG9b4U+NmQbsm1uOoV4kGWv7+FVLsu7Bb/ieYQ== - dependencies: - commander "^6.1.0" - lodash "^4.17.20" - promise@^7.0.3, promise@^7.1.1: version "7.3.1" resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" From cb757b5b50a645932547a94f7b46d851ea34e9c1 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 15 Feb 2021 08:56:38 -0700 Subject: [PATCH 2/2] Fix import --- src/CallHandler.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index e09a47cf97..f106d75f8b 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -85,7 +85,7 @@ import DesktopCapturerSourcePicker from "./components/views/elements/DesktopCapt import { Action } from './dispatcher/actions'; import { roomForVirtualRoom, getOrCreateVirtualRoomForRoom } from './VoipUserMapper'; import { addManagedHybridWidget, isManagedHybridWidgetEnabled } from './widgets/ManagedHybrid'; -import { randomString } from "matrix-js-sdk/lib/randomstring"; +import { randomString } from "matrix-js-sdk/src/randomstring"; const CHECK_PSTN_SUPPORT_ATTEMPTS = 3;