How to use the compress-commons/lib/archivers/zip/constants.MIN_VERSION_DATA_DESCRIPTOR function in compress-commons

To help you get started, we’ve selected a few compress-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github artem-karpenko / archiver-zip-encrypted / lib / zip20 / zip-crypto-stream.js View on Github external
ZipCryptoStream.prototype._appendStream = function(ae, source, callback) {
    ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);

    ae.getGeneralPurposeBit().useDataDescriptor(false);
    // we will write local file header after we get CRC back
    // it seems as if using data descriptor is not supported when encrypting data with ZipCrypto
    // so we have to write CRC into local file header
    // this._writeLocalFileHeader(ae);

    var smart = this._smartStream(ae, callback);
    source.once('error', function(err) {
        smart.emit('error', err);
        smart.end();
    });
    source.pipe(smart);
};
github ksoichiro / node-archiver-zip-encryptable / lib / zip-crypto-stream.js View on Github external
ZipCryptoStream.prototype._appendBuffer = function(ae, source, callback) {
  ae.gpb.useEncryption(true);
  // Use data descriptor whatever the method is,
  // because when using encryption, we need to calculate
  // the compressed size with encrypted data.
  ae.gpb.useDataDescriptor(true);
  ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);

  if (source.length === 0) {
    ae.setMethod(constants.METHOD_STORED);
  }

  this._writeLocalFileHeader(ae);

  var method = ae.getMethod();
  if (
    method === constants.METHOD_STORED ||
    method === constants.METHOD_DEFLATED
  ) {
    this._smartStream(ae, callback).end(source);
  } else {
    callback(new Error('compression method ' + method + ' not implemented'));
  }