mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 01:35:22 +02:00
Update all Uint8Array/Buffer to use ArrayBuffer
Co-authored-by: Jordan Rose <jrose@signal.org>
This commit is contained in:
@@ -9,11 +9,13 @@ import * as Native from '../../Native.js';
|
||||
export const UNCHECKED_AND_UNCLONED: unique symbol = Symbol();
|
||||
|
||||
export default class ByteArray {
|
||||
contents: Uint8Array;
|
||||
contents: Uint8Array<ArrayBuffer>;
|
||||
|
||||
protected constructor(
|
||||
contents: Uint8Array,
|
||||
checkValid: ((contents: Uint8Array) => void) | typeof UNCHECKED_AND_UNCLONED
|
||||
contents: Uint8Array<ArrayBuffer>,
|
||||
checkValid:
|
||||
| ((contents: Uint8Array<ArrayBuffer>) => void)
|
||||
| typeof UNCHECKED_AND_UNCLONED
|
||||
) {
|
||||
if (checkValid === UNCHECKED_AND_UNCLONED) {
|
||||
this.contents = contents;
|
||||
@@ -25,7 +27,7 @@ export default class ByteArray {
|
||||
|
||||
protected static checkLength(
|
||||
expectedLength: number
|
||||
): (contents: Uint8Array) => void {
|
||||
): (contents: Uint8Array<ArrayBuffer>) => void {
|
||||
return (contents) => {
|
||||
if (contents.length !== expectedLength) {
|
||||
throw new LibSignalErrorBase(
|
||||
@@ -37,11 +39,11 @@ export default class ByteArray {
|
||||
};
|
||||
}
|
||||
|
||||
public getContents(): Uint8Array {
|
||||
public getContents(): Uint8Array<ArrayBuffer> {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public serialize(): Uint8Array {
|
||||
public serialize(): Uint8Array<ArrayBuffer> {
|
||||
return Uint8Array.from(this.contents);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user