zlib.js 453 B

123456789
  1. import { promisify } from 'util';
  2. import { inflateRaw as inflateRawCb, deflateRaw as deflateRawCb } from 'zlib';
  3. import { JWEDecompressionFailed } from '../util/errors.js';
  4. const inflateRaw = promisify(inflateRawCb);
  5. const deflateRaw = promisify(deflateRawCb);
  6. export const inflate = (input) => inflateRaw(input, { maxOutputLength: 250000 }).catch(() => {
  7. throw new JWEDecompressionFailed();
  8. });
  9. export const deflate = (input) => deflateRaw(input);