Don't use js-sdk's base64 encode function

It uses the NodeJS Buffer global which presumably is provided by
Webpack in element-web but isn't here, apparently.
This commit is contained in:
David Baker
2023-10-05 17:57:23 +01:00
parent d373081db1
commit 87d5062d34

View File

@@ -28,7 +28,6 @@ import {
GroupCallIntent,
GroupCallType,
} from "matrix-js-sdk/src/webrtc/groupCall";
import { encodeUnpaddedBase64 } from "matrix-js-sdk/src/common-crypto/base64";
import type { MatrixClient } from "matrix-js-sdk/src/client";
import type { Room } from "matrix-js-sdk/src/models/room";
@@ -77,7 +76,9 @@ function waitForSync(client: MatrixClient) {
function secureRandomString(entropyBytes: number): string {
const key = new Uint8Array(entropyBytes);
crypto.getRandomValues(key);
return encodeUnpaddedBase64(key);
return btoa(
key.reduce((acc, current) => acc + String.fromCharCode(current), "")
).replace(/=*$/, "");
}
/**