Merge pull request #28626 from element-hq/t3chguy/web-friendly-buffers
Remove usages of Buffer so we don't need to ship the polyfill
This commit is contained in:
Vendored
+1
-1
@@ -12,7 +12,7 @@ declare module "png-chunks-extract" {
|
||||
data: Uint8Array;
|
||||
}
|
||||
|
||||
function extractPngChunks(data: Uint8Array | Buffer): IChunk[];
|
||||
function extractPngChunks(data: Uint8Array): IChunk[];
|
||||
|
||||
export default extractPngChunks;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { ScalableBloomFilter } from "bloom-filters";
|
||||
import ScalableBloomFilter from "bloom-filters/dist/bloom/scalable-bloom-filter";
|
||||
import { HttpApiEvent, MatrixClient, MatrixEventEvent, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { Error as ErrorEvent } from "@matrix-org/analytics-events/types/typescript/Error";
|
||||
import { DecryptionFailureCode, CryptoEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
@@ -37,7 +37,6 @@ interface IState {
|
||||
userCode?: string;
|
||||
checkCode?: string;
|
||||
failureReason?: FailureReason;
|
||||
lastScannedCode?: Buffer;
|
||||
}
|
||||
|
||||
export enum LoginWithQRFailureReason {
|
||||
@@ -154,7 +153,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
|
||||
throw new Error("Rendezvous not found");
|
||||
}
|
||||
|
||||
if (!this.state.lastScannedCode && this.state.rendezvous?.checkCode !== checkCode) {
|
||||
if (this.state.rendezvous?.checkCode !== checkCode) {
|
||||
this.setState({ failureReason: LoginWithQRFailureReason.CheckCodeMismatch });
|
||||
return;
|
||||
}
|
||||
@@ -201,7 +200,6 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
|
||||
failureReason: undefined,
|
||||
userCode: undefined,
|
||||
checkCode: undefined,
|
||||
lastScannedCode: undefined,
|
||||
mediaPermissionError: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import QRCode from "../QRCode";
|
||||
|
||||
interface IProps {
|
||||
/** The data for the QR code. If `undefined`, a spinner is shown. */
|
||||
qrCodeBytes: undefined | Buffer;
|
||||
qrCodeBytes: undefined | Uint8ClampedArray;
|
||||
}
|
||||
|
||||
export default class VerificationQRCode extends React.PureComponent<IProps> {
|
||||
|
||||
@@ -46,7 +46,7 @@ interface IState {
|
||||
* We attempt to calculate this once the verification request transitions into the "Ready" phase. If the other
|
||||
* side cannot scan QR codes, it will remain `undefined`.
|
||||
*/
|
||||
qrCodeBytes: Buffer | undefined;
|
||||
qrCodeBytes: Uint8ClampedArray | undefined;
|
||||
|
||||
sasEvent: ShowSasCallbacks | null;
|
||||
emojiButtonClicked?: boolean;
|
||||
|
||||
@@ -99,7 +99,7 @@ export default class ThreepidInviteStore extends EventEmitter {
|
||||
|
||||
private generateIdOf(persisted: IPersistedThreepidInvite): string {
|
||||
// Use a consistent "hash" to form an ID.
|
||||
return base32.stringify(Buffer.from(JSON.stringify(persisted)));
|
||||
return base32.stringify(new TextEncoder().encode(JSON.stringify(persisted)));
|
||||
}
|
||||
|
||||
private translateInvite(persisted: IPersistedThreepidInvite): IThreepidInvite {
|
||||
|
||||
@@ -445,7 +445,7 @@ export default class WidgetUtils {
|
||||
// For compatibility with Jitsi, use base32 without padding.
|
||||
// More details here:
|
||||
// https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
|
||||
confId = base32.stringify(Buffer.from(roomId), { pad: false });
|
||||
confId = base32.stringify(new TextEncoder().encode(roomId), { pad: false });
|
||||
} else {
|
||||
// Create a random conference ID
|
||||
confId = `Jitsi${randomUppercaseString(1)}${randomLowercaseString(23)}`;
|
||||
|
||||
@@ -431,7 +431,7 @@ export default class HTMLExporter extends Exporter {
|
||||
!this.needsDateSeparator(event, prevEvent) &&
|
||||
shouldFormContinuation(prevEvent, event, this.room.client, false);
|
||||
const body = await this.createMessageBody(event, shouldBeJoined);
|
||||
this.totalSize += Buffer.byteLength(body);
|
||||
this.totalSize += new TextEncoder().encode(body).byteLength;
|
||||
content += body;
|
||||
prevEvent = event;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export async function buildAndEncodePickleKey(
|
||||
data.encrypted,
|
||||
);
|
||||
if (pickleKeyBuf) {
|
||||
return encodeUnpaddedBase64(pickleKeyBuf);
|
||||
return encodeUnpaddedBase64(new Uint8Array(pickleKeyBuf));
|
||||
}
|
||||
} catch {
|
||||
logger.error("Error decrypting pickle key");
|
||||
|
||||
Reference in New Issue
Block a user