UNPKG

1.55 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3import { Transform } from 'stream';
4import { CRC32CValidatorGenerator } from './crc32c';
5interface HashStreamValidatorOptions {
6 /** Enables CRC32C calculation. To validate a provided value use `crc32cExpected`. */
7 crc32c: boolean;
8 /** Enables MD5 calculation. To validate a provided value use `md5Expected`. */
9 md5: boolean;
10 /** Set a custom CRC32C generator */
11 crc32cGenerator: CRC32CValidatorGenerator;
12 /** Sets the expected CRC32C value to verify once all data has been consumed. Also sets the `crc32c` option to `true` */
13 crc32cExpected?: string;
14 /** Sets the expected MD5 value to verify once all data has been consumed. Also sets the `md5` option to `true` */
15 md5Expected?: string;
16 /** Indicates whether or not to run a validation check or only update the hash values */
17 updateHashesOnly?: boolean;
18}
19declare class HashStreamValidator extends Transform {
20 #private;
21 readonly crc32cEnabled: boolean;
22 readonly md5Enabled: boolean;
23 readonly crc32cExpected: string | undefined;
24 readonly md5Expected: string | undefined;
25 readonly updateHashesOnly: boolean;
26 constructor(options?: Partial<HashStreamValidatorOptions>);
27 _flush(callback: (error?: Error | null | undefined) => void): void;
28 _transform(chunk: Buffer, encoding: BufferEncoding, callback: (e?: Error) => void): void;
29 test(hash: 'crc32c' | 'md5', sum: Buffer | string): boolean;
30}
31export { HashStreamValidator, HashStreamValidatorOptions };