mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 01:35:22 +02:00
node: Move TypeScript source files into ts/ directory
This way, files that reference the non-compiled Native.js/.d.ts can consistently refer to it as '../Native' without having to copy anything around.
This commit is contained in:
37
node/ts/zkgroup/internal/ByteArray.ts
Normal file
37
node/ts/zkgroup/internal/ByteArray.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2020-2021 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
import { SignalClientErrorBase } from '../../Errors';
|
||||
|
||||
export default class ByteArray {
|
||||
contents: Buffer;
|
||||
|
||||
constructor(contents: Buffer, checkValid: (contents: Buffer) => void) {
|
||||
checkValid(contents);
|
||||
this.contents = Buffer.from(contents);
|
||||
}
|
||||
|
||||
protected static checkLength(
|
||||
expectedLength: number
|
||||
): (contents: Buffer) => void {
|
||||
return contents => {
|
||||
if (contents.length !== expectedLength) {
|
||||
throw new SignalClientErrorBase(
|
||||
`Length of array supplied was ${contents.length} expected ${expectedLength}`,
|
||||
undefined,
|
||||
this.name
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public getContents(): Buffer {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public serialize(): Buffer {
|
||||
return Buffer.from(this.contents);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user