Socket
Socket
Sign inDemoInstall

zip-stream

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zip-stream - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

APPNOTE.txt

86

lib/headers.js

@@ -13,7 +13,46 @@ /**

var DEFAULT_FILE_MODE = 0100664;
var DEFAULT_DIR_MODE = 040755;
var BASE_FILE_MODE = 0100000;
var BASE_DIR_MODE = 040000;
var DEFAULT_FILE_MODE = 0100644; // 644 -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
var DEFAULT_DIR_MODE = 040755; // 755 drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
var EXT_FILE_ATTR_DIR = 010173200020; // 755 drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D)
var EXT_FILE_ATTR_FILE = 020151000040; // 644 -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0
// Unix file types
var S_IFIFO = 010000; // named pipe (fifo)
var S_IFCHR = 020000; // character special
var S_IFDIR = 040000; // directory
var S_IFBLK = 060000; // block special
var S_IFREG = 0100000; // regular
var S_IFLNK = 0120000; // symbolic link
var S_IFSOCK = 0140000; // socket
var S_IRWXU = 0700; // RWX mask for owner
var S_IRUSR = 0400; // R for owner
var S_IWUSR = 0200; // W for owner
var S_IXUSR = 0100; // X for owner
var S_IRWXG = 070; // RWX mask for group
var S_IRGRP = 040; // R for group
var S_IWGRP = 020; // W for group
var S_IXGRP = 010; // X for group
var S_IRWXO = 07; // RWX mask for other
var S_IROTH = 04; // R for other
var S_IWOTH = 02; // W for other
var S_IXOTH = 01; // X for other
var S_ISVTX = 01000; // save swapped text even after use
// setuid/setgid/sticky bits
var S_ISUID = 04000; // set user id on execution
var S_ISGID = 02000; // set group id on execution
var S_ISTXT = 01000; // sticky bit
// DOS file type flags
var S_DOS_A = 040; // Archive
var S_DOS_D = 020; // Directory
var S_DOS_V = 010; // Volume
var S_DOS_S = 04; // System
var S_DOS_H = 02; // Hidden
var S_DOS_R = 01; // Read Only
function ZipHeader() {

@@ -42,11 +81,5 @@ this.name = 'zipHeader';

var noAssert = false;
if (field.name === 'externalFileAttributes') {
noAssert = true;
}
if (typeof buf['write' + field.type] === 'function') {
debug('%s:%s:%s:%d+%d', self.name, field.type, field.name, offset, field.len);
buf['write' + field.type](val, offset, noAssert);
buf['write' + field.type](val, offset);
} else if (val.length > 0) {

@@ -88,2 +121,15 @@ debug('%s:%s:%d+%d', self.name, field.name, offset, val.length);

ZipHeader.prototype._generateExternalAttributes = function(mode, type) {
var isDir = type === 'directory';
var owner = (mode >> 6) & 07;
var group = (mode >> 3) & 07;
var other = mode & 07;
var attr = isDir ? S_IFDIR : S_IFREG;
attr |= ((owner & 07) << 6) | ((group & 07) << 3) | (other & 07);
return (attr << 16) | (isDir ? S_DOS_D : S_DOS_A);
};
ZipHeader.prototype._normalize = function(data) {

@@ -120,5 +166,11 @@ // Don't always set mode as this is a experimental feature

if (data.mode) {
data.mode &= ~BASE_DIR_MODE;
data.mode |= BASE_FILE_MODE;
data.externalFileAttributes = (data.mode << 16);
data.mode &= ~S_IFDIR;
if (data.type === 'file') {
data.mode |= S_IFREG;
}
data.externalFileAttributes &= ~data.externalFileAttributes;
data.externalFileAttributes |= this._generateExternalAttributes(data.mode, data.type);
data.externalFileAttributes >>>= 0;
}

@@ -140,3 +192,3 @@

{name: 'lastModifiedDate', len: 4, type: 'UInt32LE'},
{name: 'crc32', len: 4, type: 'Int32LE', def: 0},
{name: 'crc32', len: 4, type: 'UInt32LE', def: 0},
{name: 'compressedSize', len: 4, type: 'UInt32LE'},

@@ -159,3 +211,3 @@ {name: 'uncompressedSize', len: 4, type: 'UInt32LE'},

{name: 'signature', len: 4, type: 'UInt32LE', def: 0x08074b50},
{name: 'crc32', len: 4, type: 'Int32LE'},
{name: 'crc32', len: 4, type: 'UInt32LE'},
{name: 'compressedSize', len: 4, type: 'UInt32LE'},

@@ -179,3 +231,3 @@ {name: 'uncompressedSize', len: 4, type: 'UInt32LE'}

{name: 'lastModifiedDate', len: 4, type: 'UInt32LE'},
{name: 'crc32', len: 4, type: 'Int32LE'},
{name: 'crc32', len: 4, type: 'UInt32LE'},
{name: 'compressedSize', len: 4, type: 'UInt32LE'},

@@ -182,0 +234,0 @@ {name: 'uncompressedSize', len: 4, type: 'UInt32LE'},

@@ -87,2 +87,6 @@ /**

CRC32.prototype.update = function(data) {
if (!Buffer.isBuffer(data)) {
data = new Buffer(data);
}
for (var i = 0; i < data.length; i++) {

@@ -96,5 +100,9 @@ this.crc = (this.crc >>> 8) ^ lookup[(this.crc ^ data[i]) & 0xff];

CRC32.prototype.digest = function() {
return this.crc ^ -1;
return (this.crc ^ -1) >>> 0;
};
CRC32.prototype.hex = function() {
return this.digest().toString(16).toUpperCase();
};
module.exports = CRC32;

2

package.json
{
"name": "zip-stream",
"version": "0.2.2",
"version": "0.2.3",
"description": "a streaming zip generator.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-zip-stream",

@@ -1,5 +0,7 @@

# zip-stream v0.2.2 [![Build Status](https://secure.travis-ci.org/ctalkington/node-zip-stream.png?branch=master)](http://travis-ci.org/ctalkington/node-zip-stream)
# zip-stream v0.2.3 [![Build Status](https://travis-ci.org/ctalkington/node-zip-stream.svg?branch=master)](https://travis-ci.org/ctalkington/node-zip-stream)
zip-stream is a streaming zip generator. It was built to be a successor to [zipstream](https://npmjs.org/package/zipstream). Dependencies are kept to a minimum through the use of many of node's built-in modules including the use of zlib module for compression.
[![NPM](https://nodei.co/npm/zip-stream.png)](https://nodei.co/npm/zip-stream/)
### Install

@@ -6,0 +8,0 @@

@@ -219,3 +219,3 @@ /*global before,describe,it */

