@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/cli.js
CHANGED
|
@@ -7,7 +7,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw mod = 0, e;
|
|
14
|
+
}
|
|
11
15
|
};
|
|
12
16
|
var __copyProps = (to, from, except, desc) => {
|
|
13
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -351,7 +355,7 @@ var require_error = __commonJS({
|
|
|
351
355
|
};
|
|
352
356
|
return _getPrototypeOf(o);
|
|
353
357
|
}
|
|
354
|
-
var ResponseError = exports2.ResponseError = /* @__PURE__ */ function(_Error) {
|
|
358
|
+
var ResponseError = exports2.ResponseError = /* @__PURE__ */ (function(_Error) {
|
|
355
359
|
_inherits(ResponseError2, _Error);
|
|
356
360
|
var _super = _createSuper(ResponseError2);
|
|
357
361
|
function ResponseError2(response) {
|
|
@@ -367,14 +371,14 @@ var require_error = __commonJS({
|
|
|
367
371
|
return _this;
|
|
368
372
|
}
|
|
369
373
|
return _createClass(ResponseError2);
|
|
370
|
-
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
374
|
+
})(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
371
375
|
function parseError(res) {
|
|
372
376
|
if (res.status === 502) {
|
|
373
377
|
return "No connection with server";
|
|
374
378
|
}
|
|
375
379
|
return res.body || "Status Code ".concat(res.status, " (").concat(res.statusText, ")");
|
|
376
380
|
}
|
|
377
|
-
var TLSError = exports2.TLSError = /* @__PURE__ */ function(_Error2) {
|
|
381
|
+
var TLSError = exports2.TLSError = /* @__PURE__ */ (function(_Error2) {
|
|
378
382
|
_inherits(TLSError2, _Error2);
|
|
379
383
|
var _super2 = _createSuper(TLSError2);
|
|
380
384
|
function TLSError2(reason, cause) {
|
|
@@ -389,7 +393,7 @@ var require_error = __commonJS({
|
|
|
389
393
|
return _this2;
|
|
390
394
|
}
|
|
391
395
|
return _createClass(TLSError2);
|
|
392
|
-
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
396
|
+
})(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
393
397
|
var SECURE_CONTEXT_REASONS = [{
|
|
394
398
|
match: /bad decrypt|bad password read|wrong final block length/i,
|
|
395
399
|
reason: "The private key could not be decrypted, the passphrase is missing or incorrect."
|
|
@@ -620,7 +624,7 @@ var require_event_emitter = __commonJS({
|
|
|
620
624
|
}
|
|
621
625
|
return (hint3 === "string" ? String : Number)(input);
|
|
622
626
|
}
|
|
623
|
-
var EventEmitter = exports2["default"] = /* @__PURE__ */ function() {
|
|
627
|
+
var EventEmitter = exports2["default"] = /* @__PURE__ */ (function() {
|
|
624
628
|
function EventEmitter2() {
|
|
625
629
|
_classCallCheck(this, EventEmitter2);
|
|
626
630
|
this.events = {};
|
|
@@ -662,7 +666,7 @@ var require_event_emitter = __commonJS({
|
|
|
662
666
|
}
|
|
663
667
|
}]);
|
|
664
668
|
return EventEmitter2;
|
|
665
|
-
}();
|
|
669
|
+
})();
|
|
666
670
|
}
|
|
667
671
|
});
|
|
668
672
|
|
|
@@ -880,7 +884,7 @@ var require_request = __commonJS({
|
|
|
880
884
|
var RESPONSE_EVENT = "response";
|
|
881
885
|
var ERROR_EVENT = "error";
|
|
882
886
|
var DONE_EVENT = "done";
|
|
883
|
-
var Request = exports2.Request = /* @__PURE__ */ function(_EventEmitter) {
|
|
887
|
+
var Request = exports2.Request = /* @__PURE__ */ (function(_EventEmitter) {
|
|
884
888
|
_inherits(Request2, _EventEmitter);
|
|
885
889
|
var _super = _createSuper(Request2);
|
|
886
890
|
function Request2(path23, method, body) {
|
|
@@ -1183,7 +1187,7 @@ var require_request = __commonJS({
|
|
|
1183
1187
|
}
|
|
1184
1188
|
}]);
|
|
1185
1189
|
return Request2;
|
|
1186
|
-
}(_eventEmitter["default"]);
|
|
1190
|
+
})(_eventEmitter["default"]);
|
|
1187
1191
|
function pickTLSOptions(tlsOptions) {
|
|
1188
1192
|
var result = {};
|
|
1189
1193
|
TLS_OPTION_KEYS.forEach(function(key) {
|
|
@@ -1347,9 +1351,9 @@ var require_lib = __commonJS({
|
|
|
1347
1351
|
}
|
|
1348
1352
|
});
|
|
1349
1353
|
|
|
1350
|
-
//
|
|
1354
|
+
// node_modules/adm-zip/util/constants.js
|
|
1351
1355
|
var require_constants = __commonJS({
|
|
1352
|
-
"
|
|
1356
|
+
"node_modules/adm-zip/util/constants.js"(exports2, module2) {
|
|
1353
1357
|
module2.exports = {
|
|
1354
1358
|
/* The local file header */
|
|
1355
1359
|
LOCHDR: 30,
|
|
@@ -1566,9 +1570,9 @@ var require_constants = __commonJS({
|
|
|
1566
1570
|
}
|
|
1567
1571
|
});
|
|
1568
1572
|
|
|
1569
|
-
//
|
|
1573
|
+
// node_modules/adm-zip/util/errors.js
|
|
1570
1574
|
var require_errors = __commonJS({
|
|
1571
|
-
"
|
|
1575
|
+
"node_modules/adm-zip/util/errors.js"(exports2) {
|
|
1572
1576
|
var errors = {
|
|
1573
1577
|
/* Header error messages */
|
|
1574
1578
|
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
@@ -1581,6 +1585,7 @@ var require_errors = __commonJS({
|
|
|
1581
1585
|
/* ZipEntry error messages*/
|
|
1582
1586
|
NO_DATA: "Nothing to decompress",
|
|
1583
1587
|
BAD_CRC: "CRC32 checksum failed {0}",
|
|
1588
|
+
MAX_OUTPUT_EXCEEDED: "Decompressed data exceeds the declared uncompressed size",
|
|
1584
1589
|
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
1585
1590
|
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
1586
1591
|
/* Inflater error messages */
|
|
@@ -1600,11 +1605,13 @@ var require_errors = __commonJS({
|
|
|
1600
1605
|
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
1601
1606
|
NO_ZIP: "No zip file was loaded",
|
|
1602
1607
|
NO_ENTRY: "Entry doesn't exist",
|
|
1608
|
+
DUPLICATE_ENTRY: "Duplicate entry name {0}",
|
|
1603
1609
|
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
1604
1610
|
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
1605
1611
|
NOT_IMPLEMENTED: "Not implemented",
|
|
1606
1612
|
INVALID_FILENAME: "Invalid filename",
|
|
1607
1613
|
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
1614
|
+
ZIP64_VALUE_TOO_LARGE: "Zip64 value exceeds the maximum safe integer",
|
|
1608
1615
|
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
1609
1616
|
WRONG_PASSWORD: "Wrong Password",
|
|
1610
1617
|
/* ADM-ZIP */
|
|
@@ -1626,9 +1633,9 @@ var require_errors = __commonJS({
|
|
|
1626
1633
|
}
|
|
1627
1634
|
});
|
|
1628
1635
|
|
|
1629
|
-
//
|
|
1636
|
+
// node_modules/adm-zip/util/utils.js
|
|
1630
1637
|
var require_utils2 = __commonJS({
|
|
1631
|
-
"
|
|
1638
|
+
"node_modules/adm-zip/util/utils.js"(exports2, module2) {
|
|
1632
1639
|
var fsystem = require("fs");
|
|
1633
1640
|
var pth = require("path");
|
|
1634
1641
|
var Constants = require_constants();
|
|
@@ -1666,7 +1673,11 @@ var require_utils2 = __commonJS({
|
|
|
1666
1673
|
try {
|
|
1667
1674
|
stat = self.fs.statSync(resolvedPath);
|
|
1668
1675
|
} catch (e) {
|
|
1669
|
-
|
|
1676
|
+
if (e.message && e.message.startsWith("ENOENT")) {
|
|
1677
|
+
self.fs.mkdirSync(resolvedPath);
|
|
1678
|
+
} else {
|
|
1679
|
+
throw e;
|
|
1680
|
+
}
|
|
1670
1681
|
}
|
|
1671
1682
|
if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
1672
1683
|
});
|
|
@@ -1712,46 +1723,83 @@ var require_utils2 = __commonJS({
|
|
|
1712
1723
|
self.fs.exists(path23, function(exist) {
|
|
1713
1724
|
if (exist && !overwrite) return callback(false);
|
|
1714
1725
|
self.fs.stat(path23, function(err, stat) {
|
|
1715
|
-
if (exist && stat.isDirectory()) {
|
|
1726
|
+
if (exist && stat && stat.isDirectory()) {
|
|
1716
1727
|
return callback(false);
|
|
1717
1728
|
}
|
|
1718
1729
|
var folder = pth.dirname(path23);
|
|
1719
1730
|
self.fs.exists(folder, function(exists) {
|
|
1720
|
-
if (!exists)
|
|
1731
|
+
if (!exists) {
|
|
1732
|
+
try {
|
|
1733
|
+
self.makeDir(folder);
|
|
1734
|
+
} catch (e) {
|
|
1735
|
+
return callback(false);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
const writeToFd = function(fd) {
|
|
1739
|
+
self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
|
|
1740
|
+
self.fs.close(fd, function() {
|
|
1741
|
+
if (writeErr) return callback(false);
|
|
1742
|
+
self.fs.chmod(path23, attr || 438, function() {
|
|
1743
|
+
callback(true);
|
|
1744
|
+
});
|
|
1745
|
+
});
|
|
1746
|
+
});
|
|
1747
|
+
};
|
|
1721
1748
|
self.fs.open(path23, "w", 438, function(err2, fd) {
|
|
1722
1749
|
if (err2) {
|
|
1723
1750
|
self.fs.chmod(path23, 438, function() {
|
|
1724
|
-
self.fs.open(path23, "w", 438, function(
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
self.fs.chmod(path23, attr || 438, function() {
|
|
1728
|
-
callback(true);
|
|
1729
|
-
});
|
|
1730
|
-
});
|
|
1731
|
-
});
|
|
1751
|
+
self.fs.open(path23, "w", 438, function(retryErr, fd2) {
|
|
1752
|
+
if (retryErr || !fd2) return callback(false);
|
|
1753
|
+
writeToFd(fd2);
|
|
1732
1754
|
});
|
|
1733
1755
|
});
|
|
1734
1756
|
} else if (fd) {
|
|
1735
|
-
|
|
1736
|
-
self.fs.close(fd, function() {
|
|
1737
|
-
self.fs.chmod(path23, attr || 438, function() {
|
|
1738
|
-
callback(true);
|
|
1739
|
-
});
|
|
1740
|
-
});
|
|
1741
|
-
});
|
|
1757
|
+
writeToFd(fd);
|
|
1742
1758
|
} else {
|
|
1743
|
-
|
|
1744
|
-
callback(true);
|
|
1745
|
-
});
|
|
1759
|
+
callback(false);
|
|
1746
1760
|
}
|
|
1747
1761
|
});
|
|
1748
1762
|
});
|
|
1749
1763
|
});
|
|
1750
1764
|
});
|
|
1751
1765
|
};
|
|
1766
|
+
Utils.prototype.assertPathSafe = function(root, target) {
|
|
1767
|
+
const self = this;
|
|
1768
|
+
if (typeof self.fs.lstatSync !== "function") return;
|
|
1769
|
+
const resolvedRoot = pth.resolve(root);
|
|
1770
|
+
const resolvedTarget = pth.resolve(target);
|
|
1771
|
+
if (resolvedTarget === resolvedRoot) return;
|
|
1772
|
+
const rel = pth.relative(resolvedRoot, resolvedTarget);
|
|
1773
|
+
if (!rel || rel === ".." || rel.startsWith(".." + pth.sep) || pth.isAbsolute(rel)) return;
|
|
1774
|
+
let cur = resolvedRoot;
|
|
1775
|
+
for (const part of rel.split(pth.sep)) {
|
|
1776
|
+
if (!part || part === ".") continue;
|
|
1777
|
+
cur = pth.join(cur, part);
|
|
1778
|
+
let stat;
|
|
1779
|
+
try {
|
|
1780
|
+
stat = self.fs.lstatSync(cur);
|
|
1781
|
+
} catch (e) {
|
|
1782
|
+
break;
|
|
1783
|
+
}
|
|
1784
|
+
if (stat.isSymbolicLink()) throw Errors.FILE_IN_THE_WAY(`"${cur}"`);
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1752
1787
|
Utils.prototype.findFiles = function(path23) {
|
|
1753
1788
|
const self = this;
|
|
1754
|
-
|
|
1789
|
+
const canLstat = typeof self.fs.lstatSync === "function";
|
|
1790
|
+
const rootReal = self.fs.realpathSync(path23);
|
|
1791
|
+
function escapesRoot(p) {
|
|
1792
|
+
if (!canLstat) return false;
|
|
1793
|
+
if (!self.fs.lstatSync(p).isSymbolicLink()) return false;
|
|
1794
|
+
let real;
|
|
1795
|
+
try {
|
|
1796
|
+
real = self.fs.realpathSync(p);
|
|
1797
|
+
} catch (e) {
|
|
1798
|
+
return true;
|
|
1799
|
+
}
|
|
1800
|
+
return !(real === rootReal || real.startsWith(rootReal + pth.sep));
|
|
1801
|
+
}
|
|
1802
|
+
function findSync(dir, pattern, recursive, visited) {
|
|
1755
1803
|
if (typeof pattern === "boolean") {
|
|
1756
1804
|
recursive = pattern;
|
|
1757
1805
|
pattern = void 0;
|
|
@@ -1759,41 +1807,90 @@ var require_utils2 = __commonJS({
|
|
|
1759
1807
|
let files = [];
|
|
1760
1808
|
self.fs.readdirSync(dir).forEach(function(file) {
|
|
1761
1809
|
const path24 = pth.join(dir, file);
|
|
1810
|
+
if (escapesRoot(path24)) return;
|
|
1762
1811
|
const stat = self.fs.statSync(path24);
|
|
1763
1812
|
if (!pattern || pattern.test(path24)) {
|
|
1764
1813
|
files.push(pth.normalize(path24) + (stat.isDirectory() ? self.sep : ""));
|
|
1765
1814
|
}
|
|
1766
|
-
if (stat.isDirectory() && recursive)
|
|
1815
|
+
if (stat.isDirectory() && recursive) {
|
|
1816
|
+
const realDir = self.fs.realpathSync(path24);
|
|
1817
|
+
if (!visited.has(realDir)) {
|
|
1818
|
+
visited.add(realDir);
|
|
1819
|
+
files = files.concat(findSync(path24, pattern, recursive, visited));
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1767
1822
|
});
|
|
1768
1823
|
return files;
|
|
1769
1824
|
}
|
|
1770
|
-
return findSync(path23, void 0, true);
|
|
1825
|
+
return findSync(path23, void 0, true, /* @__PURE__ */ new Set([rootReal]));
|
|
1771
1826
|
};
|
|
1772
1827
|
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
1773
1828
|
const self = this;
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1829
|
+
const results = [];
|
|
1830
|
+
let finished = false;
|
|
1831
|
+
const finish = function(err) {
|
|
1832
|
+
if (finished) return;
|
|
1833
|
+
finished = true;
|
|
1834
|
+
cb(err, err ? void 0 : results);
|
|
1835
|
+
};
|
|
1836
|
+
const canLstat = typeof self.fs.lstat === "function";
|
|
1837
|
+
let rootReal = null;
|
|
1838
|
+
const escapesRoot = function(file, cb2) {
|
|
1839
|
+
if (!canLstat) return cb2(null, false);
|
|
1840
|
+
self.fs.lstat(file, function(err, lst) {
|
|
1841
|
+
if (err) return cb2(err);
|
|
1842
|
+
if (!lst || !lst.isSymbolicLink()) return cb2(null, false);
|
|
1843
|
+
self.fs.realpath(file, function(err2, real) {
|
|
1844
|
+
if (err2) return cb2(null, true);
|
|
1845
|
+
cb2(null, !(real === rootReal || real.startsWith(rootReal + pth.sep)));
|
|
1846
|
+
});
|
|
1847
|
+
});
|
|
1848
|
+
};
|
|
1849
|
+
const walk = function(dir2, visited, done) {
|
|
1850
|
+
self.fs.readdir(dir2, function(err, list) {
|
|
1851
|
+
if (err) return done(err);
|
|
1852
|
+
let pending = list.length;
|
|
1853
|
+
if (!pending) return done();
|
|
1854
|
+
list.forEach(function(name) {
|
|
1855
|
+
const file = pth.join(dir2, name);
|
|
1856
|
+
escapesRoot(file, function(err2, escapes) {
|
|
1857
|
+
if (err2) return done(err2);
|
|
1858
|
+
if (escapes) {
|
|
1859
|
+
if (!--pending) done();
|
|
1860
|
+
return;
|
|
1793
1861
|
}
|
|
1794
|
-
|
|
1862
|
+
self.fs.stat(file, function(err3, stat) {
|
|
1863
|
+
if (err3) return done(err3);
|
|
1864
|
+
if (!stat) {
|
|
1865
|
+
if (!--pending) done();
|
|
1866
|
+
return;
|
|
1867
|
+
}
|
|
1868
|
+
results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
|
|
1869
|
+
if (!stat.isDirectory()) {
|
|
1870
|
+
if (!--pending) done();
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1873
|
+
self.fs.realpath(file, function(err4, realDir) {
|
|
1874
|
+
if (err4) return done(err4);
|
|
1875
|
+
if (visited.has(realDir)) {
|
|
1876
|
+
if (!--pending) done();
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
visited.add(realDir);
|
|
1880
|
+
walk(file, visited, function(err5) {
|
|
1881
|
+
if (err5) return done(err5);
|
|
1882
|
+
if (!--pending) done();
|
|
1883
|
+
});
|
|
1884
|
+
});
|
|
1885
|
+
});
|
|
1886
|
+
});
|
|
1795
1887
|
});
|
|
1796
1888
|
});
|
|
1889
|
+
};
|
|
1890
|
+
self.fs.realpath(dir, function(err, realDir) {
|
|
1891
|
+
if (err) return finish(err);
|
|
1892
|
+
rootReal = realDir;
|
|
1893
|
+
walk(dir, /* @__PURE__ */ new Set([realDir]), finish);
|
|
1797
1894
|
});
|
|
1798
1895
|
};
|
|
1799
1896
|
Utils.prototype.getAttributes = function() {
|
|
@@ -1847,7 +1944,7 @@ var require_utils2 = __commonJS({
|
|
|
1847
1944
|
var parts = name.split("/");
|
|
1848
1945
|
for (var i = 0, l = parts.length; i < l; i++) {
|
|
1849
1946
|
var path23 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
1850
|
-
if (path23.
|
|
1947
|
+
if (path23 === prefix || path23.startsWith(prefix + pth.sep)) {
|
|
1851
1948
|
return path23;
|
|
1852
1949
|
}
|
|
1853
1950
|
}
|
|
@@ -1863,9 +1960,19 @@ var require_utils2 = __commonJS({
|
|
|
1863
1960
|
}
|
|
1864
1961
|
};
|
|
1865
1962
|
Utils.readBigUInt64LE = function(buffer, index) {
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1963
|
+
const lo = buffer.readUInt32LE(index);
|
|
1964
|
+
const hi = buffer.readUInt32LE(index + 4);
|
|
1965
|
+
const value = hi * 4294967296 + lo;
|
|
1966
|
+
if (value > Number.MAX_SAFE_INTEGER) {
|
|
1967
|
+
throw Errors.ZIP64_VALUE_TOO_LARGE();
|
|
1968
|
+
}
|
|
1969
|
+
return value;
|
|
1970
|
+
};
|
|
1971
|
+
Utils.writeBigUInt64LE = function(buffer, value, index) {
|
|
1972
|
+
const lo = value >>> 0;
|
|
1973
|
+
const hi = Math.floor(value / 4294967296) >>> 0;
|
|
1974
|
+
buffer.writeUInt32LE(lo, index);
|
|
1975
|
+
buffer.writeUInt32LE(hi, index + 4);
|
|
1869
1976
|
};
|
|
1870
1977
|
Utils.fromDOS2Date = function(val) {
|
|
1871
1978
|
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);
|
|
@@ -1884,9 +1991,9 @@ var require_utils2 = __commonJS({
|
|
|
1884
1991
|
}
|
|
1885
1992
|
});
|
|
1886
1993
|
|
|
1887
|
-
//
|
|
1994
|
+
// node_modules/adm-zip/util/fattr.js
|
|
1888
1995
|
var require_fattr = __commonJS({
|
|
1889
|
-
"
|
|
1996
|
+
"node_modules/adm-zip/util/fattr.js"(exports2, module2) {
|
|
1890
1997
|
var pth = require("path");
|
|
1891
1998
|
module2.exports = function(path23, { fs: fs20 }) {
|
|
1892
1999
|
var _path = path23 || "", _obj = newAttr(), _stat = null;
|
|
@@ -1953,9 +2060,9 @@ var require_fattr = __commonJS({
|
|
|
1953
2060
|
}
|
|
1954
2061
|
});
|
|
1955
2062
|
|
|
1956
|
-
//
|
|
2063
|
+
// node_modules/adm-zip/util/decoder.js
|
|
1957
2064
|
var require_decoder = __commonJS({
|
|
1958
|
-
"
|
|
2065
|
+
"node_modules/adm-zip/util/decoder.js"(exports2, module2) {
|
|
1959
2066
|
module2.exports = {
|
|
1960
2067
|
efs: true,
|
|
1961
2068
|
encode: (data) => Buffer.from(data, "utf8"),
|
|
@@ -1964,9 +2071,9 @@ var require_decoder = __commonJS({
|
|
|
1964
2071
|
}
|
|
1965
2072
|
});
|
|
1966
2073
|
|
|
1967
|
-
//
|
|
2074
|
+
// node_modules/adm-zip/util/index.js
|
|
1968
2075
|
var require_util = __commonJS({
|
|
1969
|
-
"
|
|
2076
|
+
"node_modules/adm-zip/util/index.js"(exports2, module2) {
|
|
1970
2077
|
module2.exports = require_utils2();
|
|
1971
2078
|
module2.exports.Constants = require_constants();
|
|
1972
2079
|
module2.exports.Errors = require_errors();
|
|
@@ -1975,9 +2082,9 @@ var require_util = __commonJS({
|
|
|
1975
2082
|
}
|
|
1976
2083
|
});
|
|
1977
2084
|
|
|
1978
|
-
//
|
|
2085
|
+
// node_modules/adm-zip/headers/entryHeader.js
|
|
1979
2086
|
var require_entryHeader = __commonJS({
|
|
1980
|
-
"
|
|
2087
|
+
"node_modules/adm-zip/headers/entryHeader.js"(exports2, module2) {
|
|
1981
2088
|
var Utils = require_util();
|
|
1982
2089
|
var Constants = Utils.Constants;
|
|
1983
2090
|
module2.exports = function() {
|
|
@@ -2037,6 +2144,7 @@ var require_entryHeader = __commonJS({
|
|
|
2037
2144
|
switch (val) {
|
|
2038
2145
|
case Constants.STORED:
|
|
2039
2146
|
this.version = 10;
|
|
2147
|
+
break;
|
|
2040
2148
|
case Constants.DEFLATED:
|
|
2041
2149
|
default:
|
|
2042
2150
|
this.version = 20;
|
|
@@ -2047,6 +2155,7 @@ var require_entryHeader = __commonJS({
|
|
|
2047
2155
|
return Utils.fromDOS2Date(this.timeval);
|
|
2048
2156
|
},
|
|
2049
2157
|
set time(val) {
|
|
2158
|
+
val = new Date(val);
|
|
2050
2159
|
this.timeval = Utils.fromDate2DOS(val);
|
|
2051
2160
|
},
|
|
2052
2161
|
get timeval() {
|
|
@@ -2120,7 +2229,7 @@ var require_entryHeader = __commonJS({
|
|
|
2120
2229
|
},
|
|
2121
2230
|
// get Unix file permissions
|
|
2122
2231
|
get fileAttr() {
|
|
2123
|
-
return (_attr || 0) >> 16 &
|
|
2232
|
+
return (_attr || 0) >> 16 & 511;
|
|
2124
2233
|
},
|
|
2125
2234
|
get offset() {
|
|
2126
2235
|
return _offset;
|
|
@@ -2141,12 +2250,16 @@ var require_entryHeader = __commonJS({
|
|
|
2141
2250
|
return _localHeader;
|
|
2142
2251
|
},
|
|
2143
2252
|
loadLocalHeaderFromBinary: function(input) {
|
|
2253
|
+
if (_offset < 0 || _offset + Constants.LOCHDR > input.length) {
|
|
2254
|
+
throw Utils.Errors.INVALID_LOC();
|
|
2255
|
+
}
|
|
2144
2256
|
var data = input.slice(_offset, _offset + Constants.LOCHDR);
|
|
2145
2257
|
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
|
|
2146
2258
|
throw Utils.Errors.INVALID_LOC();
|
|
2147
2259
|
}
|
|
2148
2260
|
_localHeader.version = data.readUInt16LE(Constants.LOCVER);
|
|
2149
2261
|
_localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
|
|
2262
|
+
_localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
|
|
2150
2263
|
_localHeader.method = data.readUInt16LE(Constants.LOCHOW);
|
|
2151
2264
|
_localHeader.time = data.readUInt32LE(Constants.LOCTIM);
|
|
2152
2265
|
_localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
|
|
@@ -2182,7 +2295,7 @@ var require_entryHeader = __commonJS({
|
|
|
2182
2295
|
var data = Buffer.alloc(Constants.LOCHDR);
|
|
2183
2296
|
data.writeUInt32LE(Constants.LOCSIG, 0);
|
|
2184
2297
|
data.writeUInt16LE(_version, Constants.LOCVER);
|
|
2185
|
-
data.writeUInt16LE(_flags, Constants.LOCFLG);
|
|
2298
|
+
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
|
|
2186
2299
|
data.writeUInt16LE(_method, Constants.LOCHOW);
|
|
2187
2300
|
data.writeUInt32LE(_time, Constants.LOCTIM);
|
|
2188
2301
|
data.writeUInt32LE(_crc, Constants.LOCCRC);
|
|
@@ -2197,7 +2310,7 @@ var require_entryHeader = __commonJS({
|
|
|
2197
2310
|
data.writeUInt32LE(Constants.CENSIG, 0);
|
|
2198
2311
|
data.writeUInt16LE(_verMade, Constants.CENVEM);
|
|
2199
2312
|
data.writeUInt16LE(_version, Constants.CENVER);
|
|
2200
|
-
data.writeUInt16LE(_flags, Constants.CENFLG);
|
|
2313
|
+
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
|
|
2201
2314
|
data.writeUInt16LE(_method, Constants.CENHOW);
|
|
2202
2315
|
data.writeUInt32LE(_time, Constants.CENTIM);
|
|
2203
2316
|
data.writeUInt32LE(_crc, Constants.CENCRC);
|
|
@@ -2243,13 +2356,14 @@ var require_entryHeader = __commonJS({
|
|
|
2243
2356
|
}
|
|
2244
2357
|
});
|
|
2245
2358
|
|
|
2246
|
-
//
|
|
2359
|
+
// node_modules/adm-zip/headers/mainHeader.js
|
|
2247
2360
|
var require_mainHeader = __commonJS({
|
|
2248
|
-
"
|
|
2361
|
+
"node_modules/adm-zip/headers/mainHeader.js"(exports2, module2) {
|
|
2249
2362
|
var Utils = require_util();
|
|
2250
2363
|
var Constants = Utils.Constants;
|
|
2251
2364
|
module2.exports = function() {
|
|
2252
2365
|
var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
|
|
2366
|
+
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;
|
|
2253
2367
|
return {
|
|
2254
2368
|
get diskEntries() {
|
|
2255
2369
|
return _volumeEntries;
|
|
@@ -2282,7 +2396,7 @@ var require_mainHeader = __commonJS({
|
|
|
2282
2396
|
_commentLength = val;
|
|
2283
2397
|
},
|
|
2284
2398
|
get mainHeaderSize() {
|
|
2285
|
-
return Constants.ENDHDR + _commentLength;
|
|
2399
|
+
return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
|
|
2286
2400
|
},
|
|
2287
2401
|
loadFromBinary: function(data) {
|
|
2288
2402
|
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
|
|
@@ -2297,21 +2411,51 @@ var require_mainHeader = __commonJS({
|
|
|
2297
2411
|
} else {
|
|
2298
2412
|
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
|
|
2299
2413
|
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
|
|
2300
|
-
_size = Utils.readBigUInt64LE(data, Constants.
|
|
2414
|
+
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
|
|
2301
2415
|
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
|
|
2302
2416
|
_commentLength = 0;
|
|
2303
2417
|
}
|
|
2304
2418
|
},
|
|
2305
2419
|
toBinary: function() {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2420
|
+
if (!needsZip64()) {
|
|
2421
|
+
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
|
|
2422
|
+
b.writeUInt32LE(Constants.ENDSIG, 0);
|
|
2423
|
+
b.writeUInt32LE(0, 4);
|
|
2424
|
+
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
|
|
2425
|
+
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
|
|
2426
|
+
b.writeUInt32LE(_size, Constants.ENDSIZ);
|
|
2427
|
+
b.writeUInt32LE(_offset, Constants.ENDOFF);
|
|
2428
|
+
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
|
|
2429
|
+
b.fill(" ", Constants.ENDHDR);
|
|
2430
|
+
return b;
|
|
2431
|
+
}
|
|
2432
|
+
var b = Buffer.alloc(this.mainHeaderSize);
|
|
2433
|
+
let offset = 0;
|
|
2434
|
+
b.writeUInt32LE(Constants.ZIP64SIG, offset);
|
|
2435
|
+
Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
|
|
2436
|
+
b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
|
|
2437
|
+
b.writeUInt16LE(45, offset + Constants.ZIP64VER);
|
|
2438
|
+
b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
|
|
2439
|
+
b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
|
|
2440
|
+
Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
|
|
2441
|
+
Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
|
|
2442
|
+
Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
|
|
2443
|
+
Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
|
|
2444
|
+
const zip64EndOffset = _offset + _size;
|
|
2445
|
+
offset += Constants.ZIP64HDR;
|
|
2446
|
+
b.writeUInt32LE(Constants.END64SIG, offset);
|
|
2447
|
+
b.writeUInt32LE(0, offset + Constants.END64START);
|
|
2448
|
+
Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
|
|
2449
|
+
b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
|
|
2450
|
+
offset += Constants.END64HDR;
|
|
2451
|
+
b.writeUInt32LE(Constants.ENDSIG, offset);
|
|
2452
|
+
b.writeUInt32LE(0, offset + 4);
|
|
2453
|
+
b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
|
|
2454
|
+
b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
|
|
2455
|
+
b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
|
|
2456
|
+
b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
|
|
2457
|
+
b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
|
|
2458
|
+
b.fill(" ", offset + Constants.ENDHDR);
|
|
2315
2459
|
return b;
|
|
2316
2460
|
},
|
|
2317
2461
|
toJSON: function() {
|
|
@@ -2336,17 +2480,17 @@ var require_mainHeader = __commonJS({
|
|
|
2336
2480
|
}
|
|
2337
2481
|
});
|
|
2338
2482
|
|
|
2339
|
-
//
|
|
2483
|
+
// node_modules/adm-zip/headers/index.js
|
|
2340
2484
|
var require_headers = __commonJS({
|
|
2341
|
-
"
|
|
2485
|
+
"node_modules/adm-zip/headers/index.js"(exports2) {
|
|
2342
2486
|
exports2.EntryHeader = require_entryHeader();
|
|
2343
2487
|
exports2.MainHeader = require_mainHeader();
|
|
2344
2488
|
}
|
|
2345
2489
|
});
|
|
2346
2490
|
|
|
2347
|
-
//
|
|
2491
|
+
// node_modules/adm-zip/methods/deflater.js
|
|
2348
2492
|
var require_deflater = __commonJS({
|
|
2349
|
-
"
|
|
2493
|
+
"node_modules/adm-zip/methods/deflater.js"(exports2, module2) {
|
|
2350
2494
|
module2.exports = function(inbuf) {
|
|
2351
2495
|
var zlib = require("zlib");
|
|
2352
2496
|
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
@@ -2377,24 +2521,41 @@ var require_deflater = __commonJS({
|
|
|
2377
2521
|
}
|
|
2378
2522
|
});
|
|
2379
2523
|
|
|
2380
|
-
//
|
|
2524
|
+
// node_modules/adm-zip/methods/inflater.js
|
|
2381
2525
|
var require_inflater = __commonJS({
|
|
2382
|
-
"
|
|
2383
|
-
var version2 = +(process
|
|
2526
|
+
"node_modules/adm-zip/methods/inflater.js"(exports2, module2) {
|
|
2527
|
+
var version2 = +(process?.versions?.node ?? "").split(".")[0] || 0;
|
|
2528
|
+
var Errors = require_errors();
|
|
2384
2529
|
module2.exports = function(inbuf, expectedLength) {
|
|
2385
2530
|
var zlib = require("zlib");
|
|
2386
|
-
const
|
|
2531
|
+
const maxOutputLength = expectedLength > 0 ? expectedLength : 1;
|
|
2532
|
+
const option = version2 >= 15 ? { maxOutputLength } : {};
|
|
2387
2533
|
return {
|
|
2388
2534
|
inflate: function() {
|
|
2389
2535
|
return zlib.inflateRawSync(inbuf, option);
|
|
2390
2536
|
},
|
|
2391
2537
|
inflateAsync: function(callback) {
|
|
2392
|
-
var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
|
|
2538
|
+
var tmp = zlib.createInflateRaw(option), parts = [], total = 0, done = false;
|
|
2539
|
+
const fail3 = function(err) {
|
|
2540
|
+
if (done) return;
|
|
2541
|
+
done = true;
|
|
2542
|
+
tmp.destroy();
|
|
2543
|
+
callback && callback(Buffer.alloc(0), err);
|
|
2544
|
+
};
|
|
2545
|
+
tmp.on("error", function(err) {
|
|
2546
|
+
fail3(err);
|
|
2547
|
+
});
|
|
2393
2548
|
tmp.on("data", function(data) {
|
|
2394
|
-
|
|
2549
|
+
if (done) return;
|
|
2395
2550
|
total += data.length;
|
|
2551
|
+
if (total > maxOutputLength) {
|
|
2552
|
+
return fail3(Errors.MAX_OUTPUT_EXCEEDED());
|
|
2553
|
+
}
|
|
2554
|
+
parts.push(data);
|
|
2396
2555
|
});
|
|
2397
2556
|
tmp.on("end", function() {
|
|
2557
|
+
if (done) return;
|
|
2558
|
+
done = true;
|
|
2398
2559
|
var buf = Buffer.alloc(total), written = 0;
|
|
2399
2560
|
buf.fill(0);
|
|
2400
2561
|
for (var i = 0; i < parts.length; i++) {
|
|
@@ -2411,9 +2572,9 @@ var require_inflater = __commonJS({
|
|
|
2411
2572
|
}
|
|
2412
2573
|
});
|
|
2413
2574
|
|
|
2414
|
-
//
|
|
2575
|
+
// node_modules/adm-zip/methods/zipcrypto.js
|
|
2415
2576
|
var require_zipcrypto = __commonJS({
|
|
2416
|
-
"
|
|
2577
|
+
"node_modules/adm-zip/methods/zipcrypto.js"(exports2, module2) {
|
|
2417
2578
|
"use strict";
|
|
2418
2579
|
var { randomFillSync } = require("crypto");
|
|
2419
2580
|
var Errors = require_errors();
|
|
@@ -2527,18 +2688,18 @@ var require_zipcrypto = __commonJS({
|
|
|
2527
2688
|
}
|
|
2528
2689
|
});
|
|
2529
2690
|
|
|
2530
|
-
//
|
|
2691
|
+
// node_modules/adm-zip/methods/index.js
|
|
2531
2692
|
var require_methods = __commonJS({
|
|
2532
|
-
"
|
|
2693
|
+
"node_modules/adm-zip/methods/index.js"(exports2) {
|
|
2533
2694
|
exports2.Deflater = require_deflater();
|
|
2534
2695
|
exports2.Inflater = require_inflater();
|
|
2535
2696
|
exports2.ZipCrypto = require_zipcrypto();
|
|
2536
2697
|
}
|
|
2537
2698
|
});
|
|
2538
2699
|
|
|
2539
|
-
//
|
|
2700
|
+
// node_modules/adm-zip/zipEntry.js
|
|
2540
2701
|
var require_zipEntry = __commonJS({
|
|
2541
|
-
"
|
|
2702
|
+
"node_modules/adm-zip/zipEntry.js"(exports2, module2) {
|
|
2542
2703
|
var Utils = require_util();
|
|
2543
2704
|
var Headers = require_headers();
|
|
2544
2705
|
var Constants = Utils.Constants;
|
|
@@ -2553,38 +2714,16 @@ var require_zipEntry = __commonJS({
|
|
|
2553
2714
|
return Buffer.alloc(0);
|
|
2554
2715
|
}
|
|
2555
2716
|
_extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
|
|
2556
|
-
|
|
2717
|
+
const dataOffset = _centralHeader.realDataOffset;
|
|
2718
|
+
const dataEnd = dataOffset + _centralHeader.compressedSize;
|
|
2719
|
+
if (dataOffset < 0 || dataEnd < dataOffset || dataEnd > input.length) {
|
|
2720
|
+
throw Utils.Errors.INVALID_LOC();
|
|
2721
|
+
}
|
|
2722
|
+
return input.slice(dataOffset, dataEnd);
|
|
2557
2723
|
}
|
|
2558
2724
|
function crc32OK(data) {
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
return false;
|
|
2562
|
-
}
|
|
2563
|
-
} else {
|
|
2564
|
-
const descriptor = {};
|
|
2565
|
-
const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
|
|
2566
|
-
if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
|
|
2567
|
-
throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
|
|
2568
|
-
}
|
|
2569
|
-
if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
|
|
2570
|
-
descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
|
|
2571
|
-
descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
|
|
2572
|
-
descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
|
|
2573
|
-
} else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
|
|
2574
|
-
descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
|
|
2575
|
-
descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
|
|
2576
|
-
descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
|
|
2577
|
-
} else {
|
|
2578
|
-
throw Utils.Errors.DESCRIPTOR_UNKNOWN();
|
|
2579
|
-
}
|
|
2580
|
-
if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
|
|
2581
|
-
throw Utils.Errors.DESCRIPTOR_FAULTY();
|
|
2582
|
-
}
|
|
2583
|
-
if (Utils.crc32(data) !== descriptor.crc) {
|
|
2584
|
-
return false;
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
|
-
return true;
|
|
2725
|
+
const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
|
|
2726
|
+
return Utils.crc32(data) === expectedCrc;
|
|
2588
2727
|
}
|
|
2589
2728
|
function decompress(async, callback, pass) {
|
|
2590
2729
|
if (typeof callback === "undefined" && typeof async === "string") {
|
|
@@ -2597,20 +2736,30 @@ var require_zipEntry = __commonJS({
|
|
|
2597
2736
|
}
|
|
2598
2737
|
return Buffer.alloc(0);
|
|
2599
2738
|
}
|
|
2600
|
-
var compressedData
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
|
|
2607
|
-
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
2739
|
+
var compressedData;
|
|
2740
|
+
try {
|
|
2741
|
+
compressedData = getCompressedDataFromZip();
|
|
2742
|
+
if (compressedData.length === 0) {
|
|
2743
|
+
if (async && callback) callback(compressedData);
|
|
2744
|
+
return compressedData;
|
|
2608
2745
|
}
|
|
2609
|
-
|
|
2746
|
+
if (_centralHeader.encrypted) {
|
|
2747
|
+
if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
|
|
2748
|
+
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
2749
|
+
}
|
|
2750
|
+
compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
|
|
2751
|
+
}
|
|
2752
|
+
} catch (err) {
|
|
2753
|
+
if (async && callback) {
|
|
2754
|
+
callback(Buffer.alloc(0), err);
|
|
2755
|
+
return Buffer.alloc(0);
|
|
2756
|
+
}
|
|
2757
|
+
throw err;
|
|
2610
2758
|
}
|
|
2611
|
-
var data
|
|
2759
|
+
var data;
|
|
2612
2760
|
switch (_centralHeader.method) {
|
|
2613
2761
|
case Utils.Constants.STORED:
|
|
2762
|
+
data = Buffer.alloc(compressedData.length);
|
|
2614
2763
|
compressedData.copy(data);
|
|
2615
2764
|
if (!crc32OK(data)) {
|
|
2616
2765
|
if (async && callback) callback(data, Utils.Errors.BAD_CRC());
|
|
@@ -2622,21 +2771,20 @@ var require_zipEntry = __commonJS({
|
|
|
2622
2771
|
case Utils.Constants.DEFLATED:
|
|
2623
2772
|
var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
|
|
2624
2773
|
if (!async) {
|
|
2625
|
-
|
|
2626
|
-
result.copy(data, 0);
|
|
2774
|
+
data = inflater.inflate();
|
|
2627
2775
|
if (!crc32OK(data)) {
|
|
2628
2776
|
throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
|
|
2629
2777
|
}
|
|
2630
2778
|
return data;
|
|
2631
2779
|
} else {
|
|
2632
|
-
inflater.inflateAsync(function(result) {
|
|
2633
|
-
|
|
2634
|
-
if (
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2780
|
+
inflater.inflateAsync(function(result, err) {
|
|
2781
|
+
if (!callback) return;
|
|
2782
|
+
if (err) {
|
|
2783
|
+
callback(Buffer.alloc(0), err);
|
|
2784
|
+
} else if (!crc32OK(result)) {
|
|
2785
|
+
callback(result, Utils.Errors.BAD_CRC());
|
|
2786
|
+
} else {
|
|
2787
|
+
callback(result);
|
|
2640
2788
|
}
|
|
2641
2789
|
});
|
|
2642
2790
|
}
|
|
@@ -2685,7 +2833,7 @@ var require_zipEntry = __commonJS({
|
|
|
2685
2833
|
}
|
|
2686
2834
|
}
|
|
2687
2835
|
function readUInt64LE(buffer, offset) {
|
|
2688
|
-
return (buffer
|
|
2836
|
+
return Utils.readBigUInt64LE(buffer, offset);
|
|
2689
2837
|
}
|
|
2690
2838
|
function parseExtra(data) {
|
|
2691
2839
|
try {
|
|
@@ -2770,8 +2918,8 @@ var require_zipEntry = __commonJS({
|
|
|
2770
2918
|
if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
|
|
2771
2919
|
},
|
|
2772
2920
|
get name() {
|
|
2773
|
-
|
|
2774
|
-
return _isDirectory ? n.
|
|
2921
|
+
const n = decoder.decode(_entryName);
|
|
2922
|
+
return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
|
|
2775
2923
|
},
|
|
2776
2924
|
get isDirectory() {
|
|
2777
2925
|
return _isDirectory;
|
|
@@ -2867,14 +3015,14 @@ var require_zipEntry = __commonJS({
|
|
|
2867
3015
|
}
|
|
2868
3016
|
});
|
|
2869
3017
|
|
|
2870
|
-
//
|
|
3018
|
+
// node_modules/adm-zip/zipFile.js
|
|
2871
3019
|
var require_zipFile = __commonJS({
|
|
2872
|
-
"
|
|
3020
|
+
"node_modules/adm-zip/zipFile.js"(exports2, module2) {
|
|
2873
3021
|
var ZipEntry = require_zipEntry();
|
|
2874
3022
|
var Headers = require_headers();
|
|
2875
3023
|
var Utils = require_util();
|
|
2876
3024
|
module2.exports = function(inBuffer, options) {
|
|
2877
|
-
var entryList = [], entryTable =
|
|
3025
|
+
var entryList = [], entryTable = /* @__PURE__ */ Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
|
|
2878
3026
|
var password = null;
|
|
2879
3027
|
const temporary = /* @__PURE__ */ new Set();
|
|
2880
3028
|
const opts = options;
|
|
@@ -2909,7 +3057,7 @@ var require_zipFile = __commonJS({
|
|
|
2909
3057
|
}
|
|
2910
3058
|
function readEntries() {
|
|
2911
3059
|
loadedEntries = true;
|
|
2912
|
-
entryTable =
|
|
3060
|
+
entryTable = /* @__PURE__ */ Object.create(null);
|
|
2913
3061
|
if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
|
|
2914
3062
|
throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
|
|
2915
3063
|
}
|
|
@@ -2924,6 +3072,9 @@ var require_zipFile = __commonJS({
|
|
|
2924
3072
|
}
|
|
2925
3073
|
if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
|
|
2926
3074
|
index += entry.header.centralHeaderSize;
|
|
3075
|
+
if (entry.entryName in entryTable) {
|
|
3076
|
+
throw Utils.Errors.DUPLICATE_ENTRY(`"${entry.entryName}"`);
|
|
3077
|
+
}
|
|
2927
3078
|
entryList[i] = entry;
|
|
2928
3079
|
entryTable[entry.entryName] = entry;
|
|
2929
3080
|
}
|
|
@@ -2962,7 +3113,7 @@ var require_zipFile = __commonJS({
|
|
|
2962
3113
|
}
|
|
2963
3114
|
function sortEntries() {
|
|
2964
3115
|
if (entryList.length > 1 && !noSort) {
|
|
2965
|
-
entryList.sort((a, b) => a.
|
|
3116
|
+
entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
|
|
2966
3117
|
}
|
|
2967
3118
|
}
|
|
2968
3119
|
return {
|
|
@@ -3139,7 +3290,7 @@ var require_zipFile = __commonJS({
|
|
|
3139
3290
|
}
|
|
3140
3291
|
const mh = mainHeader.toBinary();
|
|
3141
3292
|
if (_comment) {
|
|
3142
|
-
_comment.copy(mh,
|
|
3293
|
+
_comment.copy(mh, mh.length - _comment.length);
|
|
3143
3294
|
}
|
|
3144
3295
|
mh.copy(outBuffer, dindex);
|
|
3145
3296
|
inBuffer = outBuffer;
|
|
@@ -3195,7 +3346,7 @@ var require_zipFile = __commonJS({
|
|
|
3195
3346
|
});
|
|
3196
3347
|
const mh = mainHeader.toBinary();
|
|
3197
3348
|
if (_comment) {
|
|
3198
|
-
_comment.copy(mh,
|
|
3349
|
+
_comment.copy(mh, mh.length - _comment.length);
|
|
3199
3350
|
}
|
|
3200
3351
|
mh.copy(outBuffer, dindex);
|
|
3201
3352
|
inBuffer = outBuffer;
|
|
@@ -3213,9 +3364,9 @@ var require_zipFile = __commonJS({
|
|
|
3213
3364
|
}
|
|
3214
3365
|
});
|
|
3215
3366
|
|
|
3216
|
-
//
|
|
3367
|
+
// node_modules/adm-zip/adm-zip.js
|
|
3217
3368
|
var require_adm_zip = __commonJS({
|
|
3218
|
-
"
|
|
3369
|
+
"node_modules/adm-zip/adm-zip.js"(exports2, module2) {
|
|
3219
3370
|
var Utils = require_util();
|
|
3220
3371
|
var pth = require("path");
|
|
3221
3372
|
var ZipEntry = require_zipEntry();
|
|
@@ -3250,6 +3401,9 @@ var require_adm_zip = __commonJS({
|
|
|
3250
3401
|
}
|
|
3251
3402
|
Object.assign(opts, options);
|
|
3252
3403
|
const filetools = new Utils(opts);
|
|
3404
|
+
const applyDirAttributes = (dirEntries) => {
|
|
3405
|
+
dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
|
|
3406
|
+
};
|
|
3253
3407
|
if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
|
|
3254
3408
|
opts.decoder = Utils.decoder;
|
|
3255
3409
|
}
|
|
@@ -3277,15 +3431,15 @@ var require_adm_zip = __commonJS({
|
|
|
3277
3431
|
}
|
|
3278
3432
|
function fixPath(zipPath) {
|
|
3279
3433
|
const { join, normalize, sep } = pth.posix;
|
|
3280
|
-
return join(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
3434
|
+
return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
3281
3435
|
}
|
|
3282
3436
|
function filenameFilter(filterfn) {
|
|
3283
3437
|
if (filterfn instanceof RegExp) {
|
|
3284
|
-
return /* @__PURE__ */ function(rx) {
|
|
3438
|
+
return /* @__PURE__ */ (function(rx) {
|
|
3285
3439
|
return function(filename) {
|
|
3286
3440
|
return rx.test(filename);
|
|
3287
3441
|
};
|
|
3288
|
-
}(filterfn);
|
|
3442
|
+
})(filterfn);
|
|
3289
3443
|
} else if ("function" !== typeof filterfn) {
|
|
3290
3444
|
return () => true;
|
|
3291
3445
|
}
|
|
@@ -3380,6 +3534,7 @@ var require_adm_zip = __commonJS({
|
|
|
3380
3534
|
* Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
|
|
3381
3535
|
*
|
|
3382
3536
|
* @param {ZipEntry|string} entry
|
|
3537
|
+
* @param {boolean} withsubfolders
|
|
3383
3538
|
* @returns {void}
|
|
3384
3539
|
*/
|
|
3385
3540
|
deleteFile: function(entry, withsubfolders = true) {
|
|
@@ -3462,17 +3617,17 @@ var require_adm_zip = __commonJS({
|
|
|
3462
3617
|
* @param {string} [zipName] Optional name for the file
|
|
3463
3618
|
* @param {string} [comment] Optional file comment
|
|
3464
3619
|
*/
|
|
3465
|
-
addLocalFile: function(
|
|
3466
|
-
if (filetools.fs.existsSync(
|
|
3620
|
+
addLocalFile: function(localPath, zipPath, zipName, comment) {
|
|
3621
|
+
if (filetools.fs.existsSync(localPath)) {
|
|
3467
3622
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3468
|
-
const p = pth.win32.basename(pth.win32.normalize(
|
|
3623
|
+
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
3469
3624
|
zipPath += zipName ? zipName : p;
|
|
3470
|
-
const _attr = filetools.fs.statSync(
|
|
3471
|
-
const data = _attr.isFile() ? filetools.fs.readFileSync(
|
|
3625
|
+
const _attr = filetools.fs.statSync(localPath);
|
|
3626
|
+
const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
|
|
3472
3627
|
if (_attr.isDirectory()) zipPath += filetools.sep;
|
|
3473
3628
|
this.addFile(zipPath, data, comment, _attr);
|
|
3474
3629
|
} else {
|
|
3475
|
-
throw Utils.Errors.FILE_NOT_FOUND(
|
|
3630
|
+
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
3476
3631
|
}
|
|
3477
3632
|
},
|
|
3478
3633
|
/**
|
|
@@ -3494,17 +3649,17 @@ var require_adm_zip = __commonJS({
|
|
|
3494
3649
|
*/
|
|
3495
3650
|
addLocalFileAsync: function(options2, callback) {
|
|
3496
3651
|
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
3497
|
-
const
|
|
3652
|
+
const localPath = pth.resolve(options2.localPath);
|
|
3498
3653
|
const { comment } = options2;
|
|
3499
3654
|
let { zipPath, zipName } = options2;
|
|
3500
3655
|
const self = this;
|
|
3501
|
-
filetools.fs.stat(
|
|
3656
|
+
filetools.fs.stat(localPath, function(err, stats) {
|
|
3502
3657
|
if (err) return callback(err, false);
|
|
3503
3658
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3504
|
-
const p = pth.win32.basename(pth.win32.normalize(
|
|
3659
|
+
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
3505
3660
|
zipPath += zipName ? zipName : p;
|
|
3506
3661
|
if (stats.isFile()) {
|
|
3507
|
-
filetools.fs.readFile(
|
|
3662
|
+
filetools.fs.readFile(localPath, function(err2, data) {
|
|
3508
3663
|
if (err2) return callback(err2, false);
|
|
3509
3664
|
self.addFile(zipPath, data, comment, stats);
|
|
3510
3665
|
return setImmediate(callback, void 0, true);
|
|
@@ -3523,23 +3678,23 @@ var require_adm_zip = __commonJS({
|
|
|
3523
3678
|
* @param {string} [zipPath] - optional path inside zip
|
|
3524
3679
|
* @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
|
|
3525
3680
|
*/
|
|
3526
|
-
addLocalFolder: function(
|
|
3681
|
+
addLocalFolder: function(localPath, zipPath, filter) {
|
|
3527
3682
|
filter = filenameFilter(filter);
|
|
3528
3683
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3529
|
-
|
|
3530
|
-
if (filetools.fs.existsSync(
|
|
3531
|
-
const items = filetools.findFiles(
|
|
3684
|
+
localPath = pth.normalize(localPath);
|
|
3685
|
+
if (filetools.fs.existsSync(localPath)) {
|
|
3686
|
+
const items = filetools.findFiles(localPath);
|
|
3532
3687
|
const self = this;
|
|
3533
3688
|
if (items.length) {
|
|
3534
3689
|
for (const filepath of items) {
|
|
3535
|
-
const p = pth.join(zipPath, relativePath(
|
|
3690
|
+
const p = pth.join(zipPath, relativePath(localPath, filepath));
|
|
3536
3691
|
if (filter(p)) {
|
|
3537
3692
|
self.addLocalFile(filepath, pth.dirname(p));
|
|
3538
3693
|
}
|
|
3539
3694
|
}
|
|
3540
3695
|
}
|
|
3541
3696
|
} else {
|
|
3542
|
-
throw Utils.Errors.FILE_NOT_FOUND(
|
|
3697
|
+
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
3543
3698
|
}
|
|
3544
3699
|
},
|
|
3545
3700
|
/**
|
|
@@ -3550,24 +3705,24 @@ var require_adm_zip = __commonJS({
|
|
|
3550
3705
|
* @param {RegExp|function} [filter] optional RegExp or Function if files match will
|
|
3551
3706
|
* be included.
|
|
3552
3707
|
*/
|
|
3553
|
-
addLocalFolderAsync: function(
|
|
3708
|
+
addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
|
|
3554
3709
|
filter = filenameFilter(filter);
|
|
3555
3710
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3556
|
-
|
|
3711
|
+
localPath = pth.normalize(localPath);
|
|
3557
3712
|
var self = this;
|
|
3558
|
-
filetools.fs.open(
|
|
3713
|
+
filetools.fs.open(localPath, "r", function(err) {
|
|
3559
3714
|
if (err && err.code === "ENOENT") {
|
|
3560
|
-
callback(void 0, Utils.Errors.FILE_NOT_FOUND(
|
|
3715
|
+
callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
3561
3716
|
} else if (err) {
|
|
3562
3717
|
callback(void 0, err);
|
|
3563
3718
|
} else {
|
|
3564
|
-
var items = filetools.findFiles(
|
|
3719
|
+
var items = filetools.findFiles(localPath);
|
|
3565
3720
|
var i = -1;
|
|
3566
3721
|
var next = function() {
|
|
3567
3722
|
i += 1;
|
|
3568
3723
|
if (i < items.length) {
|
|
3569
3724
|
var filepath = items[i];
|
|
3570
|
-
var p = relativePath(
|
|
3725
|
+
var p = relativePath(localPath, filepath).split("\\").join("/");
|
|
3571
3726
|
p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
3572
3727
|
if (filter(p)) {
|
|
3573
3728
|
filetools.fs.stat(filepath, function(er0, stats) {
|
|
@@ -3613,21 +3768,21 @@ var require_adm_zip = __commonJS({
|
|
|
3613
3768
|
addLocalFolderAsync2: function(options2, callback) {
|
|
3614
3769
|
const self = this;
|
|
3615
3770
|
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
3616
|
-
localPath = pth.resolve(
|
|
3771
|
+
const localPath = pth.resolve(options2.localPath);
|
|
3617
3772
|
let { zipPath, filter, namefix } = options2;
|
|
3618
3773
|
if (filter instanceof RegExp) {
|
|
3619
|
-
filter = /* @__PURE__ */ function(rx) {
|
|
3774
|
+
filter = /* @__PURE__ */ (function(rx) {
|
|
3620
3775
|
return function(filename) {
|
|
3621
3776
|
return rx.test(filename);
|
|
3622
3777
|
};
|
|
3623
|
-
}(filter);
|
|
3778
|
+
})(filter);
|
|
3624
3779
|
} else if ("function" !== typeof filter) {
|
|
3625
3780
|
filter = function() {
|
|
3626
3781
|
return true;
|
|
3627
3782
|
};
|
|
3628
3783
|
}
|
|
3629
3784
|
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
3630
|
-
if (namefix
|
|
3785
|
+
if (namefix === "latin1") {
|
|
3631
3786
|
namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
3632
3787
|
}
|
|
3633
3788
|
if (typeof namefix !== "function") namefix = (str) => str;
|
|
@@ -3635,14 +3790,14 @@ var require_adm_zip = __commonJS({
|
|
|
3635
3790
|
const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
|
|
3636
3791
|
filetools.fs.open(localPath, "r", function(err) {
|
|
3637
3792
|
if (err && err.code === "ENOENT") {
|
|
3638
|
-
callback(
|
|
3793
|
+
callback(Utils.Errors.FILE_NOT_FOUND(localPath), false);
|
|
3639
3794
|
} else if (err) {
|
|
3640
|
-
callback(
|
|
3795
|
+
callback(err, false);
|
|
3641
3796
|
} else {
|
|
3642
3797
|
filetools.findFilesAsync(localPath, function(err2, fileEntries) {
|
|
3643
|
-
if (err2) return callback(err2);
|
|
3798
|
+
if (err2) return callback(err2, false);
|
|
3644
3799
|
fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
|
|
3645
|
-
if (!fileEntries.length) callback(void 0,
|
|
3800
|
+
if (!fileEntries.length) return callback(void 0, true);
|
|
3646
3801
|
setImmediate(
|
|
3647
3802
|
fileEntries.reverse().reduce(function(next, entry) {
|
|
3648
3803
|
return function(err3, done) {
|
|
@@ -3671,10 +3826,10 @@ var require_adm_zip = __commonJS({
|
|
|
3671
3826
|
* @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
|
|
3672
3827
|
* @param {function|string} [props.namefix] - optional function to help fix filename
|
|
3673
3828
|
*/
|
|
3674
|
-
addLocalFolderPromise: function(
|
|
3829
|
+
addLocalFolderPromise: function(localPath, props) {
|
|
3675
3830
|
return new Promise((resolve, reject) => {
|
|
3676
|
-
this.addLocalFolderAsync2(Object.assign({ localPath
|
|
3677
|
-
if (err) reject(err);
|
|
3831
|
+
this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
|
|
3832
|
+
if (err) return reject(err);
|
|
3678
3833
|
if (done) resolve(this);
|
|
3679
3834
|
});
|
|
3680
3835
|
});
|
|
@@ -3765,7 +3920,7 @@ var require_adm_zip = __commonJS({
|
|
|
3765
3920
|
throw Utils.Errors.NO_ENTRY();
|
|
3766
3921
|
}
|
|
3767
3922
|
var entryName = canonical(item.entryName);
|
|
3768
|
-
var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
3923
|
+
var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
3769
3924
|
if (item.isDirectory) {
|
|
3770
3925
|
var children = _zip.getEntryChildren(item);
|
|
3771
3926
|
children.forEach(function(child) {
|
|
@@ -3774,8 +3929,9 @@ var require_adm_zip = __commonJS({
|
|
|
3774
3929
|
if (!content2) {
|
|
3775
3930
|
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
3776
3931
|
}
|
|
3777
|
-
var name = canonical(child.entryName);
|
|
3778
|
-
var childName = sanitize(targetPath,
|
|
3932
|
+
var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
|
|
3933
|
+
var childName = sanitize(targetPath, name);
|
|
3934
|
+
filetools.assertPathSafe(targetPath, childName);
|
|
3779
3935
|
const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
|
|
3780
3936
|
filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
|
|
3781
3937
|
});
|
|
@@ -3783,6 +3939,7 @@ var require_adm_zip = __commonJS({
|
|
|
3783
3939
|
}
|
|
3784
3940
|
var content = item.getData(_zip.password);
|
|
3785
3941
|
if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
3942
|
+
filetools.assertPathSafe(targetPath, target);
|
|
3786
3943
|
if (filetools.fs.existsSync(target) && !overwrite) {
|
|
3787
3944
|
throw Utils.Errors.CANT_OVERRIDE();
|
|
3788
3945
|
}
|
|
@@ -3798,12 +3955,12 @@ var require_adm_zip = __commonJS({
|
|
|
3798
3955
|
if (!_zip) {
|
|
3799
3956
|
return false;
|
|
3800
3957
|
}
|
|
3801
|
-
for (var entry
|
|
3958
|
+
for (var entry of _zip.entries) {
|
|
3802
3959
|
try {
|
|
3803
3960
|
if (entry.isDirectory) {
|
|
3804
3961
|
continue;
|
|
3805
3962
|
}
|
|
3806
|
-
var content =
|
|
3963
|
+
var content = entry.getData(pass);
|
|
3807
3964
|
if (!content) {
|
|
3808
3965
|
return false;
|
|
3809
3966
|
}
|
|
@@ -3828,10 +3985,13 @@ var require_adm_zip = __commonJS({
|
|
|
3828
3985
|
pass = get_Str(keepOriginalPermission, pass);
|
|
3829
3986
|
overwrite = get_Bool(false, overwrite);
|
|
3830
3987
|
if (!_zip) throw Utils.Errors.NO_ZIP();
|
|
3988
|
+
const dirEntries = [];
|
|
3831
3989
|
_zip.entries.forEach(function(entry) {
|
|
3832
3990
|
var entryName = sanitize(targetPath, canonical(entry.entryName));
|
|
3991
|
+
filetools.assertPathSafe(targetPath, entryName);
|
|
3833
3992
|
if (entry.isDirectory) {
|
|
3834
3993
|
filetools.makeDir(entryName);
|
|
3994
|
+
if (keepOriginalPermission) dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
|
|
3835
3995
|
return;
|
|
3836
3996
|
}
|
|
3837
3997
|
var content = entry.getData(pass);
|
|
@@ -3843,9 +4003,9 @@ var require_adm_zip = __commonJS({
|
|
|
3843
4003
|
try {
|
|
3844
4004
|
filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
|
|
3845
4005
|
} catch (err) {
|
|
3846
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
3847
4006
|
}
|
|
3848
4007
|
});
|
|
4008
|
+
applyDirAttributes(dirEntries);
|
|
3849
4009
|
},
|
|
3850
4010
|
/**
|
|
3851
4011
|
* Asynchronous extractAllTo
|
|
@@ -3888,17 +4048,33 @@ var require_adm_zip = __commonJS({
|
|
|
3888
4048
|
fileEntries.push(e);
|
|
3889
4049
|
}
|
|
3890
4050
|
});
|
|
4051
|
+
const deferredDirAttr = [];
|
|
3891
4052
|
for (const entry of dirEntries) {
|
|
3892
4053
|
const dirPath = getPath2(entry);
|
|
3893
4054
|
const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
|
|
3894
4055
|
try {
|
|
4056
|
+
filetools.assertPathSafe(targetPath, dirPath);
|
|
3895
4057
|
filetools.makeDir(dirPath);
|
|
3896
|
-
if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
|
|
3897
|
-
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
3898
4058
|
} catch (er) {
|
|
3899
4059
|
callback(getError("Unable to create folder", dirPath));
|
|
4060
|
+
continue;
|
|
4061
|
+
}
|
|
4062
|
+
if (dirAttr) deferredDirAttr.push({ path: dirPath, attr: dirAttr });
|
|
4063
|
+
try {
|
|
4064
|
+
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
4065
|
+
} catch (er) {
|
|
3900
4066
|
}
|
|
3901
4067
|
}
|
|
4068
|
+
const done = (err) => {
|
|
4069
|
+
if (!err) {
|
|
4070
|
+
try {
|
|
4071
|
+
applyDirAttributes(deferredDirAttr);
|
|
4072
|
+
} catch (er) {
|
|
4073
|
+
return callback(getError("Unable to set folder permissions", er.path || ""));
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
callback(err);
|
|
4077
|
+
};
|
|
3902
4078
|
fileEntries.reverse().reduce(function(next, entry) {
|
|
3903
4079
|
return function(err) {
|
|
3904
4080
|
if (err) {
|
|
@@ -3906,6 +4082,11 @@ var require_adm_zip = __commonJS({
|
|
|
3906
4082
|
} else {
|
|
3907
4083
|
const entryName = pth.normalize(canonical(entry.entryName));
|
|
3908
4084
|
const filePath = sanitize(targetPath, entryName);
|
|
4085
|
+
try {
|
|
4086
|
+
filetools.assertPathSafe(targetPath, filePath);
|
|
4087
|
+
} catch (er) {
|
|
4088
|
+
return next(er);
|
|
4089
|
+
}
|
|
3909
4090
|
entry.getDataAsync(function(content, err_1) {
|
|
3910
4091
|
if (err_1) {
|
|
3911
4092
|
next(err_1);
|
|
@@ -3915,21 +4096,17 @@ var require_adm_zip = __commonJS({
|
|
|
3915
4096
|
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
|
|
3916
4097
|
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
|
|
3917
4098
|
if (!succ) {
|
|
3918
|
-
next(getError("Unable to write file", filePath));
|
|
4099
|
+
return next(getError("Unable to write file", filePath));
|
|
3919
4100
|
}
|
|
3920
|
-
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(
|
|
3921
|
-
|
|
3922
|
-
next(getError("Unable to set times", filePath));
|
|
3923
|
-
} else {
|
|
3924
|
-
next();
|
|
3925
|
-
}
|
|
4101
|
+
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
|
|
4102
|
+
next();
|
|
3926
4103
|
});
|
|
3927
4104
|
});
|
|
3928
4105
|
}
|
|
3929
4106
|
});
|
|
3930
4107
|
}
|
|
3931
4108
|
};
|
|
3932
|
-
},
|
|
4109
|
+
}, done)();
|
|
3933
4110
|
},
|
|
3934
4111
|
/**
|
|
3935
4112
|
* 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
|
|
@@ -4011,7 +4188,7 @@ var require_package = __commonJS({
|
|
|
4011
4188
|
publishConfig: {
|
|
4012
4189
|
access: "public"
|
|
4013
4190
|
},
|
|
4014
|
-
version: "0.1.
|
|
4191
|
+
version: "0.1.3",
|
|
4015
4192
|
description: "Flowrunner CLI for deploying Custom Extensions",
|
|
4016
4193
|
bin: {
|
|
4017
4194
|
flowrunner: "./bin/flowrunner.js"
|
|
@@ -4039,7 +4216,7 @@ var require_package = __commonJS({
|
|
|
4039
4216
|
},
|
|
4040
4217
|
dependencies: {
|
|
4041
4218
|
"@types/node": "^20.0.0",
|
|
4042
|
-
"adm-zip": "^0.
|
|
4219
|
+
"adm-zip": "^0.6.1",
|
|
4043
4220
|
archiver: "^7.0.0",
|
|
4044
4221
|
commander: "^12.0.0",
|
|
4045
4222
|
"form-data": "^4.0.0",
|
|
@@ -4055,7 +4232,7 @@ var require_package = __commonJS({
|
|
|
4055
4232
|
"@types/adm-zip": "^0.5.7",
|
|
4056
4233
|
"@types/archiver": "^6.0.0",
|
|
4057
4234
|
"@types/node-fetch": "^2.6.0",
|
|
4058
|
-
esbuild: "^0.
|
|
4235
|
+
esbuild: "^0.28.2",
|
|
4059
4236
|
nock: "^14.0.17",
|
|
4060
4237
|
"query-string": "^7.1.3",
|
|
4061
4238
|
"tsconfig-paths": "^4.2.0",
|
|
@@ -7055,11 +7232,11 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
7055
7232
|
if (!this.#props.apiRequest) {
|
|
7056
7233
|
return void 0;
|
|
7057
7234
|
}
|
|
7058
|
-
this.#apiRequest ??= (arg) => this.#props.apiRequest({
|
|
7235
|
+
this.#apiRequest ??= ((arg) => this.#props.apiRequest({
|
|
7059
7236
|
...arg,
|
|
7060
7237
|
context: this.context,
|
|
7061
7238
|
logger: this.logger
|
|
7062
|
-
});
|
|
7239
|
+
}));
|
|
7063
7240
|
return this.#apiRequest;
|
|
7064
7241
|
}
|
|
7065
7242
|
// The bag every handler receives. Memoized: one bag per context, so the `helpers` factory runs once.
|
|
@@ -7731,11 +7908,13 @@ var RealtimeInboundInvocationSchema = z2.looseObject({
|
|
|
7731
7908
|
queryParams: anyRecord().optional(),
|
|
7732
7909
|
body: z2.unknown(),
|
|
7733
7910
|
rawBody: z2.string().optional(),
|
|
7911
|
+
webhookData: anyRecord().nullish(),
|
|
7734
7912
|
connectionId: z2.string().nullish()
|
|
7735
7913
|
});
|
|
7736
7914
|
var RealtimeSelectInvocationSchema = z2.looseObject({
|
|
7737
7915
|
eventName: z2.string().min(1),
|
|
7738
7916
|
eventData: z2.unknown(),
|
|
7917
|
+
webhookData: anyRecord().nullish(),
|
|
7739
7918
|
triggers: z2.array(z2.looseObject({
|
|
7740
7919
|
id: z2.string().min(1),
|
|
7741
7920
|
// A partially-configured instance is legal — `match` treats an empty param as "matches all".
|
|
@@ -7744,12 +7923,13 @@ var RealtimeSelectInvocationSchema = z2.looseObject({
|
|
|
7744
7923
|
});
|
|
7745
7924
|
|
|
7746
7925
|
// ../../flow-extension-runner/src/v2/realtime-triggers/verify.ts
|
|
7747
|
-
function verifyDeclarative(verify, rawBody, headers, config) {
|
|
7926
|
+
function verifyDeclarative(verify, rawBody, headers, config, webhookData) {
|
|
7748
7927
|
const provided = headers[verify.header] ?? headers[verify.header.toLowerCase()];
|
|
7749
7928
|
if (!provided) {
|
|
7750
7929
|
return false;
|
|
7751
7930
|
}
|
|
7752
|
-
const
|
|
7931
|
+
const secret = verify.secret(config, { webhookData });
|
|
7932
|
+
const computed = Flowrunner.crypto.hmac(verify.algo, secret, rawBody ?? "", verify.encoding);
|
|
7753
7933
|
if (!Flowrunner.crypto.timingSafeEqual(provided, computed)) {
|
|
7754
7934
|
return false;
|
|
7755
7935
|
}
|
|
@@ -7883,8 +8063,9 @@ var RealtimeSetup = class {
|
|
|
7883
8063
|
const headers = invocation.headers ?? {};
|
|
7884
8064
|
const body = invocation.body;
|
|
7885
8065
|
const rawBody = invocation.rawBody;
|
|
8066
|
+
const webhookData = invocation.webhookData ?? null;
|
|
7886
8067
|
if (this.props.handshake) {
|
|
7887
|
-
const result = await this.props.handshake(ctx.bagWith({ requestBody: body, headers, rawBody }));
|
|
8068
|
+
const result = await this.props.handshake(ctx.bagWith({ requestBody: body, headers, rawBody, webhookData }));
|
|
7888
8069
|
if (result && (result.responseToExternalService !== void 0 || result.responseHeaders || result.responseToWebhook)) {
|
|
7889
8070
|
return {
|
|
7890
8071
|
handshake: true,
|
|
@@ -7897,7 +8078,7 @@ var RealtimeSetup = class {
|
|
|
7897
8078
|
if (isEmptyBody(body)) {
|
|
7898
8079
|
return { handshake: true, events: [] };
|
|
7899
8080
|
}
|
|
7900
|
-
if (!await this.#verify(rawBody, headers, ctx)) {
|
|
8081
|
+
if (!await this.#verify(rawBody, headers, webhookData, ctx)) {
|
|
7901
8082
|
ctx.logger.warn(`[flow-extension:${this.extension.id}] webhook signature verification failed \u2014 answering 401`);
|
|
7902
8083
|
return { events: [], responseToWebhook: { httpStatus: 401, rawBody: "" } };
|
|
7903
8084
|
}
|
|
@@ -7907,6 +8088,7 @@ var RealtimeSetup = class {
|
|
|
7907
8088
|
headers,
|
|
7908
8089
|
query: invocation.queryParams ?? {},
|
|
7909
8090
|
body,
|
|
8091
|
+
webhookData,
|
|
7910
8092
|
connectionId: invocation.connectionId
|
|
7911
8093
|
}));
|
|
7912
8094
|
return {
|
|
@@ -7935,12 +8117,12 @@ var RealtimeSetup = class {
|
|
|
7935
8117
|
return { events, eventScopeId, connectionId: invocation.connectionId };
|
|
7936
8118
|
}
|
|
7937
8119
|
// The author's own check wins; otherwise the declarative one; otherwise nothing was asked for.
|
|
7938
|
-
async #verify(rawBody, headers, ctx) {
|
|
8120
|
+
async #verify(rawBody, headers, webhookData, ctx) {
|
|
7939
8121
|
if (this.props.verifyRequest) {
|
|
7940
|
-
return !!await this.props.verifyRequest(ctx.bagWith({ rawBody, headers, config: ctx.config }));
|
|
8122
|
+
return !!await this.props.verifyRequest(ctx.bagWith({ rawBody, headers, webhookData, config: ctx.config }));
|
|
7941
8123
|
}
|
|
7942
8124
|
if (this.props.verify) {
|
|
7943
|
-
return verifyDeclarative(this.props.verify, rawBody, headers, ctx.config);
|
|
8125
|
+
return verifyDeclarative(this.props.verify, rawBody, headers, ctx.config, webhookData);
|
|
7944
8126
|
}
|
|
7945
8127
|
return true;
|
|
7946
8128
|
}
|
|
@@ -7960,8 +8142,9 @@ var RealtimeSetup = class {
|
|
|
7960
8142
|
return { ids: [], enrichedEventData: null };
|
|
7961
8143
|
}
|
|
7962
8144
|
const eventData = invocation.eventData;
|
|
7963
|
-
const
|
|
7964
|
-
const
|
|
8145
|
+
const webhookData = invocation.webhookData ?? null;
|
|
8146
|
+
const ids = (invocation.triggers ?? []).filter((instance) => trigger.matches(instance.data ?? {}, eventData, webhookData)).map((instance) => instance.id);
|
|
8147
|
+
const enrichedEventData = ids.length && trigger.hasExtendResult() ? await trigger.extendResult(eventData, ctx, webhookData) : null;
|
|
7965
8148
|
return { ids, enrichedEventData };
|
|
7966
8149
|
}
|
|
7967
8150
|
};
|
|
@@ -8022,14 +8205,18 @@ var RealtimeTriggerMethod = class extends ExtensionMethod {
|
|
|
8022
8205
|
* Whether one CONFIGURED INSTANCE of this trigger cares about an event. Declarative form: type-coerced
|
|
8023
8206
|
* equality per filled param, where an empty param means "any" — that is what lets a user leave a filter
|
|
8024
8207
|
* blank and receive everything. Predicate form: the author decides. No `match` at all: always fires.
|
|
8208
|
+
*
|
|
8209
|
+
* `webhookData` is handed to the predicate form to be READ — an instance filter that depends on what the
|
|
8210
|
+
* subscription registered (a tenant id, a resource the webhook was scoped to) has nowhere else to get it.
|
|
8211
|
+
* Returning a new document is not a thing this seam can do; only subscribe/refresh/unsubscribe persist.
|
|
8025
8212
|
*/
|
|
8026
|
-
matches(params, providerEventData) {
|
|
8213
|
+
matches(params, providerEventData, webhookData = null) {
|
|
8027
8214
|
const match = this.props.match;
|
|
8028
8215
|
if (!match) {
|
|
8029
8216
|
return true;
|
|
8030
8217
|
}
|
|
8031
8218
|
if (typeof match === "function") {
|
|
8032
|
-
return !!match({ params, providerEventData });
|
|
8219
|
+
return !!match({ params, providerEventData, webhookData });
|
|
8033
8220
|
}
|
|
8034
8221
|
for (const [paramKey, path23] of Object.entries(match)) {
|
|
8035
8222
|
const paramValue = params[paramKey];
|
|
@@ -8043,8 +8230,9 @@ var RealtimeTriggerMethod = class extends ExtensionMethod {
|
|
|
8043
8230
|
return true;
|
|
8044
8231
|
}
|
|
8045
8232
|
// Runs ONCE per event if any instance matched — the only per-event place that may call the provider API.
|
|
8046
|
-
|
|
8047
|
-
|
|
8233
|
+
// It reads `webhookData` (an access token or external id the subscription stored) but cannot change it.
|
|
8234
|
+
extendResult(providerEventData, ctx, webhookData = null) {
|
|
8235
|
+
return this.props.extendResult?.(ctx.bagWith({ providerEventData, webhookData }));
|
|
8048
8236
|
}
|
|
8049
8237
|
hasExtendResult() {
|
|
8050
8238
|
return typeof this.props.extendResult === "function";
|
|
@@ -10456,6 +10644,7 @@ async function initCommand(templateId, options = {}) {
|
|
|
10456
10644
|
const relative = import_path22.default.relative(process.cwd(), result.projectRoot);
|
|
10457
10645
|
const where = !relative || relative.startsWith("..") ? result.projectRoot : relative;
|
|
10458
10646
|
const step = (index2, text2) => say(` ${index2}. ${text2}`);
|
|
10647
|
+
const option = (text2) => say(` ${text2}`);
|
|
10459
10648
|
await offerGlobalInstall();
|
|
10460
10649
|
if (result.service && result.projectRoot === process.cwd() && await offerDeploy(result.service.serviceId)) {
|
|
10461
10650
|
return;
|
|
@@ -10468,16 +10657,17 @@ async function initCommand(templateId, options = {}) {
|
|
|
10468
10657
|
if (!result.installed) {
|
|
10469
10658
|
step(index++, "npm install");
|
|
10470
10659
|
}
|
|
10660
|
+
step(index++, "write the service \u2014 either route works:");
|
|
10661
|
+
option(`${cliCommand()} init-claude \u2014 wire in the FlowRunner agents, then describe what you want`);
|
|
10471
10662
|
if (result.service) {
|
|
10472
|
-
|
|
10663
|
+
option(`services/${result.service.serviceId}/src/index.js \u2014 or open it and write it yourself`);
|
|
10473
10664
|
} else {
|
|
10474
|
-
|
|
10665
|
+
option(`${cliCommand()} cs \u2014 or scaffold a service and write it yourself`);
|
|
10475
10666
|
}
|
|
10476
10667
|
if (options.tests !== false) {
|
|
10477
10668
|
step(index++, "npm test \u2014 the unit suites in services/*/tests/");
|
|
10478
10669
|
}
|
|
10479
|
-
step(index
|
|
10480
|
-
step(index, `${cliCommand()} init-claude \u2014 optional, wires the FlowRunner agents into Claude Code`);
|
|
10670
|
+
step(index, `${cliCommand()} deploy \u2014 logs you in first if you have not already`);
|
|
10481
10671
|
say("");
|
|
10482
10672
|
} catch (error) {
|
|
10483
10673
|
fail(error);
|