addons-scanner-utils 4.10.0 → 6.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.
package/dist/const.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const ECMA_VERSION = 12;
1
+ export declare const ECMA_VERSION = 13;
package/dist/const.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ECMA_VERSION = void 0;
4
4
  // This is the ECMAScript version officially supported by AMO.
5
- exports.ECMA_VERSION = 12; // a.k.a. 2021
5
+ exports.ECMA_VERSION = 13; // a.k.a. 2022
@@ -0,0 +1,6 @@
1
+ export declare class InvalidZipFileError extends Error {
2
+ get name(): string;
3
+ }
4
+ export declare class DuplicateZipEntryError extends Error {
5
+ get name(): string;
6
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /* eslint-disable max-classes-per-file */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DuplicateZipEntryError = exports.InvalidZipFileError = void 0;
5
+ class InvalidZipFileError extends Error {
6
+ get name() {
7
+ return 'InvalidZipFileError';
8
+ }
9
+ }
10
+ exports.InvalidZipFileError = InvalidZipFileError;
11
+ class DuplicateZipEntryError extends Error {
12
+ get name() {
13
+ return 'DuplicateZipFileEntry';
14
+ }
15
+ }
16
+ exports.DuplicateZipEntryError = DuplicateZipEntryError;
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './const';
2
2
  export * from './functions';
3
3
  export * from './io';
4
4
  export * from './stdio';
5
+ export * from './errors';
package/dist/index.js CHANGED
@@ -14,3 +14,4 @@ __exportStar(require("./const"), exports);
14
14
  __exportStar(require("./functions"), exports);
15
15
  __exportStar(require("./io"), exports);
16
16
  __exportStar(require("./stdio"), exports);
17
+ __exportStar(require("./errors"), exports);
package/dist/io/xpi.js CHANGED
@@ -18,6 +18,7 @@ const first_chunk_stream_1 = __importDefault(require("first-chunk-stream"));
18
18
  const strip_bom_stream_1 = __importDefault(require("strip-bom-stream"));
19
19
  const common_tags_1 = require("common-tags");
20
20
  const base_1 = require("./base");
21
+ const errors_1 = require("../errors");
21
22
  /*
22
23
  * Simple Promise wrapper for the Yauzl unzipping lib to unpack add-on .xpis.
23
24
  *
@@ -43,7 +44,17 @@ class Xpi extends base_1.IOBase {
43
44
  resolve(this.zipfile);
44
45
  return;
45
46
  }
46
- this.zipLib.open(this.path, { autoClose: this.autoClose }, (err, zipfile) => {
47
+ this.zipLib.open(this.path, {
48
+ autoClose: this.autoClose,
49
+ // Enable checks on invalid chars in zip entries filenames.
50
+ strictFileNames: true,
51
+ // Decode automatically filenames and zip entries content from buffer into strings
52
+ // and autodetects their encoding.
53
+ //
54
+ // NOTE: this is also mandatory because without this option set to true
55
+ // strictFileNames option is ignored.
56
+ decodeStrings: true,
57
+ }, (err, zipfile) => {
47
58
  if (err) {
48
59
  return reject(err);
49
60
  }
@@ -63,8 +74,8 @@ class Xpi extends base_1.IOBase {
63
74
  if (this.entries.includes(entry.fileName)) {
64
75
  this.stderr.info((0, common_tags_1.oneLine) `found duplicate file entry: "${entry.fileName}"
65
76
  in package`);
66
- reject(new Error((0, common_tags_1.oneLine) `DuplicateZipEntry: Entry
67
- "${entry.fileName}" has already been seen`));
77
+ reject(new errors_1.DuplicateZipEntryError((0, common_tags_1.oneLine) `Entry "${entry.fileName}" has already
78
+ been seen`));
68
79
  return;
69
80
  }
70
81
  this.entries.push(entry.fileName);
@@ -88,6 +99,9 @@ class Xpi extends base_1.IOBase {
88
99
  }
89
100
  const zipfile = yield this.open();
90
101
  return new Promise((resolve, reject) => {
102
+ zipfile.on('error', (err) => {
103
+ reject(new errors_1.InvalidZipFileError(err.message));
104
+ });
91
105
  zipfile.on('entry', (entry) => {
92
106
  this.handleEntry(entry, reject);
93
107
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "addons-scanner-utils",
3
- "version": "4.10.0",
3
+ "version": "6.1.0",
4
4
  "description": "Various addons related helpers to build CLIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,17 +33,17 @@
33
33
  "@types/safe-compare": "^1.1.0",
34
34
  "@types/sinon": "^10.0.0",
35
35
  "@types/supertest": "^2.0.8",
36
- "@typescript-eslint/eslint-plugin": "^4.0.0",
37
- "@typescript-eslint/parser": "^4.0.0",
36
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
37
+ "@typescript-eslint/parser": "^5.0.0",
38
38
  "body-parser": "1.19.0",
39
39
  "codecov": "^3.5.0",
40
40
  "download": "8.0.0",
41
- "eslint": "^7.23.0",
42
- "eslint-config-amo": "^4.0.0",
41
+ "eslint": "^8.1.0",
42
+ "eslint-config-amo": "^5.0.0",
43
43
  "eslint-plugin-amo": "^1.10.2",
44
44
  "express": "4.17.1",
45
45
  "jest": "^27.0.0",
46
- "prettier": "2.3.2",
46
+ "prettier": "2.4.1",
47
47
  "pretty-quick": "^3.0.0",
48
48
  "rimraf": "^3.0.0",
49
49
  "safe-compare": "1.1.4",