testStream.on('close', function() {
assert.equal(testStream.digest, '41da8a79fb25b46b594105eb8618b6ebb0ed3135');
assert.equal(testStream.digest, 'a6abe53ecf77cf64ff9c024b55200695656e1bf1');
done();

@@ -222,0 +222,0 @@ });

@@ -28,3 +28,3 @@ /*global before,describe,it */

checksum.on('end', function() {
assert.equal(checksum.digest, -270675091);
assert.equal(checksum.digest, 4024292205);

@@ -60,3 +60,3 @@ done();

assert.equal(actual.crc, 323269802);
assert.equal(actual.crc, 943146542);
});

@@ -67,5 +67,5 @@ });

it('should update CRC32 based on data', function() {
var actual = utils.crc32().update('testing checksum');
var actual = utils.crc32().update('testing checksum update');
assert.equal(actual.crc, 323269802);
assert.equal(actual.crc, -2042121681);
});

@@ -76,8 +76,16 @@ });

it('should return digest of CRC32', function() {
var actual = utils.crc32().update('testing checksum').digest();
var actual = utils.crc32('testing checksum').digest();
assert.equal(actual, -323269803);
assert.equal(actual, 3351820753);
});
});
describe('#hex()', function() {
it('should return hex digest of CRC32', function() {
var actual = utils.crc32('testing checksum').hex();
assert.equal(actual, 'C7C8B9D1');
});
});
});

@@ -84,0 +92,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc