Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'));
}
};