Comparing version 0.9.0-rc8 to 0.9.0-rc9
@@ -22,3 +22,3 @@ var PullStream = require('../PullStream'); | ||
.then(function(vars) { | ||
Object.defineProperty(vars,'source',{value: source}); | ||
source.stream(vars.offsetToStartOfCentralDirectory).pipe(records); | ||
@@ -29,10 +29,11 @@ | ||
.then(function(file) { | ||
file.raw = function(_password) { | ||
var p = source.stream(file.offsetToLocalFileHeader).pipe(PullStream()); | ||
return read.fileStream(p,{password: _password,raw: true}); | ||
}; | ||
file.stream = function(_password, _raw) { | ||
var input = source.stream(file.offsetToLocalFileHeader); | ||
var output = read.fileStream(input.pipe(PullStream()),{password:_password, raw: _raw}); | ||
file.stream = function(_password) { | ||
var p = source.stream(file.offsetToLocalFileHeader).pipe(PullStream()); | ||
return read.fileStream(p,{password:_password}); | ||
input.on('error',function(err) { | ||
output.emit('error',err); | ||
}); | ||
return output; | ||
}; | ||
@@ -39,0 +40,0 @@ |
@@ -67,4 +67,3 @@ var util = require('util'); | ||
entry.vars.then(function(vars) { | ||
entry.vars = vars; | ||
entry.header.then(function(vars) { | ||
var fileSizeKnown = !(vars.flags & 0x08); | ||
@@ -90,3 +89,2 @@ entry.path = vars.path; | ||
entry | ||
.on('error',function(err) { self.emit('error',err);}) | ||
.on('finish', function() { | ||
@@ -93,0 +91,0 @@ Promise.resolve(!fileSizeKnown && read.dataDescriptor(self)) |
@@ -66,3 +66,3 @@ var Stream = require('stream'); | ||
self.removeListener('chunk',pull); | ||
self.emit('error','FILE_ENDED'); | ||
self.emit('error',new Error('FILE_ENDED')); | ||
this.__ended = true; | ||
@@ -105,3 +105,3 @@ return; | ||
if (self.finished) | ||
return reject('FILE_ENDED'); | ||
return reject(new Error('FILE_ENDED')); | ||
self.stream(eof,includeEof) | ||
@@ -108,0 +108,0 @@ .on('error',reject) |
@@ -17,2 +17,9 @@ var Decrypt = require('../Decrypt'); | ||
function emitError(e) { | ||
e.vars = entry.vars; | ||
entry.emit('error',e); | ||
} | ||
p.on('error',emitError); | ||
entry.buffer = function() { | ||
@@ -22,5 +29,5 @@ return BufferStream(entry); | ||
entry.vars = p.pull(30) | ||
entry.header = p.pull(30) | ||
.then(function(data) { | ||
vars = binary.parse(data) | ||
vars = entry.vars = binary.parse(data) | ||
.word32lu('signature') | ||
@@ -63,3 +70,3 @@ .word16lu('versionsNeededToExtract') | ||
entry.vars.then(function(vars) { | ||
entry.header.then(function(vars) { | ||
if (vars.flags & 0x01) { | ||
@@ -71,54 +78,52 @@ vars.compressedSize -= 12; | ||
.then(function(header) { | ||
var fileSizeKnown = !(vars.flags & 0x08), | ||
eof; | ||
var fileSizeKnown = !(vars.flags & 0x08), eof; | ||
if (fileSizeKnown) { | ||
entry.size = vars.uncompressedSize; | ||
eof = vars.compressedSize; | ||
} else { | ||
eof = new Buffer(4); | ||
eof.writeUInt32LE(0x08074b50, 0); | ||
} | ||
if (fileSizeKnown) { | ||
entry.size = vars.uncompressedSize; | ||
eof = vars.compressedSize; | ||
} else { | ||
eof = new Buffer(4); | ||
eof.writeUInt32LE(0x08074b50, 0); | ||
} | ||
var stream = entry.source = p.stream(eof); | ||
var stream = entry.source = p.stream(eof); | ||
if (entry.autodraining) | ||
return stream.pipe(NoopStream()).pipe(entry); | ||
if (entry.autodraining) | ||
return stream.pipe(NoopStream()).pipe(entry); | ||
if (header) { | ||
var _password = opts.password || entry.password; | ||
if (!_password && !entry.autodraining) | ||
throw new Error('MISSING_PASSWORD'); | ||
if (header) { | ||
var _password = opts.password || entry.password; | ||
if (!_password && !entry.autodraining) | ||
throw new Error('MISSING_PASSWORD'); | ||
var decrypt = Decrypt(); | ||
var decrypt = Decrypt(); | ||
String(_password).split('').forEach(function(d) { | ||
decrypt.update(d); | ||
}); | ||
String(_password).split('').forEach(function(d) { | ||
decrypt.update(d); | ||
}); | ||
for (var i=0; i < header.length; i++) | ||
header[i] = decrypt.decryptByte(header[i]); | ||
for (var i=0; i < header.length; i++) | ||
header[i] = decrypt.decryptByte(header[i]); | ||
vars.decrypt = decrypt; | ||
vars.compressedSize -= 12; | ||
vars.decrypt = decrypt; | ||
vars.compressedSize -= 12; | ||
var check = (vars.flags & 0x8) ? (vars.lastModifiedTime >> 8) & 0xff : (vars.crc32 >> 24) & 0xff; | ||
if (header[11] !== check && !entry.autodraining) | ||
throw new Error('BAD_PASSWORD'); | ||
} | ||
var check = (vars.flags & 0x8) ? (vars.lastModifiedTime >> 8) & 0xff : (vars.crc32 >> 24) & 0xff; | ||
if (header[11] !== check && !entry.autodraining) | ||
throw new Error('BAD_PASSWORD'); | ||
} | ||
var inflater = (!vars.compressionMethod || opts.raw) ? Stream.PassThrough() : zlib.createInflateRaw(); | ||
var inflater = (!vars.compressionMethod || opts.raw) ? Stream.PassThrough() : zlib.createInflateRaw(); | ||
if (vars.decrypt) | ||
stream = stream.pipe(vars.decrypt.stream()); | ||
if (vars.decrypt) | ||
stream = stream.pipe(vars.decrypt.stream()); | ||
return stream | ||
.pipe(inflater) | ||
.on('error',function(err) { entry.emit('error',err);}) | ||
.pipe(entry); | ||
}) | ||
.catch(function(e) { | ||
entry.emit('error',e); | ||
}); | ||
return stream | ||
.pipe(inflater) | ||
.on('error',emitError) | ||
.pipe(entry); | ||
}) | ||
.catch(emitError); | ||
return entry; | ||
}; |
{ | ||
"name": "unzipper", | ||
"version": "0.9.0-rc8", | ||
"version": "0.9.0-rc9", | ||
"description": "Unzip cross-platform streaming API ", | ||
@@ -39,3 +39,3 @@ "author": "Evan Oxfeld <eoxfeld@gmail.com>", | ||
"request": "^2.79.0", | ||
"tap": ">= 0.3.0 < 1", | ||
"tap": "^10.3.2", | ||
"temp": ">= 0.4.0 < 1", | ||
@@ -42,0 +42,0 @@ "dirdiff": ">= 0.0.1 < 1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
633
30794