@flowrunner/cli 0.1.1 → 0.1.3
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/ai-docs/instructions/service-code-format/01-service-structure.md +27 -2
- package/ai-docs/instructions/service-code-format/04-http-requests.md +29 -0
- package/ai-docs/instructions/service-code-format/05-dictionaries.md +19 -0
- package/ai-docs/instructions/service-code-format/08-polling-triggers.md +68 -5
- package/ai-docs/instructions/service-code-format/09-realtime-triggers.md +51 -8
- package/ai-docs/instructions/service-code-format/12-service-readme.md +5 -0
- package/ai-docs/instructions/service-code-format/13-runtime-contracts.md +18 -5
- package/ai-docs/instructions/service-code-format/14-reference-service.md +7 -2
- package/ai-docs/instructions/service-code-format/16-gotchas.md +16 -4
- package/ai-docs/providers/claude/agents/flowrunner-service-code-engineer.md +9 -2
- package/dist/cli.js +429 -239
- package/dist/cli.js.map +4 -4
- package/dist/index.js +420 -232
- package/dist/index.js.map +4 -4
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/system-params.d.ts +2 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/trigger-method.d.ts +6 -2
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +6 -1
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/verify.d.ts +1 -1
- package/dist/types/packages/cli/src/constants/testing.d.ts +9 -4
- package/dist/types/shared/src/constants/knowledge-base.d.ts +1 -0
- package/dist/types/shared/src/scheme/billing/java.dto.d.ts +19 -1
- package/dist/types/shared/src/scheme/crm/dto.d.ts +2 -2
- package/dist/types/shared/src/scheme/flowrunner/java.dto.d.ts +1 -1
- package/dist/types/shared/src/scheme/knowledge-base/dto.d.ts +156 -0
- package/dist/types/shared/src/scheme/workspace/dto.d.ts +1 -1
- package/package.json +3 -3
- package/runtime/index.js +39 -24
- package/runtime/index.js.map +2 -2
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/system-params.d.ts +2 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/trigger-method.d.ts +6 -2
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +6 -1
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/verify.d.ts +1 -1
- package/runtime/types/shared/src/constants/knowledge-base.d.ts +1 -0
- package/runtime/types/shared/src/scheme/billing/java.dto.d.ts +19 -1
- package/runtime/types/shared/src/scheme/crm/dto.d.ts +2 -2
- package/runtime/types/shared/src/scheme/flowrunner/java.dto.d.ts +1 -1
- package/runtime/types/shared/src/scheme/knowledge-base/dto.d.ts +156 -0
- package/runtime/types/shared/src/scheme/workspace/dto.d.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
|
|
9
|
+
try {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw mod = 0, e;
|
|
13
|
+
}
|
|
10
14
|
};
|
|
11
15
|
var __export = (target, all) => {
|
|
12
16
|
for (var name in all)
|
|
@@ -355,7 +359,7 @@ var require_error = __commonJS({
|
|
|
355
359
|
};
|
|
356
360
|
return _getPrototypeOf(o);
|
|
357
361
|
}
|
|
358
|
-
var ResponseError = exports2.ResponseError = /* @__PURE__ */ function(_Error) {
|
|
362
|
+
var ResponseError = exports2.ResponseError = /* @__PURE__ */ (function(_Error) {
|
|
359
363
|
_inherits(ResponseError2, _Error);
|
|
360
364
|
var _super = _createSuper(ResponseError2);
|
|
361
365
|
function ResponseError2(response) {
|
|
@@ -371,14 +375,14 @@ var require_error = __commonJS({
|
|
|
371
375
|
return _this;
|
|
372
376
|
}
|
|
373
377
|
return _createClass(ResponseError2);
|
|
374
|
-
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
378
|
+
})(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
375
379
|
function parseError(res) {
|
|
376
380
|
if (res.status === 502) {
|
|
377
381
|
return "No connection with server";
|
|
378
382
|
}
|
|
379
383
|
return res.body || "Status Code ".concat(res.status, " (").concat(res.statusText, ")");
|
|
380
384
|
}
|
|
381
|
-
var TLSError = exports2.TLSError = /* @__PURE__ */ function(_Error2) {
|
|
385
|
+
var TLSError = exports2.TLSError = /* @__PURE__ */ (function(_Error2) {
|
|
382
386
|
_inherits(TLSError2, _Error2);
|
|
383
387
|
var _super2 = _createSuper(TLSError2);
|
|
384
388
|
function TLSError2(reason, cause) {
|
|
@@ -393,7 +397,7 @@ var require_error = __commonJS({
|
|
|
393
397
|
return _this2;
|
|
394
398
|
}
|
|
395
399
|
return _createClass(TLSError2);
|
|
396
|
-
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
400
|
+
})(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
397
401
|
var SECURE_CONTEXT_REASONS = [{
|
|
398
402
|
match: /bad decrypt|bad password read|wrong final block length/i,
|
|
399
403
|
reason: "The private key could not be decrypted, the passphrase is missing or incorrect."
|
|
@@ -624,7 +628,7 @@ var require_event_emitter = __commonJS({
|
|
|
624
628
|
}
|
|
625
629
|
return (hint2 === "string" ? String : Number)(input);
|
|
626
630
|
}
|
|
627
|
-
var EventEmitter = exports2["default"] = /* @__PURE__ */ function() {
|
|
631
|
+
var EventEmitter = exports2["default"] = /* @__PURE__ */ (function() {
|
|
628
632
|
function EventEmitter2() {
|
|
629
633
|
_classCallCheck(this, EventEmitter2);
|
|
630
634
|
this.events = {};
|
|
@@ -666,7 +670,7 @@ var require_event_emitter = __commonJS({
|
|
|
666
670
|
}
|
|
667
671
|
}]);
|
|
668
672
|
return EventEmitter2;
|
|
669
|
-
}();
|
|
673
|
+
})();
|
|
670
674
|
}
|
|
671
675
|
});
|
|
672
676
|
|
|
@@ -884,7 +888,7 @@ var require_request = __commonJS({
|
|
|
884
888
|
var RESPONSE_EVENT = "response";
|
|
885
889
|
var ERROR_EVENT = "error";
|
|
886
890
|
var DONE_EVENT = "done";
|
|
887
|
-
var Request = exports2.Request = /* @__PURE__ */ function(_EventEmitter) {
|
|
891
|
+
var Request = exports2.Request = /* @__PURE__ */ (function(_EventEmitter) {
|
|
888
892
|
_inherits(Request2, _EventEmitter);
|
|
889
893
|
var _super = _createSuper(Request2);
|
|
890
894
|
function Request2(path19, method, body) {
|
|
@@ -1187,7 +1191,7 @@ var require_request = __commonJS({
|
|
|
1187
1191
|
}
|
|
1188
1192
|
}]);
|
|
1189
1193
|
return Request2;
|
|
1190
|
-
}(_eventEmitter["default"]);
|
|
1194
|
+
})(_eventEmitter["default"]);
|
|
1191
1195
|
function pickTLSOptions(tlsOptions) {
|
|
1192
1196
|
var result = {};
|
|
1193
1197
|
TLS_OPTION_KEYS.forEach(function(key) {
|
|
@@ -1351,9 +1355,9 @@ var require_lib = __commonJS({
|
|
|
1351
1355
|
}
|
|
1352
1356
|
});
|
|
1353
1357
|
|
|
1354
|
-
//
|
|
1358
|
+
// node_modules/adm-zip/util/constants.js
|
|
1355
1359
|
var require_constants = __commonJS({
|
|
1356
|
-
"
|
|
1360
|
+
"node_modules/adm-zip/util/constants.js"(exports2, module2) {
|
|
1357
1361
|
module2.exports = {
|
|
1358
1362
|
/* The local file header */
|
|
1359
1363
|
LOCHDR: 30,
|
|
@@ -1570,9 +1574,9 @@ var require_constants = __commonJS({
|
|
|
1570
1574
|
}
|
|
1571
1575
|
});
|
|
1572
1576
|
|
|
1573
|
-
//
|
|
1577
|
+
// node_modules/adm-zip/util/errors.js
|
|
1574
1578
|
var require_errors = __commonJS({
|
|
1575
|
-
"
|
|
1579
|
+
"node_modules/adm-zip/util/errors.js"(exports2) {
|
|
1576
1580
|
var errors = {
|
|
1577
1581
|
/* Header error messages */
|
|
1578
1582
|
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
@@ -1585,6 +1589,7 @@ var require_errors = __commonJS({
|
|
|
1585
1589
|
/* ZipEntry error messages*/
|
|
1586
1590
|
NO_DATA: "Nothing to decompress",
|
|
1587
1591
|
BAD_CRC: "CRC32 checksum failed {0}",
|
|
1592
|
+
MAX_OUTPUT_EXCEEDED: "Decompressed data exceeds the declared uncompressed size",
|
|
1588
1593
|
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
1589
1594
|
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
1590
1595
|
/* Inflater error messages */
|
|
@@ -1604,11 +1609,13 @@ var require_errors = __commonJS({
|
|
|
1604
1609
|
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
1605
1610
|
NO_ZIP: "No zip file was loaded",
|
|
1606
1611
|
NO_ENTRY: "Entry doesn't exist",
|
|
1612
|
+
DUPLICATE_ENTRY: "Duplicate entry name {0}",
|
|
1607
1613
|
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
1608
1614
|
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
1609
1615
|
NOT_IMPLEMENTED: "Not implemented",
|
|
1610
1616
|
INVALID_FILENAME: "Invalid filename",
|
|
1611
1617
|
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
1618
|
+
ZIP64_VALUE_TOO_LARGE: "Zip64 value exceeds the maximum safe integer",
|
|
1612
1619
|
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
1613
1620
|
WRONG_PASSWORD: "Wrong Password",
|
|
1614
1621
|
/* ADM-ZIP */
|
|
@@ -1630,9 +1637,9 @@ var require_errors = __commonJS({
|
|
|
1630
1637
|
}
|
|
1631
1638
|
});
|
|
1632
1639
|
|
|
1633
|
-
//
|
|
1640
|
+
// node_modules/adm-zip/util/utils.js
|
|
1634
1641
|
var require_utils2 = __commonJS({
|
|
1635
|
-
"
|
|
1642
|
+
"node_modules/adm-zip/util/utils.js"(exports2, module2) {
|
|
1636
1643
|
var fsystem = require("fs");
|
|
1637
1644
|
var pth = require("path");
|
|
1638
1645
|
var Constants = require_constants();
|
|
@@ -1670,7 +1677,11 @@ var require_utils2 = __commonJS({
|
|
|
1670
1677
|
try {
|
|
1671
1678
|
stat = self.fs.statSync(resolvedPath);
|
|
1672
1679
|
} catch (e) {
|
|
1673
|
-
|
|
1680
|
+
if (e.message && e.message.startsWith("ENOENT")) {
|
|
1681
|
+
self.fs.mkdirSync(resolvedPath);
|
|
1682
|
+
} else {
|
|
1683
|
+
throw e;
|
|
1684
|
+
}
|
|
1674
1685
|
}
|
|
1675
1686
|
if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
1676
1687
|
});
|
|
@@ -1716,46 +1727,83 @@ var require_utils2 = __commonJS({
|
|
|
1716
1727
|
self.fs.exists(path19, function(exist) {
|
|
1717
1728
|
if (exist && !overwrite) return callback(false);
|
|
1718
1729
|
self.fs.stat(path19, function(err, stat) {
|
|
1719
|
-
if (exist && stat.isDirectory()) {
|
|
1730
|
+
if (exist && stat && stat.isDirectory()) {
|
|
1720
1731
|
return callback(false);
|
|
1721
1732
|
}
|
|
1722
1733
|
var folder = pth.dirname(path19);
|
|
1723
1734
|
self.fs.exists(folder, function(exists) {
|
|
1724
|
-
if (!exists)
|
|
1735
|
+
if (!exists) {
|
|
1736
|
+
try {
|
|
1737
|
+
self.makeDir(folder);
|
|
1738
|
+
} catch (e) {
|
|
1739
|
+
return callback(false);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
const writeToFd = function(fd) {
|
|
1743
|
+
self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
|
|
1744
|
+
self.fs.close(fd, function() {
|
|
1745
|
+
if (writeErr) return callback(false);
|
|
1746
|
+
self.fs.chmod(path19, attr || 438, function() {
|
|
1747
|
+
callback(true);
|
|
1748
|
+
});
|
|
1749
|
+
});
|
|
1750
|
+
});
|
|
1751
|
+
};
|
|
1725
1752
|
self.fs.open(path19, "w", 438, function(err2, fd) {
|
|
1726
1753
|
if (err2) {
|
|
1727
1754
|
self.fs.chmod(path19, 438, function() {
|
|
1728
|
-
self.fs.open(path19, "w", 438, function(
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
self.fs.chmod(path19, attr || 438, function() {
|
|
1732
|
-
callback(true);
|
|
1733
|
-
});
|
|
1734
|
-
});
|
|
1735
|
-
});
|
|
1755
|
+
self.fs.open(path19, "w", 438, function(retryErr, fd2) {
|
|
1756
|
+
if (retryErr || !fd2) return callback(false);
|
|
1757
|
+
writeToFd(fd2);
|
|
1736
1758
|
});
|
|
1737
1759
|
});
|
|
1738
1760
|
} else if (fd) {
|
|
1739
|
-
|
|
1740
|
-
self.fs.close(fd, function() {
|
|
1741
|
-
self.fs.chmod(path19, attr || 438, function() {
|
|
1742
|
-
callback(true);
|
|
1743
|
-
});
|
|
1744
|
-
});
|
|
1745
|
-
});
|
|
1761
|
+
writeToFd(fd);
|
|
1746
1762
|
} else {
|
|
1747
|
-
|
|
1748
|
-
callback(true);
|
|
1749
|
-
});
|
|
1763
|
+
callback(false);
|
|
1750
1764
|
}
|
|
1751
1765
|
});
|
|
1752
1766
|
});
|
|
1753
1767
|
});
|
|
1754
1768
|
});
|
|
1755
1769
|
};
|
|
1770
|
+
Utils.prototype.assertPathSafe = function(root, target) {
|
|
1771
|
+
const self = this;
|
|
1772
|
+
if (typeof self.fs.lstatSync !== "function") return;
|
|
1773
|
+
const resolvedRoot = pth.resolve(root);
|
|
1774
|
+
const resolvedTarget = pth.resolve(target);
|
|
1775
|
+
if (resolvedTarget === resolvedRoot) return;
|
|
1776
|
+
const rel = pth.relative(resolvedRoot, resolvedTarget);
|
|
1777
|
+
if (!rel || rel === ".." || rel.startsWith(".." + pth.sep) || pth.isAbsolute(rel)) return;
|
|
1778
|
+
let cur = resolvedRoot;
|
|
1779
|
+
for (const part of rel.split(pth.sep)) {
|
|
1780
|
+
if (!part || part === ".") continue;
|
|
1781
|
+
cur = pth.join(cur, part);
|
|
1782
|
+
let stat;
|
|
1783
|
+
try {
|
|
1784
|
+
stat = self.fs.lstatSync(cur);
|
|
1785
|
+
} catch (e) {
|
|
1786
|
+
break;
|
|
1787
|
+
}
|
|
1788
|
+
if (stat.isSymbolicLink()) throw Errors.FILE_IN_THE_WAY(`"${cur}"`);
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1756
1791
|
Utils.prototype.findFiles = function(path19) {
|
|
1757
1792
|
const self = this;
|
|
1758
|
-
|
|
1793
|
+
const canLstat = typeof self.fs.lstatSync === "function";
|
|
1794
|
+
const rootReal = self.fs.realpathSync(path19);
|
|
1795
|
+
function escapesRoot(p) {
|
|
1796
|
+
if (!canLstat) return false;
|
|
1797
|
+
if (!self.fs.lstatSync(p).isSymbolicLink()) return false;
|
|
1798
|
+
let real;
|
|
1799
|
+
try {
|
|
1800
|
+
real = self.fs.realpathSync(p);
|
|
1801
|
+
} catch (e) {
|
|
1802
|
+
return true;
|
|
1803
|
+
}
|
|
1804
|
+
return !(real === rootReal || real.startsWith(rootReal + pth.sep));
|
|
1805
|
+
}
|
|
1806
|
+
function findSync(dir, pattern, recursive, visited) {
|
|
1759
1807
|
if (typeof pattern === "boolean") {
|
|
1760
1808
|
recursive = pattern;
|
|
1761
1809
|
pattern = void 0;
|
|
@@ -1763,41 +1811,90 @@ var require_utils2 = __commonJS({
|
|
|
1763
1811
|
let files = [];
|
|
1764
1812
|
self.fs.readdirSync(dir).forEach(function(file) {
|
|
1765
1813
|
const path20 = pth.join(dir, file);
|
|
1814
|
+
if (escapesRoot(path20)) return;
|
|
1766
1815
|
const stat = self.fs.statSync(path20);
|
|
1767
1816
|
if (!pattern || pattern.test(path20)) {
|
|
1768
1817
|
files.push(pth.normalize(path20) + (stat.isDirectory() ? self.sep : ""));
|
|
1769
1818
|
}
|
|
1770
|
-
if (stat.isDirectory() && recursive)
|
|
1819
|
+
if (stat.isDirectory() && recursive) {
|
|
1820
|
+
const realDir = self.fs.realpathSync(path20);
|
|
1821
|
+
if (!visited.has(realDir)) {
|
|
1822
|
+
visited.add(realDir);
|
|
1823
|
+
files = files.concat(findSync(path20, pattern, recursive, visited));
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1771
1826
|
});
|
|
1772
1827
|
return files;
|
|
1773
1828
|
}
|
|
1774
|
-
return findSync(path19, void 0, true);
|
|
1829
|
+
return findSync(path19, void 0, true, /* @__PURE__ */ new Set([rootReal]));
|
|
1775
1830
|
};
|
|
1776
1831
|
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
1777
1832
|
const self = this;
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1833
|
+
const results = [];
|
|
1834
|
+
let finished = false;
|
|
1835
|
+
const finish = function(err) {
|
|
1836
|
+
if (finished) return;
|
|
1837
|
+
finished = true;
|
|
1838
|
+
cb(err, err ? void 0 : results);
|
|
1839
|
+
};
|
|
1840
|
+
const canLstat = typeof self.fs.lstat === "function";
|
|
1841
|
+
let rootReal = null;
|
|
1842
|
+
const escapesRoot = function(file, cb2) {
|
|
1843
|
+
if (!canLstat) return cb2(null, false);
|
|
1844
|
+
self.fs.lstat(file, function(err, lst) {
|
|
1845
|
+
if (err) return cb2(err);
|
|
1846
|
+
if (!lst || !lst.isSymbolicLink()) return cb2(null, false);
|
|
1847
|
+
self.fs.realpath(file, function(err2, real) {
|
|
1848
|
+
if (err2) return cb2(null, true);
|
|
1849
|
+
cb2(null, !(real === rootReal || real.startsWith(rootReal + pth.sep)));
|
|
1850
|
+
});
|
|
1851
|
+
});
|
|
1852
|
+
};
|
|
1853
|
+
const walk = function(dir2, visited, done) {
|
|
1854
|
+
self.fs.readdir(dir2, function(err, list) {
|
|
1855
|
+
if (err) return done(err);
|
|
1856
|
+
let pending = list.length;
|
|
1857
|
+
if (!pending) return done();
|
|
1858
|
+
list.forEach(function(name) {
|
|
1859
|
+
const file = pth.join(dir2, name);
|
|
1860
|
+
escapesRoot(file, function(err2, escapes) {
|
|
1861
|
+
if (err2) return done(err2);
|
|
1862
|
+
if (escapes) {
|
|
1863
|
+
if (!--pending) done();
|
|
1864
|
+
return;
|
|
1797
1865
|
}
|
|
1798
|
-
|
|
1866
|
+
self.fs.stat(file, function(err3, stat) {
|
|
1867
|
+
if (err3) return done(err3);
|
|
1868
|
+
if (!stat) {
|
|
1869
|
+
if (!--pending) done();
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
|
|
1873
|
+
if (!stat.isDirectory()) {
|
|
1874
|
+
if (!--pending) done();
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
self.fs.realpath(file, function(err4, realDir) {
|
|
1878
|
+
if (err4) return done(err4);
|
|
1879
|
+
if (visited.has(realDir)) {
|
|
1880
|
+
if (!--pending) done();
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
visited.add(realDir);
|
|
1884
|
+
walk(file, visited, function(err5) {
|
|
1885
|
+
if (err5) return done(err5);
|
|
1886
|
+
if (!--pending) done();
|
|
1887
|
+
});
|
|
1888
|
+
});
|
|
1889
|
+
});
|
|
1890
|
+
});
|
|
1799
1891
|
});
|
|
1800
1892
|
});
|
|
1893
|
+
};
|
|
1894
|
+
self.fs.realpath(dir, function(err, realDir) {
|
|
1895
|
+
if (err) return finish(err);
|
|
1896
|
+
rootReal = realDir;
|
|
1897
|
+
walk(dir, /* @__PURE__ */ new Set([realDir]), finish);
|
|
1801
1898
|
});
|
|
1802
1899
|
};
|
|
1803
1900
|
Utils.prototype.getAttributes = function() {
|
|
@@ -1851,7 +1948,7 @@ var require_utils2 = __commonJS({
|
|
|
1851
1948
|
var parts = name.split("/");
|
|
1852
1949
|
for (var i = 0, l = parts.length; i < l; i++) {
|
|
1853
1950
|
var path19 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
1854
|
-
if (path19.
|
|
1951
|
+
if (path19 === prefix || path19.startsWith(prefix + pth.sep)) {
|
|
1855
1952
|
return path19;
|
|
1856
1953
|
}
|
|
1857
1954
|
}
|
|
@@ -1867,9 +1964,19 @@ var require_utils2 = __commonJS({
|
|
|
1867
1964
|
}
|
|
1868
1965
|
};
|
|
1869
1966
|
Utils.readBigUInt64LE = function(buffer, index) {
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1967
|
+
const lo = buffer.readUInt32LE(index);
|
|
1968
|
+
const hi = buffer.readUInt32LE(index + 4);
|
|
1969
|
+
const value = hi * 4294967296 + lo;
|
|
1970
|
+
if (value > Number.MAX_SAFE_INTEGER) {
|
|
1971
|
+
throw Errors.ZIP64_VALUE_TOO_LARGE();
|
|
1972
|
+
}
|
|
1973
|
+
return value;
|
|
1974
|
+
};
|
|
1975
|
+
Utils.writeBigUInt64LE = function(buffer, value, index) {
|
|
1976
|
+
const lo = value >>> 0;
|
|
1977
|
+
const hi = Math.floor(value / 4294967296) >>> 0;
|
|
1978
|
+
buffer.writeUInt32LE(lo, index);
|
|
1979
|
+
buffer.writeUInt32LE(hi, index + 4);
|
|
1873
1980
|
};
|
|
1874
1981
|
Utils.fromDOS2Date = function(val) {
|
|
1875
1982
|
return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
|
|
@@ -1888,9 +1995,9 @@ var require_utils2 = __commonJS({
|
|
|
1888
1995
|
}
|
|
1889
1996
|
});
|
|
1890
1997
|
|
|
1891
|
-
//
|
|
1998
|
+
// node_modules/adm-zip/util/fattr.js
|
|
1892
1999
|
var require_fattr = __commonJS({
|
|
1893
|
-
"
|
|
2000
|
+
"node_modules/adm-zip/util/fattr.js"(exports2, module2) {
|
|
1894
2001
|
var pth = require("path");
|
|
1895
2002
|
module2.exports = function(path19, { fs: fs18 }) {
|
|
1896
2003
|
var _path = path19 || "", _obj = newAttr(), _stat = null;
|
|
@@ -1957,9 +2064,9 @@ var require_fattr = __commonJS({
|
|
|
1957
2064
|
}
|
|
1958
2065
|
});
|
|
1959
2066
|
|
|
1960
|
-
//
|
|
2067
|
+
// node_modules/adm-zip/util/decoder.js
|
|
1961
2068
|
var require_decoder = __commonJS({
|
|
1962
|
-
"
|
|
2069
|
+
"node_modules/adm-zip/util/decoder.js"(exports2, module2) {
|
|
1963
2070
|
module2.exports = {
|
|
1964
2071
|
efs: true,
|
|
1965
2072
|
encode: (data) => Buffer.from(data, "utf8"),
|
|
@@ -1968,9 +2075,9 @@ var require_decoder = __commonJS({
|
|
|
1968
2075
|
}
|
|
1969
2076
|
});
|
|
1970
2077
|
|
|
1971
|
-
//
|
|
2078
|
+
// node_modules/adm-zip/util/index.js
|
|
1972
2079
|
var require_util = __commonJS({
|
|
1973
|
-
"
|
|
2080
|
+
"node_modules/adm-zip/util/index.js"(exports2, module2) {
|
|
1974
2081
|
module2.exports = require_utils2();
|
|
1975
2082
|
module2.exports.Constants = require_constants();
|
|
1976
2083
|
module2.exports.Errors = require_errors();
|
|
@@ -1979,9 +2086,9 @@ var require_util = __commonJS({
|
|
|
1979
2086
|
}
|
|
1980
2087
|
});
|
|
1981
2088
|
|
|
1982
|
-
//
|
|
2089
|
+
// node_modules/adm-zip/headers/entryHeader.js
|
|
1983
2090
|
var require_entryHeader = __commonJS({
|
|
1984
|
-
"
|
|
2091
|
+
"node_modules/adm-zip/headers/entryHeader.js"(exports2, module2) {
|
|
1985
2092
|
var Utils = require_util();
|
|
1986
2093
|
var Constants = Utils.Constants;
|
|
1987
2094
|
module2.exports = function() {
|
|
@@ -2041,6 +2148,7 @@ var require_entryHeader = __commonJS({
|
|
|
2041
2148
|
switch (val) {
|
|
2042
2149
|
case Constants.STORED:
|
|
2043
2150
|
this.version = 10;
|
|
2151
|
+
break;
|
|
2044
2152
|
case Constants.DEFLATED:
|
|
2045
2153
|
default:
|
|
2046
2154
|
this.version = 20;
|
|
@@ -2051,6 +2159,7 @@ var require_entryHeader = __commonJS({
|
|
|
2051
2159
|
return Utils.fromDOS2Date(this.timeval);
|
|
2052
2160
|
},
|
|
2053
2161
|
set time(val) {
|
|
2162
|
+
val = new Date(val);
|
|
2054
2163
|
this.timeval = Utils.fromDate2DOS(val);
|
|
2055
2164
|
},
|
|
2056
2165
|
get timeval() {
|
|
@@ -2124,7 +2233,7 @@ var require_entryHeader = __commonJS({
|
|
|
2124
2233
|
},
|
|
2125
2234
|
// get Unix file permissions
|
|
2126
2235
|
get fileAttr() {
|
|
2127
|
-
return (_attr || 0) >> 16 &
|
|
2236
|
+
return (_attr || 0) >> 16 & 511;
|
|
2128
2237
|
},
|
|
2129
2238
|
get offset() {
|
|
2130
2239
|
return _offset;
|
|
@@ -2145,12 +2254,16 @@ var require_entryHeader = __commonJS({
|
|
|
2145
2254
|
return _localHeader;
|
|
2146
2255
|
},
|
|
2147
2256
|
loadLocalHeaderFromBinary: function(input) {
|
|
2257
|
+
if (_offset < 0 || _offset + Constants.LOCHDR > input.length) {
|
|
2258
|
+
throw Utils.Errors.INVALID_LOC();
|
|
2259
|
+
}
|
|
2148
2260
|
var data = input.slice(_offset, _offset + Constants.LOCHDR);
|
|
2149
2261
|
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
|
|
2150
2262
|
throw Utils.Errors.INVALID_LOC();
|
|
2151
2263
|
}
|
|
2152
2264
|
_localHeader.version = data.readUInt16LE(Constants.LOCVER);
|
|
2153
2265
|
_localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
|
|
2266
|
+
_localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
|
|
2154
2267
|
_localHeader.method = data.readUInt16LE(Constants.LOCHOW);
|
|
2155
2268
|
_localHeader.time = data.readUInt32LE(Constants.LOCTIM);
|
|
2156
2269
|
_localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
|
|
@@ -2186,7 +2299,7 @@ var require_entryHeader = __commonJS({
|
|
|
2186
2299
|
var data = Buffer.alloc(Constants.LOCHDR);
|
|
2187
2300
|
data.writeUInt32LE(Constants.LOCSIG, 0);
|
|
2188
2301
|
data.writeUInt16LE(_version, Constants.LOCVER);
|
|
2189
|
-
data.writeUInt16LE(_flags, Constants.LOCFLG);
|
|
2302
|
+
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
|
|
2190
2303
|
data.writeUInt16LE(_method, Constants.LOCHOW);
|
|
2191
2304
|
data.writeUInt32LE(_time, Constants.LOCTIM);
|
|
2192
2305
|
data.writeUInt32LE(_crc, Constants.LOCCRC);
|
|
@@ -2201,7 +2314,7 @@ var require_entryHeader = __commonJS({
|
|
|
2201
2314
|
data.writeUInt32LE(Constants.CENSIG, 0);
|
|
2202
2315
|
data.writeUInt16LE(_verMade, Constants.CENVEM);
|
|
2203
2316
|
data.writeUInt16LE(_version, Constants.CENVER);
|
|
2204
|
-
data.writeUInt16LE(_flags, Constants.CENFLG);
|
|
2317
|
+
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
|
|
2205
2318
|
data.writeUInt16LE(_method, Constants.CENHOW);
|
|
2206
2319
|
data.writeUInt32LE(_time, Constants.CENTIM);
|
|
2207
2320
|
data.writeUInt32LE(_crc, Constants.CENCRC);
|
|
@@ -2247,13 +2360,14 @@ var require_entryHeader = __commonJS({
|
|
|
2247
2360
|
}
|
|
2248
2361
|
});
|
|
2249
2362
|
|
|
2250
|
-
//
|
|
2363
|
+
// node_modules/adm-zip/headers/mainHeader.js
|
|
2251
2364
|
var require_mainHeader = __commonJS({
|
|
2252
|
-
"
|
|
2365
|
+
"node_modules/adm-zip/headers/mainHeader.js"(exports2, module2) {
|
|
2253
2366
|
var Utils = require_util();
|
|
2254
2367
|
var Constants = Utils.Constants;
|
|
2255
2368
|
module2.exports = function() {
|
|
2256
2369
|
var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
|
|
2370
|
+
const needsZip64 = () => _volumeEntries > Constants.EF_ZIP64_OR_16 || _totalEntries > Constants.EF_ZIP64_OR_16 || _size > Constants.EF_ZIP64_OR_32 || _offset > Constants.EF_ZIP64_OR_32;
|
|
2257
2371
|
return {
|
|
2258
2372
|
get diskEntries() {
|
|
2259
2373
|
return _volumeEntries;
|
|
@@ -2286,7 +2400,7 @@ var require_mainHeader = __commonJS({
|
|
|
2286
2400
|
_commentLength = val;
|
|
2287
2401
|
},
|
|
2288
2402
|
get mainHeaderSize() {
|
|
2289
|
-
return Constants.ENDHDR + _commentLength;
|
|
2403
|
+
return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
|
|
2290
2404
|
},
|
|
2291
2405
|
loadFromBinary: function(data) {
|
|
2292
2406
|
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
|
|
@@ -2301,21 +2415,51 @@ var require_mainHeader = __commonJS({
|
|
|
2301
2415
|
} else {
|
|
2302
2416
|
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
|
|
2303
2417
|
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
|
|
2304
|
-
_size = Utils.readBigUInt64LE(data, Constants.
|
|
2418
|
+
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
|
|
2305
2419
|
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
|
|
2306
2420
|
_commentLength = 0;
|
|
2307
2421
|
}
|
|
2308
2422
|
},
|
|
2309
2423
|
toBinary: function() {
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2424
|
+
if (!needsZip64()) {
|
|
2425
|
+
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
|
|
2426
|
+
b.writeUInt32LE(Constants.ENDSIG, 0);
|
|
2427
|
+
b.writeUInt32LE(0, 4);
|
|
2428
|
+
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
|
|
2429
|
+
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
|
|
2430
|
+
b.writeUInt32LE(_size, Constants.ENDSIZ);
|
|
2431
|
+
b.writeUInt32LE(_offset, Constants.ENDOFF);
|
|
2432
|
+
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
|
|
2433
|
+
b.fill(" ", Constants.ENDHDR);
|
|
2434
|
+
return b;
|
|
2435
|
+
}
|
|
2436
|
+
var b = Buffer.alloc(this.mainHeaderSize);
|
|
2437
|
+
let offset = 0;
|
|
2438
|
+
b.writeUInt32LE(Constants.ZIP64SIG, offset);
|
|
2439
|
+
Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
|
|
2440
|
+
b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
|
|
2441
|
+
b.writeUInt16LE(45, offset + Constants.ZIP64VER);
|
|
2442
|
+
b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
|
|
2443
|
+
b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
|
|
2444
|
+
Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
|
|
2445
|
+
Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
|
|
2446
|
+
Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
|
|
2447
|
+
Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
|
|
2448
|
+
const zip64EndOffset = _offset + _size;
|
|
2449
|
+
offset += Constants.ZIP64HDR;
|
|
2450
|
+
b.writeUInt32LE(Constants.END64SIG, offset);
|
|
2451
|
+
b.writeUInt32LE(0, offset + Constants.END64START);
|
|
2452
|
+
Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
|
|
2453
|
+
b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
|
|
2454
|
+
offset += Constants.END64HDR;
|
|
2455
|
+
b.writeUInt32LE(Constants.ENDSIG, offset);
|
|
2456
|
+
b.writeUInt32LE(0, offset + 4);
|
|
2457
|
+
b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
|
|
2458
|
+
b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
|
|
2459
|
+
b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
|
|
2460
|
+
b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
|
|
2461
|
+
b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
|
|
2462
|
+
b.fill(" ", offset + Constants.ENDHDR);
|
|
2319
2463
|
return b;
|
|
2320
2464
|
},
|
|
2321
2465
|
toJSON: function() {
|
|
@@ -2340,17 +2484,17 @@ var require_mainHeader = __commonJS({
|
|
|
2340
2484
|
}
|
|
2341
2485
|
});
|
|
2342
2486
|
|
|
2343
|
-
//
|
|
2487
|
+
// node_modules/adm-zip/headers/index.js
|
|
2344
2488
|
var require_headers = __commonJS({
|
|
2345
|
-
"
|
|
2489
|
+
"node_modules/adm-zip/headers/index.js"(exports2) {
|
|
2346
2490
|
exports2.EntryHeader = require_entryHeader();
|
|
2347
2491
|
exports2.MainHeader = require_mainHeader();
|
|
2348
2492
|
}
|
|
2349
2493
|
});
|
|
2350
2494
|
|
|
2351
|
-
//
|
|
2495
|
+
// node_modules/adm-zip/methods/deflater.js
|
|
2352
2496
|
var require_deflater = __commonJS({
|
|
2353
|
-
"
|
|
2497
|
+
"node_modules/adm-zip/methods/deflater.js"(exports2, module2) {
|
|
2354
2498
|
module2.exports = function(inbuf) {
|
|
2355
2499
|
var zlib = require("zlib");
|
|
2356
2500
|
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
@@ -2381,24 +2525,41 @@ var require_deflater = __commonJS({
|
|
|
2381
2525
|
}
|
|
2382
2526
|
});
|
|
2383
2527
|
|
|
2384
|
-
//
|
|
2528
|
+
// node_modules/adm-zip/methods/inflater.js
|
|
2385
2529
|
var require_inflater = __commonJS({
|
|
2386
|
-
"
|
|
2387
|
-
var version = +(process
|
|
2530
|
+
"node_modules/adm-zip/methods/inflater.js"(exports2, module2) {
|
|
2531
|
+
var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
|
|
2532
|
+
var Errors = require_errors();
|
|
2388
2533
|
module2.exports = function(inbuf, expectedLength) {
|
|
2389
2534
|
var zlib = require("zlib");
|
|
2390
|
-
const
|
|
2535
|
+
const maxOutputLength = expectedLength > 0 ? expectedLength : 1;
|
|
2536
|
+
const option = version >= 15 ? { maxOutputLength } : {};
|
|
2391
2537
|
return {
|
|
2392
2538
|
inflate: function() {
|
|
2393
2539
|
return zlib.inflateRawSync(inbuf, option);
|
|
2394
2540
|
},
|
|
2395
2541
|
inflateAsync: function(callback) {
|
|
2396
|
-
var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
|
|
2542
|
+
var tmp = zlib.createInflateRaw(option), parts = [], total = 0, done = false;
|
|
2543
|
+
const fail2 = function(err) {
|
|
2544
|
+
if (done) return;
|
|
2545
|
+
done = true;
|
|
2546
|
+
tmp.destroy();
|
|
2547
|
+
callback && callback(Buffer.alloc(0), err);
|
|
2548
|
+
};
|
|
2549
|
+
tmp.on("error", function(err) {
|
|
2550
|
+
fail2(err);
|
|
2551
|
+
});
|
|
2397
2552
|
tmp.on("data", function(data) {
|
|
2398
|
-
|
|
2553
|
+
if (done) return;
|
|
2399
2554
|
total += data.length;
|
|
2555
|
+
if (total > maxOutputLength) {
|
|
2556
|
+
return fail2(Errors.MAX_OUTPUT_EXCEEDED());
|
|
2557
|
+
}
|
|
2558
|
+
parts.push(data);
|
|
2400
2559
|
});
|
|
2401
2560
|
tmp.on("end", function() {
|
|
2561
|
+
if (done) return;
|
|
2562
|
+
done = true;
|
|
2402
2563
|
var buf = Buffer.alloc(total), written = 0;
|
|
2403
2564
|
buf.fill(0);
|
|
2404
2565
|
for (var i = 0; i < parts.length; i++) {
|
|
@@ -2415,9 +2576,9 @@ var require_inflater = __commonJS({
|
|
|
2415
2576
|
}
|
|
2416
2577
|
});
|
|
2417
2578
|
|
|
2418
|
-
//
|
|
2579
|
+
// node_modules/adm-zip/methods/zipcrypto.js
|
|
2419
2580
|
var require_zipcrypto = __commonJS({
|
|
2420
|
-
"
|
|
2581
|
+
"node_modules/adm-zip/methods/zipcrypto.js"(exports2, module2) {
|
|
2421
2582
|
"use strict";
|
|
2422
2583
|
var { randomFillSync } = require("crypto");
|
|
2423
2584
|
var Errors = require_errors();
|
|
@@ -2531,18 +2692,18 @@ var require_zipcrypto = __commonJS({
|
|
|
2531
2692
|
}
|
|
2532
2693
|
});
|
|
2533
2694
|
|
|
2534
|
-
//
|
|
2695
|
+
// node_modules/adm-zip/methods/index.js
|
|
2535
2696
|
var require_methods = __commonJS({
|
|
2536
|
-
"
|
|
2697
|
+
"node_modules/adm-zip/methods/index.js"(exports2) {
|
|
2537
2698
|
exports2.Deflater = require_deflater();
|
|
2538
2699
|
exports2.Inflater = require_inflater();
|
|
2539
2700
|
exports2.ZipCrypto = require_zipcrypto();
|
|
2540
2701
|
}
|
|
2541
2702
|
});
|
|
2542
2703
|
|
|
2543
|
-
//
|
|
2704
|
+
// node_modules/adm-zip/zipEntry.js
|
|
2544
2705
|
var require_zipEntry = __commonJS({
|
|
2545
|
-
"
|
|
2706
|
+
"node_modules/adm-zip/zipEntry.js"(exports2, module2) {
|
|
2546
2707
|
var Utils = require_util();
|
|
2547
2708
|
var Headers = require_headers();
|
|
2548
2709
|
var Constants = Utils.Constants;
|
|
@@ -2557,38 +2718,16 @@ var require_zipEntry = __commonJS({
|
|
|
2557
2718
|
return Buffer.alloc(0);
|
|
2558
2719
|
}
|
|
2559
2720
|
_extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
|
|
2560
|
-
|
|
2721
|
+
const dataOffset = _centralHeader.realDataOffset;
|
|
2722
|
+
const dataEnd = dataOffset + _centralHeader.compressedSize;
|
|
2723
|
+
if (dataOffset < 0 || dataEnd < dataOffset || dataEnd > input.length) {
|
|
2724
|
+
throw Utils.Errors.INVALID_LOC();
|
|
2725
|
+
}
|
|
2726
|
+
return input.slice(dataOffset, dataEnd);
|
|
2561
2727
|
}
|
|
2562
2728
|
function crc32OK(data) {
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
return false;
|
|
2566
|
-
}
|
|
2567
|
-
} else {
|
|
2568
|
-
const descriptor = {};
|
|
2569
|
-
const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
|
|
2570
|
-
if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
|
|
2571
|
-
throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
|
|
2572
|
-
}
|
|
2573
|
-
if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
|
|
2574
|
-
descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
|
|
2575
|
-
descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
|
|
2576
|
-
descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
|
|
2577
|
-
} else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
|
|
2578
|
-
descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
|
|
2579
|
-
descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
|
|
2580
|
-
descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
|
|
2581
|
-
} else {
|
|
2582
|
-
throw Utils.Errors.DESCRIPTOR_UNKNOWN();
|
|
2583
|
-
}
|
|
2584
|
-
if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
|
|
2585
|
-
throw Utils.Errors.DESCRIPTOR_FAULTY();
|
|
2586
|
-
}
|
|
2587
|
-
if (Utils.crc32(data) !== descriptor.crc) {
|
|
2588
|
-
return false;
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
return true;
|
|
2729
|
+
const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
|
|
2730
|
+
return Utils.crc32(data) === expectedCrc;
|
|
2592
2731
|
}
|
|
2593
2732
|
function decompress(async, callback, pass) {
|
|
2594
2733
|
if (typeof callback === "undefined" && typeof async === "string") {
|
|
@@ -2601,20 +2740,30 @@ var require_zipEntry = __commonJS({
|
|
|
2601
2740
|
}
|
|
2602
2741
|
return Buffer.alloc(0);
|
|
2603
2742
|
}
|
|
2604
|
-
var compressedData
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
|
|
2611
|
-
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
2743
|
+
var compressedData;
|
|
2744
|
+
try {
|
|
2745
|
+
compressedData = getCompressedDataFromZip();
|
|
2746
|
+
if (compressedData.length === 0) {
|
|
2747
|
+
if (async && callback) callback(compressedData);
|
|
2748
|
+
return compressedData;
|
|
2612
2749
|
}
|
|
2613
|
-
|
|
2750
|
+
if (_centralHeader.encrypted) {
|
|
2751
|
+
if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
|
|
2752
|
+
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
2753
|
+
}
|
|
2754
|
+
compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
|
|
2755
|
+
}
|
|
2756
|
+
} catch (err) {
|
|
2757
|
+
if (async && callback) {
|
|
2758
|
+
callback(Buffer.alloc(0), err);
|
|
2759
|
+
return Buffer.alloc(0);
|
|
2760
|
+
}
|
|
2761
|
+
throw err;
|
|
2614
2762
|
}
|
|
2615
|
-
var data
|
|
2763
|
+
var data;
|
|
2616
2764
|
switch (_centralHeader.method) {
|
|
2617
2765
|
case Utils.Constants.STORED:
|
|
2766
|
+
data = Buffer.alloc(compressedData.length);
|
|
2618
2767
|
compressedData.copy(data);
|
|
2619
2768
|
if (!crc32OK(data)) {
|
|
2620
2769
|
if (async && callback) callback(data, Utils.Errors.BAD_CRC());
|
|
@@ -2626,21 +2775,20 @@ var require_zipEntry = __commonJS({
|
|
|
2626
2775
|
case Utils.Constants.DEFLATED:
|
|
2627
2776
|
var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
|
|
2628
2777
|
if (!async) {
|
|
2629
|
-
|
|
2630
|
-
result.copy(data, 0);
|
|
2778
|
+
data = inflater.inflate();
|
|
2631
2779
|
if (!crc32OK(data)) {
|
|
2632
2780
|
throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
|
|
2633
2781
|
}
|
|
2634
2782
|
return data;
|
|
2635
2783
|
} else {
|
|
2636
|
-
inflater.inflateAsync(function(result) {
|
|
2637
|
-
|
|
2638
|
-
if (
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2784
|
+
inflater.inflateAsync(function(result, err) {
|
|
2785
|
+
if (!callback) return;
|
|
2786
|
+
if (err) {
|
|
2787
|
+
callback(Buffer.alloc(0), err);
|
|
2788
|
+
} else if (!crc32OK(result)) {
|
|
2789
|
+
callback(result, Utils.Errors.BAD_CRC());
|
|
2790
|
+
} else {
|
|
2791
|
+
callback(result);
|
|
2644
2792
|
}
|
|
2645
2793
|
});
|
|
2646
2794
|
}
|
|
@@ -2689,7 +2837,7 @@ var require_zipEntry = __commonJS({
|
|
|
2689
2837
|
}
|
|
2690
2838
|
}
|
|
2691
2839
|
function readUInt64LE(buffer, offset) {
|
|
2692
|
-
return (buffer
|
|
2840
|
+
return Utils.readBigUInt64LE(buffer, offset);
|
|
2693
2841
|
}
|
|
2694
2842
|
function parseExtra(data) {
|
|
2695
2843
|
try {
|
|
@@ -2774,8 +2922,8 @@ var require_zipEntry = __commonJS({
|
|
|
2774
2922
|
if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
|
|
2775
2923
|
},
|
|
2776
2924
|
get name() {
|
|
2777
|
-
|
|
2778
|
-
return _isDirectory ? n.
|
|
2925
|
+
const n = decoder.decode(_entryName);
|
|
2926
|
+
return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
|
|
2779
2927
|
},
|
|
2780
2928
|
get isDirectory() {
|
|
2781
2929
|
return _isDirectory;
|
|
@@ -2871,14 +3019,14 @@ var require_zipEntry = __commonJS({
|
|
|
2871
3019
|
}
|
|
2872
3020
|
});
|
|
2873
3021
|
|
|
2874
|
-
//
|
|
3022
|
+
// node_modules/adm-zip/zipFile.js
|
|
2875
3023
|
var require_zipFile = __commonJS({
|
|
2876
|
-
"
|
|
3024
|
+
"node_modules/adm-zip/zipFile.js"(exports2, module2) {
|
|
2877
3025
|
var ZipEntry = require_zipEntry();
|
|
2878
3026
|
var Headers = require_headers();
|
|
2879
3027
|
var Utils = require_util();
|
|
2880
3028
|
module2.exports = function(inBuffer, options) {
|
|
2881
|
-
var entryList = [], entryTable =
|
|
3029
|
+
var entryList = [], entryTable = /* @__PURE__ */ Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
|
|
2882
3030
|
var password = null;
|
|
2883
3031
|
const temporary = /* @__PURE__ */ new Set();
|
|
2884
3032
|
const opts = options;
|
|
@@ -2913,7 +3061,7 @@ var require_zipFile = __commonJS({
|
|
|
2913
3061
|
}
|
|
2914
3062
|
function readEntries() {
|
|
2915
3063
|
loadedEntries = true;
|
|
2916
|
-
entryTable =
|
|
3064
|
+
entryTable = /* @__PURE__ */ Object.create(null);
|
|
2917
3065
|
if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
|
|
2918
3066
|
throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
|
|
2919
3067
|
}
|
|
@@ -2928,6 +3076,9 @@ var require_zipFile = __commonJS({
|
|
|
2928
3076
|
}
|
|
2929
3077
|
if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
|
|
2930
3078
|
index += entry.header.centralHeaderSize;
|
|
3079
|
+
if (entry.entryName in entryTable) {
|
|
3080
|
+
throw Utils.Errors.DUPLICATE_ENTRY(`"${entry.entryName}"`);
|
|
3081
|
+
}
|
|
2931
3082
|
entryList[i] = entry;
|
|
2932
3083
|
entryTable[entry.entryName] = entry;
|
|
2933
3084
|
}
|
|
@@ -2966,7 +3117,7 @@ var require_zipFile = __commonJS({
|
|
|
2966
3117
|
}
|
|
2967
3118
|
function sortEntries() {
|
|
2968
3119
|
if (entryList.length > 1 && !noSort) {
|
|
2969
|
-
entryList.sort((a, b) => a.
|
|
3120
|
+
entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
|
|
2970
3121
|
}
|
|
2971
3122
|
}
|
|
2972
3123
|
return {
|
|
@@ -3143,7 +3294,7 @@ var require_zipFile = __commonJS({
|
|
|
3143
3294
|
}
|
|
3144
3295
|
const mh = mainHeader.toBinary();
|
|
3145
3296
|
if (_comment) {
|
|
3146
|
-
_comment.copy(mh,
|
|
3297
|
+
_comment.copy(mh, mh.length - _comment.length);
|
|
3147
3298
|
}
|
|
3148
3299
|
mh.copy(outBuffer, dindex);
|
|
3149
3300
|
inBuffer = outBuffer;
|
|
@@ -3199,7 +3350,7 @@ var require_zipFile = __commonJS({
|
|
|
3199
3350
|
});
|
|
3200
3351
|
const mh = mainHeader.toBinary();
|
|
3201
3352
|
if (_comment) {
|
|
3202
|
-
_comment.copy(mh,
|
|
3353
|
+
_comment.copy(mh, mh.length - _comment.length);
|
|
3203
3354
|
}
|
|
3204
3355
|
mh.copy(outBuffer, dindex);
|
|
3205
3356
|
inBuffer = outBuffer;
|
|
@@ -3217,9 +3368,9 @@ var require_zipFile = __commonJS({
|
|
|
3217
3368
|
}
|
|
3218
3369
|
});
|
|
3219
3370
|
|
|
3220
|
-
//
|
|
3371
|
+
// node_modules/adm-zip/adm-zip.js
|
|
3221
3372
|
var require_adm_zip = __commonJS({
|
|
3222
|
-
"
|
|
3373
|
+
"node_modules/adm-zip/adm-zip.js"(exports2, module2) {
|
|
3223
3374
|
var Utils = require_util();
|
|
3224
3375
|
var pth = require("path");
|
|
3225
3376
|
var ZipEntry = require_zipEntry();
|
|
@@ -3254,6 +3405,9 @@ var require_adm_zip = __commonJS({
|
|
|
3254
3405
|
}
|
|
3255
3406
|
Object.assign(opts, options);
|
|
3256
3407
|
const filetools = new Utils(opts);
|
|
3408
|
+
const applyDirAttributes = (dirEntries) => {
|
|
3409
|
+
dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
|
|
3410
|
+
};
|
|
3257
3411
|
if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
|
|
3258
3412
|
opts.decoder = Utils.decoder;
|
|
3259
3413
|
}
|
|
@@ -3281,15 +3435,15 @@ var require_adm_zip = __commonJS({
|
|
|
3281
3435
|
}
|
|
3282
3436
|
function fixPath(zipPath) {
|
|
3283
3437
|
const { join, normalize, sep } = pth.posix;
|
|
3284
|
-
return join(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
3438
|
+
return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
3285
3439
|
}
|
|
3286
3440
|
function filenameFilter(filterfn) {
|
|
3287
3441
|
if (filterfn instanceof RegExp) {
|
|
3288
|
-
return /* @__PURE__ */ function(rx) {
|
|
3442
|
+
return /* @__PURE__ */ (function(rx) {
|
|
3289
3443
|
return function(filename) {
|
|
3290
3444
|
return rx.test(filename);
|
|
3291
3445
|
};
|
|
3292
|
-
}(filterfn);
|
|
3446
|
+
})(filterfn);
|
|
3293
3447
|
} else if ("function" !== typeof filterfn) {
|
|
3294
3448
|
return () => true;
|
|
3295
3449
|
}
|
|
@@ -3384,6 +3538,7 @@ var require_adm_zip = __commonJS({
|
|
|
3384
3538
|
* Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
|
|
3385
3539
|
*
|
|
3386
3540
|
* @param {ZipEntry|string} entry
|
|
3541
|
+
* @param {boolean} withsubfolders
|
|
3387
3542
|
* @returns {void}
|
|
3388
3543
|
*/
|
|
3389
3544
|
deleteFile: function(entry, withsubfolders = true) {
|
|
@@ -3466,17 +3621,17 @@ var require_adm_zip = __commonJS({
|
|
|
3466
3621
|
* @param {string} [zipName] Optional name for the file
|
|
3467
3622
|
* @param {string} [comment] Optional file comment
|
|
3468
3623
|
*/
|
|
3469
|
-
addLocalFile: function(
|
|
3470
|
-
if (filetools.fs.existsSync(
|
|
3624
|
+
addLocalFile: function(localPath, zipPath, zipName, comment) {
|
|
3625
|
+
if (filetools.fs.existsSync(localPath)) {
|
|
3471
3626
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3472
|
-
const p = pth.win32.basename(pth.win32.normalize(
|
|
3627
|
+
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
3473
3628
|
zipPath += zipName ? zipName : p;
|
|
3474
|
-
const _attr = filetools.fs.statSync(
|
|
3475
|
-
const data = _attr.isFile() ? filetools.fs.readFileSync(
|
|
3629
|
+
const _attr = filetools.fs.statSync(localPath);
|
|
3630
|
+
const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
|
|
3476
3631
|
if (_attr.isDirectory()) zipPath += filetools.sep;
|
|
3477
3632
|
this.addFile(zipPath, data, comment, _attr);
|
|
3478
3633
|
} else {
|
|
3479
|
-
throw Utils.Errors.FILE_NOT_FOUND(
|
|
3634
|
+
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
3480
3635
|
}
|
|
3481
3636
|
},
|
|
3482
3637
|
/**
|
|
@@ -3498,17 +3653,17 @@ var require_adm_zip = __commonJS({
|
|
|
3498
3653
|
*/
|
|
3499
3654
|
addLocalFileAsync: function(options2, callback) {
|
|
3500
3655
|
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
3501
|
-
const
|
|
3656
|
+
const localPath = pth.resolve(options2.localPath);
|
|
3502
3657
|
const { comment } = options2;
|
|
3503
3658
|
let { zipPath, zipName } = options2;
|
|
3504
3659
|
const self = this;
|
|
3505
|
-
filetools.fs.stat(
|
|
3660
|
+
filetools.fs.stat(localPath, function(err, stats) {
|
|
3506
3661
|
if (err) return callback(err, false);
|
|
3507
3662
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3508
|
-
const p = pth.win32.basename(pth.win32.normalize(
|
|
3663
|
+
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
3509
3664
|
zipPath += zipName ? zipName : p;
|
|
3510
3665
|
if (stats.isFile()) {
|
|
3511
|
-
filetools.fs.readFile(
|
|
3666
|
+
filetools.fs.readFile(localPath, function(err2, data) {
|
|
3512
3667
|
if (err2) return callback(err2, false);
|
|
3513
3668
|
self.addFile(zipPath, data, comment, stats);
|
|
3514
3669
|
return setImmediate(callback, void 0, true);
|
|
@@ -3527,23 +3682,23 @@ var require_adm_zip = __commonJS({
|
|
|
3527
3682
|
* @param {string} [zipPath] - optional path inside zip
|
|
3528
3683
|
* @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
|
|
3529
3684
|
*/
|
|
3530
|
-
addLocalFolder: function(
|
|
3685
|
+
addLocalFolder: function(localPath, zipPath, filter) {
|
|
3531
3686
|
filter = filenameFilter(filter);
|
|
3532
3687
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3533
|
-
|
|
3534
|
-
if (filetools.fs.existsSync(
|
|
3535
|
-
const items = filetools.findFiles(
|
|
3688
|
+
localPath = pth.normalize(localPath);
|
|
3689
|
+
if (filetools.fs.existsSync(localPath)) {
|
|
3690
|
+
const items = filetools.findFiles(localPath);
|
|
3536
3691
|
const self = this;
|
|
3537
3692
|
if (items.length) {
|
|
3538
3693
|
for (const filepath of items) {
|
|
3539
|
-
const p = pth.join(zipPath, relativePath(
|
|
3694
|
+
const p = pth.join(zipPath, relativePath(localPath, filepath));
|
|
3540
3695
|
if (filter(p)) {
|
|
3541
3696
|
self.addLocalFile(filepath, pth.dirname(p));
|
|
3542
3697
|
}
|
|
3543
3698
|
}
|
|
3544
3699
|
}
|
|
3545
3700
|
} else {
|
|
3546
|
-
throw Utils.Errors.FILE_NOT_FOUND(
|
|
3701
|
+
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
3547
3702
|
}
|
|
3548
3703
|
},
|
|
3549
3704
|
/**
|
|
@@ -3554,24 +3709,24 @@ var require_adm_zip = __commonJS({
|
|
|
3554
3709
|
* @param {RegExp|function} [filter] optional RegExp or Function if files match will
|
|
3555
3710
|
* be included.
|
|
3556
3711
|
*/
|
|
3557
|
-
addLocalFolderAsync: function(
|
|
3712
|
+
addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
|
|
3558
3713
|
filter = filenameFilter(filter);
|
|
3559
3714
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3560
|
-
|
|
3715
|
+
localPath = pth.normalize(localPath);
|
|
3561
3716
|
var self = this;
|
|
3562
|
-
filetools.fs.open(
|
|
3717
|
+
filetools.fs.open(localPath, "r", function(err) {
|
|
3563
3718
|
if (err && err.code === "ENOENT") {
|
|
3564
|
-
callback(void 0, Utils.Errors.FILE_NOT_FOUND(
|
|
3719
|
+
callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
3565
3720
|
} else if (err) {
|
|
3566
3721
|
callback(void 0, err);
|
|
3567
3722
|
} else {
|
|
3568
|
-
var items = filetools.findFiles(
|
|
3723
|
+
var items = filetools.findFiles(localPath);
|
|
3569
3724
|
var i = -1;
|
|
3570
3725
|
var next = function() {
|
|
3571
3726
|
i += 1;
|
|
3572
3727
|
if (i < items.length) {
|
|
3573
3728
|
var filepath = items[i];
|
|
3574
|
-
var p = relativePath(
|
|
3729
|
+
var p = relativePath(localPath, filepath).split("\\").join("/");
|
|
3575
3730
|
p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
3576
3731
|
if (filter(p)) {
|
|
3577
3732
|
filetools.fs.stat(filepath, function(er0, stats) {
|
|
@@ -3617,21 +3772,21 @@ var require_adm_zip = __commonJS({
|
|
|
3617
3772
|
addLocalFolderAsync2: function(options2, callback) {
|
|
3618
3773
|
const self = this;
|
|
3619
3774
|
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
3620
|
-
localPath = pth.resolve(
|
|
3775
|
+
const localPath = pth.resolve(options2.localPath);
|
|
3621
3776
|
let { zipPath, filter, namefix } = options2;
|
|
3622
3777
|
if (filter instanceof RegExp) {
|
|
3623
|
-
filter = /* @__PURE__ */ function(rx) {
|
|
3778
|
+
filter = /* @__PURE__ */ (function(rx) {
|
|
3624
3779
|
return function(filename) {
|
|
3625
3780
|
return rx.test(filename);
|
|
3626
3781
|
};
|
|
3627
|
-
}(filter);
|
|
3782
|
+
})(filter);
|
|
3628
3783
|
} else if ("function" !== typeof filter) {
|
|
3629
3784
|
filter = function() {
|
|
3630
3785
|
return true;
|
|
3631
3786
|
};
|
|
3632
3787
|
}
|
|
3633
3788
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3634
|
-
if (namefix
|
|
3789
|
+
if (namefix === "latin1") {
|
|
3635
3790
|
namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
3636
3791
|
}
|
|
3637
3792
|
if (typeof namefix !== "function") namefix = (str) => str;
|
|
@@ -3639,14 +3794,14 @@ var require_adm_zip = __commonJS({
|
|
|
3639
3794
|
const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
|
|
3640
3795
|
filetools.fs.open(localPath, "r", function(err) {
|
|
3641
3796
|
if (err && err.code === "ENOENT") {
|
|
3642
|
-
callback(
|
|
3797
|
+
callback(Utils.Errors.FILE_NOT_FOUND(localPath), false);
|
|
3643
3798
|
} else if (err) {
|
|
3644
|
-
callback(
|
|
3799
|
+
callback(err, false);
|
|
3645
3800
|
} else {
|
|
3646
3801
|
filetools.findFilesAsync(localPath, function(err2, fileEntries) {
|
|
3647
|
-
if (err2) return callback(err2);
|
|
3802
|
+
if (err2) return callback(err2, false);
|
|
3648
3803
|
fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
|
|
3649
|
-
if (!fileEntries.length) callback(void 0,
|
|
3804
|
+
if (!fileEntries.length) return callback(void 0, true);
|
|
3650
3805
|
setImmediate(
|
|
3651
3806
|
fileEntries.reverse().reduce(function(next, entry) {
|
|
3652
3807
|
return function(err3, done) {
|
|
@@ -3675,10 +3830,10 @@ var require_adm_zip = __commonJS({
|
|
|
3675
3830
|
* @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
|
|
3676
3831
|
* @param {function|string} [props.namefix] - optional function to help fix filename
|
|
3677
3832
|
*/
|
|
3678
|
-
addLocalFolderPromise: function(
|
|
3833
|
+
addLocalFolderPromise: function(localPath, props) {
|
|
3679
3834
|
return new Promise((resolve, reject) => {
|
|
3680
|
-
this.addLocalFolderAsync2(Object.assign({ localPath
|
|
3681
|
-
if (err) reject(err);
|
|
3835
|
+
this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
|
|
3836
|
+
if (err) return reject(err);
|
|
3682
3837
|
if (done) resolve(this);
|
|
3683
3838
|
});
|
|
3684
3839
|
});
|
|
@@ -3769,7 +3924,7 @@ var require_adm_zip = __commonJS({
|
|
|
3769
3924
|
throw Utils.Errors.NO_ENTRY();
|
|
3770
3925
|
}
|
|
3771
3926
|
var entryName = canonical(item.entryName);
|
|
3772
|
-
var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
3927
|
+
var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
3773
3928
|
if (item.isDirectory) {
|
|
3774
3929
|
var children = _zip.getEntryChildren(item);
|
|
3775
3930
|
children.forEach(function(child) {
|
|
@@ -3778,8 +3933,9 @@ var require_adm_zip = __commonJS({
|
|
|
3778
3933
|
if (!content2) {
|
|
3779
3934
|
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
3780
3935
|
}
|
|
3781
|
-
var name = canonical(child.entryName);
|
|
3782
|
-
var childName = sanitize(targetPath,
|
|
3936
|
+
var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
|
|
3937
|
+
var childName = sanitize(targetPath, name);
|
|
3938
|
+
filetools.assertPathSafe(targetPath, childName);
|
|
3783
3939
|
const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
|
|
3784
3940
|
filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
|
|
3785
3941
|
});
|
|
@@ -3787,6 +3943,7 @@ var require_adm_zip = __commonJS({
|
|
|
3787
3943
|
}
|
|
3788
3944
|
var content = item.getData(_zip.password);
|
|
3789
3945
|
if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
3946
|
+
filetools.assertPathSafe(targetPath, target);
|
|
3790
3947
|
if (filetools.fs.existsSync(target) && !overwrite) {
|
|
3791
3948
|
throw Utils.Errors.CANT_OVERRIDE();
|
|
3792
3949
|
}
|
|
@@ -3802,12 +3959,12 @@ var require_adm_zip = __commonJS({
|
|
|
3802
3959
|
if (!_zip) {
|
|
3803
3960
|
return false;
|
|
3804
3961
|
}
|
|
3805
|
-
for (var entry
|
|
3962
|
+
for (var entry of _zip.entries) {
|
|
3806
3963
|
try {
|
|
3807
3964
|
if (entry.isDirectory) {
|
|
3808
3965
|
continue;
|
|
3809
3966
|
}
|
|
3810
|
-
var content =
|
|
3967
|
+
var content = entry.getData(pass);
|
|
3811
3968
|
if (!content) {
|
|
3812
3969
|
return false;
|
|
3813
3970
|
}
|
|
@@ -3832,10 +3989,13 @@ var require_adm_zip = __commonJS({
|
|
|
3832
3989
|
pass = get_Str(keepOriginalPermission, pass);
|
|
3833
3990
|
overwrite = get_Bool(false, overwrite);
|
|
3834
3991
|
if (!_zip) throw Utils.Errors.NO_ZIP();
|
|
3992
|
+
const dirEntries = [];
|
|
3835
3993
|
_zip.entries.forEach(function(entry) {
|
|
3836
3994
|
var entryName = sanitize(targetPath, canonical(entry.entryName));
|
|
3995
|
+
filetools.assertPathSafe(targetPath, entryName);
|
|
3837
3996
|
if (entry.isDirectory) {
|
|
3838
3997
|
filetools.makeDir(entryName);
|
|
3998
|
+
if (keepOriginalPermission) dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
|
|
3839
3999
|
return;
|
|
3840
4000
|
}
|
|
3841
4001
|
var content = entry.getData(pass);
|
|
@@ -3847,9 +4007,9 @@ var require_adm_zip = __commonJS({
|
|
|
3847
4007
|
try {
|
|
3848
4008
|
filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
|
|
3849
4009
|
} catch (err) {
|
|
3850
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
3851
4010
|
}
|
|
3852
4011
|
});
|
|
4012
|
+
applyDirAttributes(dirEntries);
|
|
3853
4013
|
},
|
|
3854
4014
|
/**
|
|
3855
4015
|
* Asynchronous extractAllTo
|
|
@@ -3892,17 +4052,33 @@ var require_adm_zip = __commonJS({
|
|
|
3892
4052
|
fileEntries.push(e);
|
|
3893
4053
|
}
|
|
3894
4054
|
});
|
|
4055
|
+
const deferredDirAttr = [];
|
|
3895
4056
|
for (const entry of dirEntries) {
|
|
3896
4057
|
const dirPath = getPath2(entry);
|
|
3897
4058
|
const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
|
|
3898
4059
|
try {
|
|
4060
|
+
filetools.assertPathSafe(targetPath, dirPath);
|
|
3899
4061
|
filetools.makeDir(dirPath);
|
|
3900
|
-
if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
|
|
3901
|
-
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
3902
4062
|
} catch (er) {
|
|
3903
4063
|
callback(getError("Unable to create folder", dirPath));
|
|
4064
|
+
continue;
|
|
4065
|
+
}
|
|
4066
|
+
if (dirAttr) deferredDirAttr.push({ path: dirPath, attr: dirAttr });
|
|
4067
|
+
try {
|
|
4068
|
+
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
4069
|
+
} catch (er) {
|
|
3904
4070
|
}
|
|
3905
4071
|
}
|
|
4072
|
+
const done = (err) => {
|
|
4073
|
+
if (!err) {
|
|
4074
|
+
try {
|
|
4075
|
+
applyDirAttributes(deferredDirAttr);
|
|
4076
|
+
} catch (er) {
|
|
4077
|
+
return callback(getError("Unable to set folder permissions", er.path || ""));
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
callback(err);
|
|
4081
|
+
};
|
|
3906
4082
|
fileEntries.reverse().reduce(function(next, entry) {
|
|
3907
4083
|
return function(err) {
|
|
3908
4084
|
if (err) {
|
|
@@ -3910,6 +4086,11 @@ var require_adm_zip = __commonJS({
|
|
|
3910
4086
|
} else {
|
|
3911
4087
|
const entryName = pth.normalize(canonical(entry.entryName));
|
|
3912
4088
|
const filePath = sanitize(targetPath, entryName);
|
|
4089
|
+
try {
|
|
4090
|
+
filetools.assertPathSafe(targetPath, filePath);
|
|
4091
|
+
} catch (er) {
|
|
4092
|
+
return next(er);
|
|
4093
|
+
}
|
|
3913
4094
|
entry.getDataAsync(function(content, err_1) {
|
|
3914
4095
|
if (err_1) {
|
|
3915
4096
|
next(err_1);
|
|
@@ -3919,21 +4100,17 @@ var require_adm_zip = __commonJS({
|
|
|
3919
4100
|
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
|
|
3920
4101
|
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
|
|
3921
4102
|
if (!succ) {
|
|
3922
|
-
next(getError("Unable to write file", filePath));
|
|
4103
|
+
return next(getError("Unable to write file", filePath));
|
|
3923
4104
|
}
|
|
3924
|
-
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(
|
|
3925
|
-
|
|
3926
|
-
next(getError("Unable to set times", filePath));
|
|
3927
|
-
} else {
|
|
3928
|
-
next();
|
|
3929
|
-
}
|
|
4105
|
+
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
|
|
4106
|
+
next();
|
|
3930
4107
|
});
|
|
3931
4108
|
});
|
|
3932
4109
|
}
|
|
3933
4110
|
});
|
|
3934
4111
|
}
|
|
3935
4112
|
};
|
|
3936
|
-
},
|
|
4113
|
+
}, done)();
|
|
3937
4114
|
},
|
|
3938
4115
|
/**
|
|
3939
4116
|
* Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
|
|
@@ -6584,11 +6761,11 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
6584
6761
|
if (!this.#props.apiRequest) {
|
|
6585
6762
|
return void 0;
|
|
6586
6763
|
}
|
|
6587
|
-
this.#apiRequest ??= (arg) => this.#props.apiRequest({
|
|
6764
|
+
this.#apiRequest ??= ((arg) => this.#props.apiRequest({
|
|
6588
6765
|
...arg,
|
|
6589
6766
|
context: this.context,
|
|
6590
6767
|
logger: this.logger
|
|
6591
|
-
});
|
|
6768
|
+
}));
|
|
6592
6769
|
return this.#apiRequest;
|
|
6593
6770
|
}
|
|
6594
6771
|
// The bag every handler receives. Memoized: one bag per context, so the `helpers` factory runs once.
|
|
@@ -7260,11 +7437,13 @@ var RealtimeInboundInvocationSchema = z.looseObject({
|
|
|
7260
7437
|
queryParams: anyRecord().optional(),
|
|
7261
7438
|
body: z.unknown(),
|
|
7262
7439
|
rawBody: z.string().optional(),
|
|
7440
|
+
webhookData: anyRecord().nullish(),
|
|
7263
7441
|
connectionId: z.string().nullish()
|
|
7264
7442
|
});
|
|
7265
7443
|
var RealtimeSelectInvocationSchema = z.looseObject({
|
|
7266
7444
|
eventName: z.string().min(1),
|
|
7267
7445
|
eventData: z.unknown(),
|
|
7446
|
+
webhookData: anyRecord().nullish(),
|
|
7268
7447
|
triggers: z.array(z.looseObject({
|
|
7269
7448
|
id: z.string().min(1),
|
|
7270
7449
|
// A partially-configured instance is legal — `match` treats an empty param as "matches all".
|
|
@@ -7273,12 +7452,13 @@ var RealtimeSelectInvocationSchema = z.looseObject({
|
|
|
7273
7452
|
});
|
|
7274
7453
|
|
|
7275
7454
|
// ../../flow-extension-runner/src/v2/realtime-triggers/verify.ts
|
|
7276
|
-
function verifyDeclarative(verify, rawBody, headers, config) {
|
|
7455
|
+
function verifyDeclarative(verify, rawBody, headers, config, webhookData) {
|
|
7277
7456
|
const provided = headers[verify.header] ?? headers[verify.header.toLowerCase()];
|
|
7278
7457
|
if (!provided) {
|
|
7279
7458
|
return false;
|
|
7280
7459
|
}
|
|
7281
|
-
const
|
|
7460
|
+
const secret = verify.secret(config, { webhookData });
|
|
7461
|
+
const computed = Flowrunner.crypto.hmac(verify.algo, secret, rawBody ?? "", verify.encoding);
|
|
7282
7462
|
if (!Flowrunner.crypto.timingSafeEqual(provided, computed)) {
|
|
7283
7463
|
return false;
|
|
7284
7464
|
}
|
|
@@ -7412,8 +7592,9 @@ var RealtimeSetup = class {
|
|
|
7412
7592
|
const headers = invocation.headers ?? {};
|
|
7413
7593
|
const body = invocation.body;
|
|
7414
7594
|
const rawBody = invocation.rawBody;
|
|
7595
|
+
const webhookData = invocation.webhookData ?? null;
|
|
7415
7596
|
if (this.props.handshake) {
|
|
7416
|
-
const result = await this.props.handshake(ctx.bagWith({ requestBody: body, headers, rawBody }));
|
|
7597
|
+
const result = await this.props.handshake(ctx.bagWith({ requestBody: body, headers, rawBody, webhookData }));
|
|
7417
7598
|
if (result && (result.responseToExternalService !== void 0 || result.responseHeaders || result.responseToWebhook)) {
|
|
7418
7599
|
return {
|
|
7419
7600
|
handshake: true,
|
|
@@ -7426,7 +7607,7 @@ var RealtimeSetup = class {
|
|
|
7426
7607
|
if (isEmptyBody(body)) {
|
|
7427
7608
|
return { handshake: true, events: [] };
|
|
7428
7609
|
}
|
|
7429
|
-
if (!await this.#verify(rawBody, headers, ctx)) {
|
|
7610
|
+
if (!await this.#verify(rawBody, headers, webhookData, ctx)) {
|
|
7430
7611
|
ctx.logger.warn(`[flow-extension:${this.extension.id}] webhook signature verification failed \u2014 answering 401`);
|
|
7431
7612
|
return { events: [], responseToWebhook: { httpStatus: 401, rawBody: "" } };
|
|
7432
7613
|
}
|
|
@@ -7436,6 +7617,7 @@ var RealtimeSetup = class {
|
|
|
7436
7617
|
headers,
|
|
7437
7618
|
query: invocation.queryParams ?? {},
|
|
7438
7619
|
body,
|
|
7620
|
+
webhookData,
|
|
7439
7621
|
connectionId: invocation.connectionId
|
|
7440
7622
|
}));
|
|
7441
7623
|
return {
|
|
@@ -7464,12 +7646,12 @@ var RealtimeSetup = class {
|
|
|
7464
7646
|
return { events, eventScopeId, connectionId: invocation.connectionId };
|
|
7465
7647
|
}
|
|
7466
7648
|
// The author's own check wins; otherwise the declarative one; otherwise nothing was asked for.
|
|
7467
|
-
async #verify(rawBody, headers, ctx) {
|
|
7649
|
+
async #verify(rawBody, headers, webhookData, ctx) {
|
|
7468
7650
|
if (this.props.verifyRequest) {
|
|
7469
|
-
return !!await this.props.verifyRequest(ctx.bagWith({ rawBody, headers, config: ctx.config }));
|
|
7651
|
+
return !!await this.props.verifyRequest(ctx.bagWith({ rawBody, headers, webhookData, config: ctx.config }));
|
|
7470
7652
|
}
|
|
7471
7653
|
if (this.props.verify) {
|
|
7472
|
-
return verifyDeclarative(this.props.verify, rawBody, headers, ctx.config);
|
|
7654
|
+
return verifyDeclarative(this.props.verify, rawBody, headers, ctx.config, webhookData);
|
|
7473
7655
|
}
|
|
7474
7656
|
return true;
|
|
7475
7657
|
}
|
|
@@ -7489,8 +7671,9 @@ var RealtimeSetup = class {
|
|
|
7489
7671
|
return { ids: [], enrichedEventData: null };
|
|
7490
7672
|
}
|
|
7491
7673
|
const eventData = invocation.eventData;
|
|
7492
|
-
const
|
|
7493
|
-
const
|
|
7674
|
+
const webhookData = invocation.webhookData ?? null;
|
|
7675
|
+
const ids = (invocation.triggers ?? []).filter((instance) => trigger.matches(instance.data ?? {}, eventData, webhookData)).map((instance) => instance.id);
|
|
7676
|
+
const enrichedEventData = ids.length && trigger.hasExtendResult() ? await trigger.extendResult(eventData, ctx, webhookData) : null;
|
|
7494
7677
|
return { ids, enrichedEventData };
|
|
7495
7678
|
}
|
|
7496
7679
|
};
|
|
@@ -7551,14 +7734,18 @@ var RealtimeTriggerMethod = class extends ExtensionMethod {
|
|
|
7551
7734
|
* Whether one CONFIGURED INSTANCE of this trigger cares about an event. Declarative form: type-coerced
|
|
7552
7735
|
* equality per filled param, where an empty param means "any" — that is what lets a user leave a filter
|
|
7553
7736
|
* blank and receive everything. Predicate form: the author decides. No `match` at all: always fires.
|
|
7737
|
+
*
|
|
7738
|
+
* `webhookData` is handed to the predicate form to be READ — an instance filter that depends on what the
|
|
7739
|
+
* subscription registered (a tenant id, a resource the webhook was scoped to) has nowhere else to get it.
|
|
7740
|
+
* Returning a new document is not a thing this seam can do; only subscribe/refresh/unsubscribe persist.
|
|
7554
7741
|
*/
|
|
7555
|
-
matches(params, providerEventData) {
|
|
7742
|
+
matches(params, providerEventData, webhookData = null) {
|
|
7556
7743
|
const match = this.props.match;
|
|
7557
7744
|
if (!match) {
|
|
7558
7745
|
return true;
|
|
7559
7746
|
}
|
|
7560
7747
|
if (typeof match === "function") {
|
|
7561
|
-
return !!match({ params, providerEventData });
|
|
7748
|
+
return !!match({ params, providerEventData, webhookData });
|
|
7562
7749
|
}
|
|
7563
7750
|
for (const [paramKey, path19] of Object.entries(match)) {
|
|
7564
7751
|
const paramValue = params[paramKey];
|
|
@@ -7572,8 +7759,9 @@ var RealtimeTriggerMethod = class extends ExtensionMethod {
|
|
|
7572
7759
|
return true;
|
|
7573
7760
|
}
|
|
7574
7761
|
// Runs ONCE per event if any instance matched — the only per-event place that may call the provider API.
|
|
7575
|
-
|
|
7576
|
-
|
|
7762
|
+
// It reads `webhookData` (an access token or external id the subscription stored) but cannot change it.
|
|
7763
|
+
extendResult(providerEventData, ctx, webhookData = null) {
|
|
7764
|
+
return this.props.extendResult?.(ctx.bagWith({ providerEventData, webhookData }));
|
|
7577
7765
|
}
|
|
7578
7766
|
hasExtendResult() {
|
|
7579
7767
|
return typeof this.props.extendResult === "function";
|