Files
libsignal/node/ts/WebpSanitizer.ts
Jordan Rose 85686caa01 node: Combine Native.js and .d.ts into Native.ts
This allows the file to be checked by tsc, which would have caught
some of the missing type aliases sooner (now added to Native.ts.in).
Strictly speaking the behavior is slightly different: we have returned
to exporting many items individually instead of collecting them on a
single object.

Co-authored-by: Alex Bakon <akonradi@signal.org>
2025-10-15 17:50:37 -07:00

33 lines
891 B
TypeScript

//
// Copyright 2023 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
/**
* A WebP format “sanitizer”.
*
* The sanitizer currently simply checks the validity of a WebP file input, so that passing a malformed file to an
* unsafe parser can be avoided.
*
* @module WebpSanitizer
*/
import * as Native from './Native.js';
import type {
IoError,
InvalidMediaInputError,
UnsupportedMediaInputError,
} from './Errors.js';
/**
* Sanitize a WebP input.
*
* @param input A WebP format input stream.
* @throws {IoError} If an IO error on the input occurs.
* @throws {InvalidMediaInputError} If the input could not be parsed because it was invalid.
* @throws {UnsupportedMediaInputError} If the input could not be parsed because it's unsupported in some way.
*/
export function sanitize(input: Uint8Array): void {
Native.WebpSanitizer_Sanitize(input);
}