read-excel-file 9.0.10 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,24 +4,48 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = unzipFromStream;
7
+ var _fflate = require("fflate");
7
8
  var _buffer = require("buffer");
8
- var _unzipper = _interopRequireDefault(require("unzipper"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
- // `unzipper` has a bug when it doesn't include "@aws-sdk/client-s3" package in the `dependencies`
11
- // which causes some "bundlers" throw an error.
12
- // https://github.com/ZJONSSON/node-unzipper/issues/330
9
+ // This code was originally submitted by Stian Jensen.
10
+ // https://github.com/catamphetamine/read-excel-file/pull/122
11
+
12
+ // A `*.zip` file consists of individual file entries with the "total" summary section
13
+ // placed at the end of the file rather than at the start of it, which was originally done
14
+ // to allow for easy append of data to a given `.zip` file.
15
+ // https://en.wikipedia.org/wiki/ZIP_(file_format)
16
+ //
17
+ // But this also means that reading a `*.zip` file from a stream can't really be done
18
+ // using the "officially recommended" way of first reading the "total" summary section
19
+ // and only then reading the individual file entries specified in that summary section.
20
+ //
21
+ // So in order to be able to read a `*.zip` file from a stream, some corners have to be cut.
22
+ // For example, the "total" summary section is completely ignored and instead the reader
23
+ // should adopt "data recovery" software approach — it should proactively "scan" the input stream
24
+ // for individual file entries and handle them one-by-one as they come.
13
25
  //
14
- // One workaround is to install "@aws-sdk/client-s3" package manually, which would still lead to increased bundle size.
15
- // If the code is bundled for server-side-use only, that is will not be used in a web browser,
16
- // then the increased bundle size would not be an issue.
26
+ // Such approach doesn't seem to contradict with the XLSX specification
27
+ // because an `*.xlsx` files is supposed to be a normal `.zip` archive
28
+ // without any "trickery" such as "deleted" files or "garbage" data
29
+ // hiding under the hood.
17
30
  //
18
- // Another workaround could be to "alias" "@aws-sdk/client-s3" package in a "bundler" configuration file
19
- // with a path to a `*.js` file containing just "export default null". But that kind of a workaround would also
20
- // result in errors when using other packages that `import` anything from "@aws-sdk/client-s3" package,
21
- // so it's not really a workaround but more of a ticking bomb.
31
+ // So when handling `*.xlsx` file, we assume that each such file must start
32
+ // with an individual file entry followed by another individual file entry, etc.
22
33
  //
23
- // Althernatively, it could use `fflate` if someone writes an example of handling a Node.js stream.
34
+ // When the "summary" section is reached, we assume that the archive has ended.
35
+ //
36
+ // To read a `.zip` archive, the code uses `fflate`'s `Unzip` class
37
+ // with `UnzipInflate` decompression implementation to decompress the data
38
+ // that was previously compressed using `DEFLATE` compressing algorithm,
39
+ // which is what `*.xlsx` files use.
40
+ //
41
+ // The `Unzip` class doesn't speak the Node.js stream interface, and `fflate`'s readme
42
+ // doesn't include a clear "reading a `.zip` file from a Node.js stream" section.
24
43
  // https://github.com/101arrowz/fflate/issues/251
44
+ // Instead, the `Unzip` class has its own `push(chunk)` / `onfile` / `entry.ondata` protocol.
45
+ // This code reads the binary input stream and forwards each chunk of it to `unzip.push()`,
46
+ // and then collects the decompressed file entries.
47
+ //
48
+
25
49
  /**
26
50
  * Reads `*.zip` file contents.
27
51
  * @param {Stream} stream
@@ -33,7 +57,6 @@ function unzipFromStream(stream) {
33
57
  // The `files` object stores the files and their contents.
34
58
  var files = {};
35
59
  return new Promise(function (resolve, reject) {
36
- var promises = [];
37
60
  var errored = false;
38
61
  var onError = function onError(error) {
39
62
  if (!errored) {
@@ -41,83 +64,137 @@ function unzipFromStream(stream) {
41
64
  reject(error);
42
65
  }
43
66
  };
44
- stream
45
- // This first "error" listener catches the original stream errors.
46
- //
47
- // That's because the .pipe() method does not automatically propagate errors
48
- // from a source (input) stream to the destination stream or the end of the pipeline.
49
- // You would need to attach an 'error' event handler to each stream in the chain.
50
- //
51
- // A more convenient alternative would be to use `stream.pipeline()` function:
52
- // `pipeline(stream1, stream2, (error) => { ... })`
53
- //
54
- .on('error', onError)
55
- // Pipe the input stream through the unzipper stream.
56
- .pipe(_unzipper["default"].Parse())
57
- // This second "error" listener catches the unzipper stream errors.
58
- //
59
- // That's because the .pipe() method does not automatically propagate errors
60
- // from a source (input) stream to the destination stream or the end of the pipeline.
61
- // You would need to attach an 'error' event handler to each stream in the chain.
62
- //
63
- // A more convenient alternative would be to use `stream.pipeline()` function:
64
- // `pipeline(stream1, stream2, (error) => { ... })`
65
- //
66
- .on('error', onError)
67
- // The unzipper stream is closed when all `entries` have been reported.
68
- .on('finish', function () {
69
- if (!errored) {
70
- // Wait for all `entries` to be read.
71
- // The second argument of `.then()` function is not required
72
- // but I didn't remove it just to potentially prevent any potential silly bugs
73
- // in case of some potential changes in some potential future.
74
- Promise.all(promises).then(function () {
75
- resolve(files);
76
- }, onError);
67
+ var _createZipFileValidat = createZipFileValidator(function (isValid) {
68
+ if (!isValid) {
69
+ onError(new Error('Invalid `.zip` archive'));
70
+ }
71
+ }),
72
+ validateChunk = _createZipFileValidat.validateChunk;
73
+
74
+ // `Unzip` discovers each individual file entry in the input data stream
75
+ // and then calls the callback function for each such entry.
76
+ var unzip = new _fflate.Unzip(function (entry) {
77
+ // If there already was an error while reading this `.zip` file,
78
+ // ignore any follow-up entries.
79
+ if (errored) {
80
+ return;
81
+ }
82
+
83
+ // Skip directory entries (their names end with a slash).
84
+ // Only files are of any interest.
85
+ if (entry.name.endsWith('/')) {
86
+ return;
77
87
  }
78
- }).on('entry', function (entry) {
88
+
79
89
  // See if this file should be ignored.
80
- var ignore = false;
81
- // `entry.type` could be 'Directory' or 'File'.
82
- // Ignore anything except files.
83
- if (entry.type === 'Directory') {
84
- ignore = true;
90
+ // If it should, this entry won't be processed, i.e. `Unzip` will not try
91
+ // to decompress its data, and will just discard it.
92
+ if (filter && !filter({
93
+ path: entry.name
94
+ })) {
95
+ return;
96
+ }
97
+ var chunks = [];
98
+
99
+ // `entry.ondata` is called with each decompressed chunk of the entry,
100
+ // and a final time with `isLast === true` once the entry is complete.
101
+ entry.ondata = function (error, chunk, isLast) {
102
+ if (error) {
103
+ return onError(error);
104
+ }
105
+ chunks.push(chunk);
106
+ if (isLast) {
107
+ files[entry.name] = _buffer.Buffer.concat(chunks);
108
+ }
109
+ };
110
+
111
+ // Start decompressing this entry.
112
+ entry.start();
113
+ });
114
+
115
+ // Register the decompressor for the data that was compressed using
116
+ // `DEFLATE` compression algorithm (compression method `8`),
117
+ // which is what `.xlsx` files use.
118
+ unzip.register(_fflate.UnzipInflate);
119
+ stream
120
+ // Catch errors emitted from the input stream (for example, a file read error).
121
+ .on('error', onError)
122
+ // When another chunk of data is read from the input stream.
123
+ .on('data', function (chunk) {
124
+ // If there already was an error while reading this `.zip` file,
125
+ // ignore any follow-up data chunks.
126
+ if (errored) {
127
+ return;
85
128
  }
129
+ // Validate the `.zip` archive as its data comes through.
130
+ validateChunk(chunk);
131
+ // If the `.zip` archive is found to be invalid, stop any further
132
+ // processing of it.
86
133
  if (errored) {
87
- ignore = true;
134
+ return;
88
135
  }
89
- if (filter) {
90
- if (!filter({
91
- path: entry.path
92
- })) {
93
- ignore = true;
94
- }
136
+ // Push the next data chunk to `fflate`'s `Unzip` class instance.
137
+ // The `.push()` function is synchronous, meaning that by the time it returns,
138
+ // any complete files entries encountered so far have already been decompressed
139
+ // and populated in the `files` object.
140
+ try {
141
+ unzip.push(chunk, false);
142
+ } catch (error) {
143
+ onError(error);
95
144
  }
96
-
97
- // If this file should be ignored.
98
- if (ignore) {
99
- // Call `entry.autodrain()` when you do not intend to process a specific `entry`'s raw data.
100
- // Otherwise, if an `entry` is not consumed (via .pipe(), .buffer(), or .autodrain()),
101
- // the stream will halt, preventing further file processing.
102
- entry.autodrain().on('error', onError);
145
+ })
146
+ // When there's no more data in the input stream to consume,
147
+ // finish reading the `.zip` archive.
148
+ .on('end', function () {
149
+ // If there were any errors when reading the `.zip` archive,
150
+ // don't `resolve()` with anything.
151
+ if (errored) {
103
152
  return;
104
153
  }
105
- var chunks = [];
106
- promises.push(new Promise(function (resolve) {
107
- // `entry` seems to be a generic Node.js stream.
108
- // `entry.pipe()` pipes the file contents to a stream.
109
- // `entry.stream()` returns a readable stream.
110
- // `entry.buffer()` returns a promise that resolves to a `Buffer` with the file contents.
111
- entry.on('data', function (data) {
112
- chunks.push(data);
113
- }).on('error', function (error) {
114
- onError(error);
115
- }).on('finish', function () {
116
- files[entry.path] = _buffer.Buffer.concat(chunks);
117
- resolve();
118
- });
119
- }));
154
+ try {
155
+ // Signal the end of the archive to `fflate`'s `Unzip` class instance.
156
+ // It will flush any remaining state in it.
157
+ unzip.push(new Uint8Array(0), true);
158
+ // Resolve with the unzipped files.
159
+ resolve(files);
160
+ } catch (error) {
161
+ onError(error);
162
+ }
120
163
  });
121
164
  });
122
165
  }
166
+
167
+ // Every section in a `.zip` archive is marked with 4 bytes, the first two of which
168
+ // are `0x50` and `0x4B`, which reads "PK", referencing the initials of the inventor Phil Katz.
169
+ //
170
+ // It looks like `fflate`'s `Unzip` doesn't ever complain about whatever data is thrown at it.
171
+ // Due to how `.zip` file format is defined, "garbage" data could be placed at various
172
+ // places in it and it'd still be a valid `.zip` archive. It's likely that for this reason
173
+ // `fflate` doesn't ever complain and simply emits no entries when fed any kind of invalid data.
174
+ //
175
+ // In order to introduce some basic validation, here we specifically demand
176
+ // that a `.zip` archive must at least start with an individual file entry
177
+ // because an `.xlsx` file creator softwared really shouldn't attempt doing
178
+ // anything "funny" when writing a file, hence this adherence requirement.
179
+ //
180
+ function createZipFileValidator(onValidationResult) {
181
+ var firstBytesCount = 2;
182
+ var firstBytes = [];
183
+ var firstBytesCheckResult;
184
+ return {
185
+ validateChunk: function validateChunk(chunk) {
186
+ if (firstBytes.length < 2) {
187
+ var i = 0;
188
+ while (i < chunk.length && i < firstBytesCount) {
189
+ firstBytes.push(chunk[i]);
190
+ i++;
191
+ }
192
+ if (firstBytes.length === 2) {
193
+ var isValid = firstBytes[0] === 0x50 && firstBytes[1] === 0x4B;
194
+ onValidationResult(isValid);
195
+ }
196
+ }
197
+ }
198
+ };
199
+ }
123
200
  //# sourceMappingURL=unzipFromStream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unzipFromStream.js","names":["_buffer","require","_unzipper","_interopRequireDefault","obj","__esModule","unzipFromStream","stream","_ref","arguments","length","undefined","filter","files","Promise","resolve","reject","promises","errored","onError","error","on","pipe","unzip","Parse","all","then","entry","ignore","type","path","autodrain","chunks","push","data","Buffer","concat"],"sources":["../../source/zip/unzipFromStream.js"],"sourcesContent":["import { Buffer } from 'buffer'\r\n\r\n// `unzipper` has a bug when it doesn't include \"@aws-sdk/client-s3\" package in the `dependencies`\r\n// which causes some \"bundlers\" throw an error.\r\n// https://github.com/ZJONSSON/node-unzipper/issues/330\r\n//\r\n// One workaround is to install \"@aws-sdk/client-s3\" package manually, which would still lead to increased bundle size.\r\n// If the code is bundled for server-side-use only, that is will not be used in a web browser,\r\n// then the increased bundle size would not be an issue.\r\n//\r\n// Another workaround could be to \"alias\" \"@aws-sdk/client-s3\" package in a \"bundler\" configuration file\r\n// with a path to a `*.js` file containing just \"export default null\". But that kind of a workaround would also\r\n// result in errors when using other packages that `import` anything from \"@aws-sdk/client-s3\" package,\r\n// so it's not really a workaround but more of a ticking bomb.\r\n//\r\nimport unzip from 'unzipper'\r\n\r\n// Althernatively, it could use `fflate` if someone writes an example of handling a Node.js stream.\r\n// https://github.com/101arrowz/fflate/issues/251\r\n\r\n/**\r\n * Reads `*.zip` file contents.\r\n * @param {Stream} stream\r\n * @return {Promise<Record<string,Buffer>>} Resolves to an object holding `*.zip` file entries. P.S. `Buffer` is a `Uint8Array`.\r\n */\r\nexport default function unzipFromStream(stream, { filter } = {}) {\r\n\t// The `files` object stores the files and their contents.\r\n\tconst files = {}\r\n\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tconst promises = []\r\n\r\n\t\tlet errored = false\r\n\r\n\t\tconst onError = (error) => {\r\n\t\t\tif (!errored) {\r\n\t\t\t\terrored = true\r\n\t\t\t\treject(error)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tstream\r\n\t\t\t// This first \"error\" listener catches the original stream errors.\r\n\t\t\t//\r\n\t\t\t// That's because the .pipe() method does not automatically propagate errors\r\n\t\t\t// from a source (input) stream to the destination stream or the end of the pipeline.\r\n\t\t\t// You would need to attach an 'error' event handler to each stream in the chain.\r\n\t\t\t//\r\n\t\t\t// A more convenient alternative would be to use `stream.pipeline()` function:\r\n\t\t\t// `pipeline(stream1, stream2, (error) => { ... })`\r\n\t\t\t//\r\n\t\t\t.on('error', onError)\r\n\t\t\t// Pipe the input stream through the unzipper stream.\r\n\t\t\t.pipe(unzip.Parse())\r\n\t\t\t// This second \"error\" listener catches the unzipper stream errors.\r\n\t\t\t//\r\n\t\t\t// That's because the .pipe() method does not automatically propagate errors\r\n\t\t\t// from a source (input) stream to the destination stream or the end of the pipeline.\r\n\t\t\t// You would need to attach an 'error' event handler to each stream in the chain.\r\n\t\t\t//\r\n\t\t\t// A more convenient alternative would be to use `stream.pipeline()` function:\r\n\t\t\t// `pipeline(stream1, stream2, (error) => { ... })`\r\n\t\t\t//\r\n\t\t\t.on('error', onError)\r\n\t\t\t// The unzipper stream is closed when all `entries` have been reported.\r\n\t\t\t.on('finish', () => {\r\n\t\t\t\tif (!errored) {\r\n\t\t\t\t\t// Wait for all `entries` to be read.\r\n\t\t\t\t\t// The second argument of `.then()` function is not required\r\n\t\t\t\t\t// but I didn't remove it just to potentially prevent any potential silly bugs\r\n\t\t\t\t\t// in case of some potential changes in some potential future.\r\n\t\t\t\t\tPromise.all(promises).then(() => {\r\n\t\t\t\t\t\tresolve(files)\r\n\t\t\t\t\t}, onError)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\t.on('entry', (entry) => {\r\n\t\t\t\t// See if this file should be ignored.\r\n\t\t\t\tlet ignore = false\r\n\t\t\t\t// `entry.type` could be 'Directory' or 'File'.\r\n\t\t\t\t// Ignore anything except files.\r\n\t\t\t\tif (entry.type === 'Directory') {\r\n\t\t\t\t\tignore = true\r\n\t\t\t\t}\r\n\t\t\t\tif (errored) {\r\n\t\t\t\t\tignore = true\r\n\t\t\t\t}\r\n\t\t\t\tif (filter) {\r\n\t\t\t\t\tif (!filter({ path: entry.path })) {\r\n\t\t\t\t\t\tignore = true\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If this file should be ignored.\r\n\t\t\t\tif (ignore) {\r\n\t\t\t\t\t// Call `entry.autodrain()` when you do not intend to process a specific `entry`'s raw data.\r\n\t\t\t\t\t// Otherwise, if an `entry` is not consumed (via .pipe(), .buffer(), or .autodrain()),\r\n\t\t\t\t\t// the stream will halt, preventing further file processing.\r\n\t\t\t\t\tentry.autodrain().on('error', onError)\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst chunks = []\r\n\r\n\t\t\t\tpromises.push(new Promise((resolve) => {\r\n\t\t\t\t\t// `entry` seems to be a generic Node.js stream.\r\n\t\t\t\t\t// `entry.pipe()` pipes the file contents to a stream.\r\n\t\t\t\t\t// `entry.stream()` returns a readable stream.\r\n\t\t\t\t\t// `entry.buffer()` returns a promise that resolves to a `Buffer` with the file contents.\r\n\t\t\t\t\tentry\r\n\t\t\t\t\t\t.on('data', (data) => {\r\n\t\t\t\t\t\t\tchunks.push(data)\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\t.on('error', (error) => {\r\n\t\t\t\t\t\t\tonError(error)\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\t.on('finish', () => {\r\n\t\t\t\t\t\t\tfiles[entry.path] = Buffer.concat(chunks)\r\n\t\t\t\t\t\t\tresolve()\r\n\t\t\t\t\t\t})\r\n\t\t\t\t}))\r\n\t\t\t})\r\n\t})\r\n}"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAeA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA4B,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAb5B;AACA;AACA;AACA;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C/BD,MAAM,GAAG,IAAI;MACd;MACA,IAAIV,OAAO,EAAE;QACZU,MAAM,GAAG,IAAI;MACd;MACA,IAAIhB,MAAM,EAAE;QACX,IAAI,CAACA,MAAM,CAAC;UAAEkB,IAAI,EAAEH,KAAK,CAACG;QAAK,CAAC,CAAC,EAAE;UAClCF,MAAM,GAAG,IAAI;QACd;MACD;;MAEA;MACA,IAAIA,MAAM,EAAE;QACX;QACA;QACA;QACAD,KAAK,CAACI,SAAS,CAAC,CAAC,CAACV,EAAE,CAAC,OAAO,EAAEF,OAAO,CAAC;QACtC;MACD;MAEA,IAAMa,MAAM,GAAG,EAAE;MAEjBf,QAAQ,CAACgB,IAAI,CAAC,IAAInB,OAAO,CAAC,UAACC,OAAO,EAAK;QACtC;QACA;QACA;QACA;QACAY,KAAK,CACHN,EAAE,CAAC,MAAM,EAAE,UAACa,IAAI,EAAK;UACrBF,MAAM,CAACC,IAAI,CAACC,IAAI,CAAC;QAClB,CAAC,CAAC,CACDb,EAAE,CAAC,OAAO,EAAE,UAACD,KAAK,EAAK;UACvBD,OAAO,CAACC,KAAK,CAAC;QACf,CAAC,CAAC,CACDC,EAAE,CAAC,QAAQ,EAAE,YAAM;UACnBR,KAAK,CAACc,KAAK,CAACG,IAAI,CAAC,GAAGK,cAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;UACzCjB,OAAO,CAAC,CAAC;QACV,CAAC,CAAC;MACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACH"}
1
+ {"version":3,"file":"unzipFromStream.js","names":["_fflate","require","_buffer","unzipFromStream","stream","_ref","arguments","length","undefined","filter","files","Promise","resolve","reject","errored","onError","error","_createZipFileValidat","createZipFileValidator","isValid","Error","validateChunk","unzip","Unzip","entry","name","endsWith","path","chunks","ondata","chunk","isLast","push","Buffer","concat","start","register","UnzipInflate","on","Uint8Array","onValidationResult","firstBytesCount","firstBytes","firstBytesCheckResult","i"],"sources":["../../source/zip/unzipFromStream.js"],"sourcesContent":["// This code was originally submitted by Stian Jensen.\r\n// https://github.com/catamphetamine/read-excel-file/pull/122\r\n\r\n// A `*.zip` file consists of individual file entries with the \"total\" summary section\r\n// placed at the end of the file rather than at the start of it, which was originally done\r\n// to allow for easy append of data to a given `.zip` file.\r\n// https://en.wikipedia.org/wiki/ZIP_(file_format)\r\n//\r\n// But this also means that reading a `*.zip` file from a stream can't really be done\r\n// using the \"officially recommended\" way of first reading the \"total\" summary section\r\n// and only then reading the individual file entries specified in that summary section.\r\n//\r\n// So in order to be able to read a `*.zip` file from a stream, some corners have to be cut.\r\n// For example, the \"total\" summary section is completely ignored and instead the reader\r\n// should adopt \"data recovery\" software approach — it should proactively \"scan\" the input stream\r\n// for individual file entries and handle them one-by-one as they come.\r\n//\r\n// Such approach doesn't seem to contradict with the XLSX specification\r\n// because an `*.xlsx` files is supposed to be a normal `.zip` archive\r\n// without any \"trickery\" such as \"deleted\" files or \"garbage\" data\r\n// hiding under the hood.\r\n//\r\n// So when handling `*.xlsx` file, we assume that each such file must start\r\n// with an individual file entry followed by another individual file entry, etc.\r\n//\r\n// When the \"summary\" section is reached, we assume that the archive has ended.\r\n//\r\n// To read a `.zip` archive, the code uses `fflate`'s `Unzip` class\r\n// with `UnzipInflate` decompression implementation to decompress the data\r\n// that was previously compressed using `DEFLATE` compressing algorithm,\r\n// which is what `*.xlsx` files use.\r\n//\r\n// The `Unzip` class doesn't speak the Node.js stream interface, and `fflate`'s readme\r\n// doesn't include a clear \"reading a `.zip` file from a Node.js stream\" section.\r\n// https://github.com/101arrowz/fflate/issues/251\r\n// Instead, the `Unzip` class has its own `push(chunk)` / `onfile` / `entry.ondata` protocol.\r\n// This code reads the binary input stream and forwards each chunk of it to `unzip.push()`,\r\n// and then collects the decompressed file entries.\r\n//\r\nimport { Unzip, UnzipInflate } from 'fflate'\r\n\r\nimport { Buffer } from 'buffer'\r\n\r\n/**\r\n * Reads `*.zip` file contents.\r\n * @param {Stream} stream\r\n * @return {Promise<Record<string,Buffer>>} Resolves to an object holding `*.zip` file entries. P.S. `Buffer` is a `Uint8Array`.\r\n */\r\nexport default function unzipFromStream(stream, { filter } = {}) {\r\n\t// The `files` object stores the files and their contents.\r\n\tconst files = {}\r\n\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tlet errored = false\r\n\r\n\t\tconst onError = (error) => {\r\n\t\t\tif (!errored) {\r\n\t\t\t\terrored = true\r\n\t\t\t\treject(error)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst { validateChunk } = createZipFileValidator((isValid) => {\r\n\t\t\tif (!isValid) {\r\n\t\t\t\tonError(new Error('Invalid `.zip` archive'))\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\t// `Unzip` discovers each individual file entry in the input data stream\r\n\t\t// and then calls the callback function for each such entry.\r\n\t\tconst unzip = new Unzip((entry) => {\r\n\t\t\t// If there already was an error while reading this `.zip` file,\r\n\t\t\t// ignore any follow-up entries.\r\n\t\t\tif (errored) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\r\n\t\t\t// Skip directory entries (their names end with a slash).\r\n\t\t\t// Only files are of any interest.\r\n\t\t\tif (entry.name.endsWith('/')) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\r\n\t\t\t// See if this file should be ignored.\r\n\t\t\t// If it should, this entry won't be processed, i.e. `Unzip` will not try\r\n\t\t\t// to decompress its data, and will just discard it.\r\n\t\t\tif (filter && !filter({ path: entry.name })) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\r\n\t\t\tconst chunks = []\r\n\r\n\t\t\t// `entry.ondata` is called with each decompressed chunk of the entry,\r\n\t\t\t// and a final time with `isLast === true` once the entry is complete.\r\n\t\t\tentry.ondata = (error, chunk, isLast) => {\r\n\t\t\t\tif (error) {\r\n\t\t\t\t\treturn onError(error)\r\n\t\t\t\t}\r\n\t\t\t\tchunks.push(chunk)\r\n\t\t\t\tif (isLast) {\r\n\t\t\t\t\tfiles[entry.name] = Buffer.concat(chunks)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Start decompressing this entry.\r\n\t\t\tentry.start()\r\n\t\t})\r\n\r\n\t\t// Register the decompressor for the data that was compressed using\r\n\t\t// `DEFLATE` compression algorithm (compression method `8`),\r\n\t\t// which is what `.xlsx` files use.\r\n\t\tunzip.register(UnzipInflate)\r\n\r\n\t\tstream\r\n\t\t\t// Catch errors emitted from the input stream (for example, a file read error).\r\n\t\t\t.on('error', onError)\r\n\t\t\t// When another chunk of data is read from the input stream.\r\n\t\t\t.on('data', (chunk) => {\r\n\t\t\t\t// If there already was an error while reading this `.zip` file,\r\n\t\t\t\t// ignore any follow-up data chunks.\r\n\t\t\t\tif (errored) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\t// Validate the `.zip` archive as its data comes through.\r\n\t\t\t\tvalidateChunk(chunk)\r\n\t\t\t\t// If the `.zip` archive is found to be invalid, stop any further\r\n\t\t\t\t// processing of it.\r\n\t\t\t\tif (errored) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\t// Push the next data chunk to `fflate`'s `Unzip` class instance.\r\n\t\t\t\t// The `.push()` function is synchronous, meaning that by the time it returns,\r\n\t\t\t\t// any complete files entries encountered so far have already been decompressed\r\n\t\t\t\t// and populated in the `files` object.\r\n\t\t\t\ttry {\r\n\t\t\t\t\tunzip.push(chunk, false)\r\n\t\t\t\t} catch (error) {\r\n\t\t\t\t\tonError(error)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\t// When there's no more data in the input stream to consume,\r\n\t\t\t// finish reading the `.zip` archive.\r\n\t\t\t.on('end', () => {\r\n\t\t\t\t// If there were any errors when reading the `.zip` archive,\r\n\t\t\t\t// don't `resolve()` with anything.\r\n\t\t\t\tif (errored) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\ttry {\r\n\t\t\t\t\t// Signal the end of the archive to `fflate`'s `Unzip` class instance.\r\n\t\t\t\t\t// It will flush any remaining state in it.\r\n\t\t\t\t\tunzip.push(new Uint8Array(0), true)\r\n\t\t\t\t\t// Resolve with the unzipped files.\r\n\t\t\t\t\tresolve(files)\r\n\t\t\t\t} catch (error) {\r\n\t\t\t\t\tonError(error)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t})\r\n}\r\n\r\n// Every section in a `.zip` archive is marked with 4 bytes, the first two of which\r\n// are `0x50` and `0x4B`, which reads \"PK\", referencing the initials of the inventor Phil Katz.\r\n//\r\n// It looks like `fflate`'s `Unzip` doesn't ever complain about whatever data is thrown at it.\r\n// Due to how `.zip` file format is defined, \"garbage\" data could be placed at various\r\n// places in it and it'd still be a valid `.zip` archive. It's likely that for this reason\r\n// `fflate` doesn't ever complain and simply emits no entries when fed any kind of invalid data.\r\n//\r\n// In order to introduce some basic validation, here we specifically demand\r\n// that a `.zip` archive must at least start with an individual file entry\r\n// because an `.xlsx` file creator softwared really shouldn't attempt doing\r\n// anything \"funny\" when writing a file, hence this adherence requirement.\r\n//\r\nfunction createZipFileValidator(onValidationResult) {\r\n\tconst firstBytesCount = 2\r\n\tconst firstBytes = []\r\n\tlet firstBytesCheckResult\r\n\treturn {\r\n\t\tvalidateChunk(chunk) {\r\n\t\t\tif (firstBytes.length < 2) {\r\n\t\t\t\tlet i = 0\r\n\t\t\t\twhile (i < chunk.length && i < firstBytesCount) {\r\n\t\t\t\t\tfirstBytes.push(chunk[i])\r\n\t\t\t\t\ti++\r\n\t\t\t\t}\r\n\t\t\t\tif (firstBytes.length === 2) {\r\n\t\t\t\t\tconst isValid = firstBytes[0] === 0x50 && firstBytes[1] === 0x4B\r\n\t\t\t\t\tonValidationResult(isValid)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;AAuCA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAzCA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,sBAAsBA,CAACsB,kBAAkB,EAAE;EACnD,IAAMC,eAAe,GAAG,CAAC;EACzB,IAAMC,UAAU,GAAG,EAAE;EACrB,IAAIC,qBAAqB;EACzB,OAAO;IACNtB,aAAa,WAAAA,cAACS,KAAK,EAAE;MACpB,IAAIY,UAAU,CAACnC,MAAM,GAAG,CAAC,EAAE;QAC1B,IAAIqC,CAAC,GAAG,CAAC;QACT,OAAOA,CAAC,GAAGd,KAAK,CAACvB,MAAM,IAAIqC,CAAC,GAAGH,eAAe,EAAE;UAC/CC,UAAU,CAACV,IAAI,CAACF,KAAK,CAACc,CAAC,CAAC,CAAC;UACzBA,CAAC,EAAE;QACJ;QACA,IAAIF,UAAU,CAACnC,MAAM,KAAK,CAAC,EAAE;UAC5B,IAAMY,OAAO,GAAGuB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;UAChEF,kBAAkB,CAACrB,OAAO,CAAC;QAC5B;MACD;IACD;EACD,CAAC;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unzipFromStream.test.js","names":["_mocha","require","_chai","_stream","_fflate","_unzipFromStream","_interopRequireDefault","obj","__esModule","_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","define","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","_catch","delegateYield","asyncGeneratorStep","gen","reject","_next","_throw","key","info","error","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","describe","it","_callee","zip","files","_callee$","_context","createZip","unzipFromStream","createStreamFromBuffer","expect","convertValuesFromBufferToString","to","deep","equal","_callee2","_callee2$","_context2","level","_callee3","_callee3$","_context3","repeat","chunkSize","_callee4","_callee4$","_context4","Buffer","from","zipSync","Uint8Array","strToU8","_callee5","_callee5$","_context5","filter","_ref6","path","endsWith","_callee6","stream","thrown","_callee6$","_context6","Readable","read","process","nextTick","emit","t0","_callee7","garbage","_callee7$","_context7","be","an","_ref9","entries","_i","_Object$keys","buffer","_ref10","_ref10$chunkSize","chunks","subarray","alloc","object","convertedObject","_i2","_Object$keys2","strFromU8"],"sources":["../../source/zip/unzipFromStream.test.js"],"sourcesContent":["// This code was originally submitted by Stian Jensen.\r\n// https://github.com/catamphetamine/read-excel-file/pull/122\r\n\r\nimport { describe, it } from 'mocha'\r\nimport { expect } from 'chai'\r\n\r\nimport { Readable } from 'stream'\r\nimport { zipSync, strToU8, strFromU8 } from 'fflate'\r\n\r\nimport unzipFromStream from './unzipFromStream.js'\r\n\r\ndescribe('unzipFromStream', () => {\r\n\tit('should read DEFLATE-compressed entries from a stream', async () => {\r\n\t\tconst zip = createZip({\r\n\t\t\t'a.xml': '<a>Hello</a>',\r\n\t\t\t'dir/b.xml': '<b>World</b>'\r\n\t\t})\r\n\t\tconst files = await unzipFromStream(createStreamFromBuffer(zip))\r\n\t\texpect(convertValuesFromBufferToString(files)).to.deep.equal({\r\n\t\t\t'a.xml': '<a>Hello</a>',\r\n\t\t\t'dir/b.xml': '<b>World</b>'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should read \"stored\" (uncompressed) entries from a stream', async () => {\r\n\t\tconst zip = createZip({ 'a.xml': '<a>Hello</a>' }, { level: 0 })\r\n\t\tconst files = await unzipFromStream(createStreamFromBuffer(zip))\r\n\t\texpect(convertValuesFromBufferToString(files)).to.deep.equal({ 'a.xml': '<a>Hello</a>' })\r\n\t})\r\n\r\n\tit('should read entries split across small stream chunks', async () => {\r\n\t\tconst zip = createZip({\r\n\t\t\t'a.xml': '<a>'.repeat(500),\r\n\t\t\t'b.xml': '<b>'.repeat(500)\r\n\t\t})\r\n\t\tconst files = await unzipFromStream(createStreamFromBuffer(zip, { chunkSize: 7 }))\r\n\t\texpect(convertValuesFromBufferToString(files)).to.deep.equal({\r\n\t\t\t'a.xml': '<a>'.repeat(500),\r\n\t\t\t'b.xml': '<b>'.repeat(500)\r\n\t\t})\r\n\t})\r\n\r\n\tit('should ignore directory entries', async () => {\r\n\t\tconst zip = Buffer.from(zipSync({\r\n\t\t\t'dir/': new Uint8Array(0),\r\n\t\t\t'dir/a.xml': strToU8('<a/>')\r\n\t\t}))\r\n\t\tconst files = await unzipFromStream(createStreamFromBuffer(zip))\r\n\t\texpect(convertValuesFromBufferToString(files)).to.deep.equal({ 'dir/a.xml': '<a/>' })\r\n\t})\r\n\r\n\tit('should ignore entries rejected by the `filter` option', async () => {\r\n\t\tconst zip = createZip({\r\n\t\t\t'keep.xml': '<keep/>',\r\n\t\t\t'skip.png': 'binary'\r\n\t\t})\r\n\t\tconst files = await unzipFromStream(createStreamFromBuffer(zip), {\r\n\t\t\tfilter: ({ path }) => path.endsWith('.xml')\r\n\t\t})\r\n\t\texpect(convertValuesFromBufferToString(files)).to.deep.equal({ 'keep.xml': '<keep/>' })\r\n\t})\r\n\r\n\tit('should reject when the source stream errors', async () => {\r\n\t\tconst stream = new Readable({ read() {} })\r\n\t\tconst error = new Error('Stream read failure')\r\n\t\tprocess.nextTick(() => stream.emit('error', error))\r\n\r\n\t\tlet thrown\r\n\t\ttry {\r\n\t\t\tawait unzipFromStream(stream)\r\n\t\t} catch (caught) {\r\n\t\t\tthrown = caught\r\n\t\t}\r\n\t\texpect(thrown).to.equal(error)\r\n\t})\r\n\r\n\tit('should reject on invalid (non-zip) data', async () => {\r\n\t\tconst garbage = Buffer.from('this is definitely not a zip archive')\r\n\r\n\t\tlet thrown\r\n\t\ttry {\r\n\t\t\tawait unzipFromStream(createStreamFromBuffer(garbage))\r\n\t\t} catch (caught) {\r\n\t\t\tthrown = caught\r\n\t\t}\r\n\t\texpect(thrown).to.be.an('error')\r\n\t})\r\n})\r\n\r\n\r\n// Builds a `.zip` archive (in memory) from a map of text files.\r\n//\r\n// Accepts `fflate`'s `zipSync()` function options as the optional second argument.\r\n// For example, passing `level: 0` will produce a `.zip` file with no compression.\r\n//\r\n// Returns a `Buffer`.\r\n//\r\nfunction createZip(files, { level } = {}) {\r\n\tconst entries = {}\r\n\tfor (const name of Object.keys(files)) {\r\n\t\tentries[name] = strToU8(files[name])\r\n\t}\r\n\treturn Buffer.from(zipSync(entries, { level }))\r\n}\r\n\r\n// Creates a Node.js Stream from a given `buffer` containing the data.\r\n// The stream will split the data into `chunkSize`-byte chunks.\r\n// (this is used to exercise reading across arbitrary chunk boundaries)\r\nfunction createStreamFromBuffer(buffer, { chunkSize = buffer.length } = {}) {\r\n\tconst chunks = []\r\n\tfor (let i = 0; i < buffer.length; i += chunkSize) {\r\n\t\tchunks.push(buffer.subarray(i, i + chunkSize))\r\n\t}\r\n\treturn Readable.from(chunks.length > 0 ? chunks : [Buffer.alloc(0)])\r\n}\r\n\r\n// Converts the values in the given object from `Buffer` to UTF-8 `string`.\r\nfunction convertValuesFromBufferToString(object) {\r\n\tconst convertedObject = {}\r\n\tfor (const path of Object.keys(object)) {\r\n\t\tconvertedObject[path] = strFromU8(object[path])\r\n\t}\r\n\treturn convertedObject\r\n}"],"mappings":";;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAC,sBAA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