Remove usages of Buffer
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/28626/head
parent
974d3c175a
commit
619e41e3a2
|
@ -42,6 +42,10 @@ module.exports = {
|
||||||
name: "setImmediate",
|
name: "setImmediate",
|
||||||
message: "Use setTimeout instead.",
|
message: "Use setTimeout instead.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Buffer",
|
||||||
|
message: "Buffer is not available in the web.",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
"import/no-duplicates": ["error"],
|
"import/no-duplicates": ["error"],
|
||||||
|
@ -255,6 +259,9 @@ module.exports = {
|
||||||
additionalTestBlockFunctions: ["beforeAll", "beforeEach", "oldBackendOnly"],
|
additionalTestBlockFunctions: ["beforeAll", "beforeEach", "oldBackendOnly"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// These are fine in tests
|
||||||
|
"no-restricted-globals": "off",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ declare module "png-chunks-extract" {
|
||||||
data: Uint8Array;
|
data: Uint8Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractPngChunks(data: Uint8Array | Buffer): IChunk[];
|
function extractPngChunks(data: Uint8Array): IChunk[];
|
||||||
|
|
||||||
export default extractPngChunks;
|
export default extractPngChunks;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ interface IState {
|
||||||
userCode?: string;
|
userCode?: string;
|
||||||
checkCode?: string;
|
checkCode?: string;
|
||||||
failureReason?: FailureReason;
|
failureReason?: FailureReason;
|
||||||
lastScannedCode?: Buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LoginWithQRFailureReason {
|
export enum LoginWithQRFailureReason {
|
||||||
|
@ -154,7 +153,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
|
||||||
throw new Error("Rendezvous not found");
|
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 });
|
this.setState({ failureReason: LoginWithQRFailureReason.CheckCodeMismatch });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +200,6 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
|
||||||
failureReason: undefined,
|
failureReason: undefined,
|
||||||
userCode: undefined,
|
userCode: undefined,
|
||||||
checkCode: undefined,
|
checkCode: undefined,
|
||||||
lastScannedCode: undefined,
|
|
||||||
mediaPermissionError: false,
|
mediaPermissionError: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ export default class ThreepidInviteStore extends EventEmitter {
|
||||||
|
|
||||||
private generateIdOf(persisted: IPersistedThreepidInvite): string {
|
private generateIdOf(persisted: IPersistedThreepidInvite): string {
|
||||||
// Use a consistent "hash" to form an ID.
|
// 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 {
|
private translateInvite(persisted: IPersistedThreepidInvite): IThreepidInvite {
|
||||||
|
|
|
@ -445,7 +445,7 @@ export default class WidgetUtils {
|
||||||
// For compatibility with Jitsi, use base32 without padding.
|
// For compatibility with Jitsi, use base32 without padding.
|
||||||
// More details here:
|
// More details here:
|
||||||
// https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
|
// 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 {
|
} else {
|
||||||
// Create a random conference ID
|
// Create a random conference ID
|
||||||
confId = `Jitsi${randomUppercaseString(1)}${randomLowercaseString(23)}`;
|
confId = `Jitsi${randomUppercaseString(1)}${randomLowercaseString(23)}`;
|
||||||
|
|
|
@ -431,7 +431,7 @@ export default class HTMLExporter extends Exporter {
|
||||||
!this.needsDateSeparator(event, prevEvent) &&
|
!this.needsDateSeparator(event, prevEvent) &&
|
||||||
shouldFormContinuation(prevEvent, event, this.room.client, false);
|
shouldFormContinuation(prevEvent, event, this.room.client, false);
|
||||||
const body = await this.createMessageBody(event, shouldBeJoined);
|
const body = await this.createMessageBody(event, shouldBeJoined);
|
||||||
this.totalSize += Buffer.byteLength(body);
|
this.totalSize += new TextEncoder().encode(body).byteLength;
|
||||||
content += body;
|
content += body;
|
||||||
prevEvent = event;
|
prevEvent = event;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue