efiencrypt 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/efiencrypt +66 -63
- package/package.json +1 -1
package/efiencrypt
CHANGED
|
@@ -61,25 +61,25 @@ function requireArgument() {
|
|
|
61
61
|
* @param {string} name
|
|
62
62
|
* @param {string} [description]
|
|
63
63
|
*/
|
|
64
|
-
constructor(
|
|
65
|
-
this.description =
|
|
64
|
+
constructor(name2, description2) {
|
|
65
|
+
this.description = description2 || "";
|
|
66
66
|
this.variadic = false;
|
|
67
67
|
this.parseArg = void 0;
|
|
68
68
|
this.defaultValue = void 0;
|
|
69
69
|
this.defaultValueDescription = void 0;
|
|
70
70
|
this.argChoices = void 0;
|
|
71
|
-
switch (
|
|
71
|
+
switch (name2[0]) {
|
|
72
72
|
case "<":
|
|
73
73
|
this.required = true;
|
|
74
|
-
this._name =
|
|
74
|
+
this._name = name2.slice(1, -1);
|
|
75
75
|
break;
|
|
76
76
|
case "[":
|
|
77
77
|
this.required = false;
|
|
78
|
-
this._name =
|
|
78
|
+
this._name = name2.slice(1, -1);
|
|
79
79
|
break;
|
|
80
80
|
default:
|
|
81
81
|
this.required = true;
|
|
82
|
-
this._name =
|
|
82
|
+
this._name = name2;
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
if (this._name.endsWith("...")) {
|
|
@@ -112,9 +112,9 @@ function requireArgument() {
|
|
|
112
112
|
* @param {string} [description]
|
|
113
113
|
* @return {Argument}
|
|
114
114
|
*/
|
|
115
|
-
default(value,
|
|
115
|
+
default(value, description2) {
|
|
116
116
|
this.defaultValue = value;
|
|
117
|
-
this.defaultValueDescription =
|
|
117
|
+
this.defaultValueDescription = description2;
|
|
118
118
|
return this;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -538,8 +538,8 @@ function requireHelp() {
|
|
|
538
538
|
formatHelp(cmd, helper) {
|
|
539
539
|
const termWidth = helper.padWidth(cmd, helper);
|
|
540
540
|
const helpWidth = helper.helpWidth ?? 80;
|
|
541
|
-
function callFormatItem(term,
|
|
542
|
-
return helper.formatItem(term, termWidth,
|
|
541
|
+
function callFormatItem(term, description2) {
|
|
542
|
+
return helper.formatItem(term, termWidth, description2, helper);
|
|
543
543
|
}
|
|
544
544
|
let output = [
|
|
545
545
|
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
|
@@ -710,10 +710,10 @@ function requireHelp() {
|
|
|
710
710
|
* @param {Help} helper
|
|
711
711
|
* @returns {string}
|
|
712
712
|
*/
|
|
713
|
-
formatItem(term, termWidth,
|
|
713
|
+
formatItem(term, termWidth, description2, helper) {
|
|
714
714
|
const itemIndent = 2;
|
|
715
715
|
const itemIndentStr = " ".repeat(itemIndent);
|
|
716
|
-
if (!
|
|
716
|
+
if (!description2) return itemIndentStr + term;
|
|
717
717
|
const paddedTerm = term.padEnd(
|
|
718
718
|
termWidth + term.length - helper.displayWidth(term)
|
|
719
719
|
);
|
|
@@ -721,10 +721,10 @@ function requireHelp() {
|
|
|
721
721
|
const helpWidth = this.helpWidth ?? 80;
|
|
722
722
|
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
723
723
|
let formattedDescription;
|
|
724
|
-
if (remainingWidth < this.minWidthToWrap || helper.preformatted(
|
|
725
|
-
formattedDescription =
|
|
724
|
+
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description2)) {
|
|
725
|
+
formattedDescription = description2;
|
|
726
726
|
} else {
|
|
727
|
-
const wrappedDescription = helper.boxWrap(
|
|
727
|
+
const wrappedDescription = helper.boxWrap(description2, remainingWidth);
|
|
728
728
|
formattedDescription = wrappedDescription.replace(
|
|
729
729
|
/\n/g,
|
|
730
730
|
"\n" + " ".repeat(termWidth + spacerWidth)
|
|
@@ -792,9 +792,9 @@ function requireOption() {
|
|
|
792
792
|
* @param {string} flags
|
|
793
793
|
* @param {string} [description]
|
|
794
794
|
*/
|
|
795
|
-
constructor(flags,
|
|
795
|
+
constructor(flags, description2) {
|
|
796
796
|
this.flags = flags;
|
|
797
|
-
this.description =
|
|
797
|
+
this.description = description2 || "";
|
|
798
798
|
this.required = flags.includes("<");
|
|
799
799
|
this.optional = flags.includes("[");
|
|
800
800
|
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
@@ -824,9 +824,9 @@ function requireOption() {
|
|
|
824
824
|
* @param {string} [description]
|
|
825
825
|
* @return {Option}
|
|
826
826
|
*/
|
|
827
|
-
default(value,
|
|
827
|
+
default(value, description2) {
|
|
828
828
|
this.defaultValue = value;
|
|
829
|
-
this.defaultValueDescription =
|
|
829
|
+
this.defaultValueDescription = description2;
|
|
830
830
|
return this;
|
|
831
831
|
}
|
|
832
832
|
/**
|
|
@@ -889,8 +889,8 @@ function requireOption() {
|
|
|
889
889
|
* @param {string} name
|
|
890
890
|
* @return {Option}
|
|
891
891
|
*/
|
|
892
|
-
env(
|
|
893
|
-
this.envVar =
|
|
892
|
+
env(name2) {
|
|
893
|
+
this.envVar = name2;
|
|
894
894
|
return this;
|
|
895
895
|
}
|
|
896
896
|
/**
|
|
@@ -1194,7 +1194,7 @@ function requireCommand() {
|
|
|
1194
1194
|
*
|
|
1195
1195
|
* @param {string} [name]
|
|
1196
1196
|
*/
|
|
1197
|
-
constructor(
|
|
1197
|
+
constructor(name2) {
|
|
1198
1198
|
super();
|
|
1199
1199
|
this.commands = [];
|
|
1200
1200
|
this.options = [];
|
|
@@ -1207,7 +1207,7 @@ function requireCommand() {
|
|
|
1207
1207
|
this.rawArgs = [];
|
|
1208
1208
|
this.processedArgs = [];
|
|
1209
1209
|
this._scriptPath = null;
|
|
1210
|
-
this._name =
|
|
1210
|
+
this._name = name2 || "";
|
|
1211
1211
|
this._optionValues = {};
|
|
1212
1212
|
this._optionValueSources = {};
|
|
1213
1213
|
this._storeOptionsAsProperties = false;
|
|
@@ -1312,8 +1312,8 @@ function requireCommand() {
|
|
|
1312
1312
|
desc = null;
|
|
1313
1313
|
}
|
|
1314
1314
|
opts = opts || {};
|
|
1315
|
-
const [,
|
|
1316
|
-
const cmd = this.createCommand(
|
|
1315
|
+
const [, name2, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1316
|
+
const cmd = this.createCommand(name2);
|
|
1317
1317
|
if (desc) {
|
|
1318
1318
|
cmd.description(desc);
|
|
1319
1319
|
cmd._executableHandler = true;
|
|
@@ -1337,8 +1337,8 @@ function requireCommand() {
|
|
|
1337
1337
|
* @param {string} [name]
|
|
1338
1338
|
* @return {Command} new command
|
|
1339
1339
|
*/
|
|
1340
|
-
createCommand(
|
|
1341
|
-
return new Command2(
|
|
1340
|
+
createCommand(name2) {
|
|
1341
|
+
return new Command2(name2);
|
|
1342
1342
|
}
|
|
1343
1343
|
/**
|
|
1344
1344
|
* You can customise the help with a subclass of Help by overriding createHelp,
|
|
@@ -1444,8 +1444,8 @@ function requireCommand() {
|
|
|
1444
1444
|
* @param {string} [description]
|
|
1445
1445
|
* @return {Argument} new argument
|
|
1446
1446
|
*/
|
|
1447
|
-
createArgument(
|
|
1448
|
-
return new Argument2(
|
|
1447
|
+
createArgument(name2, description2) {
|
|
1448
|
+
return new Argument2(name2, description2);
|
|
1449
1449
|
}
|
|
1450
1450
|
/**
|
|
1451
1451
|
* Define argument syntax for command.
|
|
@@ -1463,8 +1463,8 @@ function requireCommand() {
|
|
|
1463
1463
|
* @param {*} [defaultValue]
|
|
1464
1464
|
* @return {Command} `this` command for chaining
|
|
1465
1465
|
*/
|
|
1466
|
-
argument(
|
|
1467
|
-
const argument2 = this.createArgument(
|
|
1466
|
+
argument(name2, description2, parseArg, defaultValue) {
|
|
1467
|
+
const argument2 = this.createArgument(name2, description2);
|
|
1468
1468
|
if (typeof parseArg === "function") {
|
|
1469
1469
|
argument2.default(defaultValue).argParser(parseArg);
|
|
1470
1470
|
} else {
|
|
@@ -1524,7 +1524,7 @@ function requireCommand() {
|
|
|
1524
1524
|
* @param {string} [description] - custom description
|
|
1525
1525
|
* @return {Command} `this` command for chaining
|
|
1526
1526
|
*/
|
|
1527
|
-
helpCommand(enableOrNameAndArgs,
|
|
1527
|
+
helpCommand(enableOrNameAndArgs, description2) {
|
|
1528
1528
|
if (typeof enableOrNameAndArgs === "boolean") {
|
|
1529
1529
|
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
1530
1530
|
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
@@ -1534,14 +1534,14 @@ function requireCommand() {
|
|
|
1534
1534
|
}
|
|
1535
1535
|
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
1536
1536
|
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1537
|
-
const helpDescription =
|
|
1537
|
+
const helpDescription = description2 ?? "display help for command";
|
|
1538
1538
|
const helpCommand = this.createCommand(helpName);
|
|
1539
1539
|
helpCommand.helpOption(false);
|
|
1540
1540
|
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
1541
1541
|
if (helpDescription) helpCommand.description(helpDescription);
|
|
1542
1542
|
this._addImplicitHelpCommand = true;
|
|
1543
1543
|
this._helpCommand = helpCommand;
|
|
1544
|
-
if (enableOrNameAndArgs ||
|
|
1544
|
+
if (enableOrNameAndArgs || description2) this._initCommandGroup(helpCommand);
|
|
1545
1545
|
return this;
|
|
1546
1546
|
}
|
|
1547
1547
|
/**
|
|
@@ -1669,8 +1669,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1669
1669
|
* @param {string} [description]
|
|
1670
1670
|
* @return {Option} new option
|
|
1671
1671
|
*/
|
|
1672
|
-
createOption(flags,
|
|
1673
|
-
return new Option2(flags,
|
|
1672
|
+
createOption(flags, description2) {
|
|
1673
|
+
return new Option2(flags, description2);
|
|
1674
1674
|
}
|
|
1675
1675
|
/**
|
|
1676
1676
|
* Wrap parseArgs to catch 'commander.invalidArgument'.
|
|
@@ -1721,7 +1721,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1721
1721
|
return [cmd.name()].concat(cmd.aliases());
|
|
1722
1722
|
};
|
|
1723
1723
|
const alreadyUsed = knownBy(command2).find(
|
|
1724
|
-
(
|
|
1724
|
+
(name2) => this._findCommand(name2)
|
|
1725
1725
|
);
|
|
1726
1726
|
if (alreadyUsed) {
|
|
1727
1727
|
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
|
|
@@ -1742,24 +1742,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1742
1742
|
addOption(option2) {
|
|
1743
1743
|
this._registerOption(option2);
|
|
1744
1744
|
const oname = option2.name();
|
|
1745
|
-
const
|
|
1745
|
+
const name2 = option2.attributeName();
|
|
1746
1746
|
if (option2.negate) {
|
|
1747
1747
|
const positiveLongFlag = option2.long.replace(/^--no-/, "--");
|
|
1748
1748
|
if (!this._findOption(positiveLongFlag)) {
|
|
1749
1749
|
this.setOptionValueWithSource(
|
|
1750
|
-
|
|
1750
|
+
name2,
|
|
1751
1751
|
option2.defaultValue === void 0 ? true : option2.defaultValue,
|
|
1752
1752
|
"default"
|
|
1753
1753
|
);
|
|
1754
1754
|
}
|
|
1755
1755
|
} else if (option2.defaultValue !== void 0) {
|
|
1756
|
-
this.setOptionValueWithSource(
|
|
1756
|
+
this.setOptionValueWithSource(name2, option2.defaultValue, "default");
|
|
1757
1757
|
}
|
|
1758
1758
|
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
1759
1759
|
if (val == null && option2.presetArg !== void 0) {
|
|
1760
1760
|
val = option2.presetArg;
|
|
1761
1761
|
}
|
|
1762
|
-
const oldValue = this.getOptionValue(
|
|
1762
|
+
const oldValue = this.getOptionValue(name2);
|
|
1763
1763
|
if (val !== null && option2.parseArg) {
|
|
1764
1764
|
val = this._callParseArg(option2, val, oldValue, invalidValueMessage);
|
|
1765
1765
|
} else if (val !== null && option2.variadic) {
|
|
@@ -1774,7 +1774,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1774
1774
|
val = "";
|
|
1775
1775
|
}
|
|
1776
1776
|
}
|
|
1777
|
-
this.setOptionValueWithSource(
|
|
1777
|
+
this.setOptionValueWithSource(name2, val, valueSource);
|
|
1778
1778
|
};
|
|
1779
1779
|
this.on("option:" + oname, (val) => {
|
|
1780
1780
|
const invalidValueMessage = `error: option '${option2.flags}' argument '${val}' is invalid.`;
|
|
@@ -1794,13 +1794,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1794
1794
|
* @return {Command} `this` command for chaining
|
|
1795
1795
|
* @private
|
|
1796
1796
|
*/
|
|
1797
|
-
_optionEx(config, flags,
|
|
1797
|
+
_optionEx(config, flags, description2, fn, defaultValue) {
|
|
1798
1798
|
if (typeof flags === "object" && flags instanceof Option2) {
|
|
1799
1799
|
throw new Error(
|
|
1800
1800
|
"To add an Option object use addOption() instead of option() or requiredOption()"
|
|
1801
1801
|
);
|
|
1802
1802
|
}
|
|
1803
|
-
const option2 = this.createOption(flags,
|
|
1803
|
+
const option2 = this.createOption(flags, description2);
|
|
1804
1804
|
option2.makeOptionMandatory(!!config.mandatory);
|
|
1805
1805
|
if (typeof fn === "function") {
|
|
1806
1806
|
option2.default(defaultValue).argParser(fn);
|
|
@@ -1837,8 +1837,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1837
1837
|
* @param {*} [defaultValue]
|
|
1838
1838
|
* @return {Command} `this` command for chaining
|
|
1839
1839
|
*/
|
|
1840
|
-
option(flags,
|
|
1841
|
-
return this._optionEx({}, flags,
|
|
1840
|
+
option(flags, description2, parseArg, defaultValue) {
|
|
1841
|
+
return this._optionEx({}, flags, description2, parseArg, defaultValue);
|
|
1842
1842
|
}
|
|
1843
1843
|
/**
|
|
1844
1844
|
* Add a required option which must have a value after parsing. This usually means
|
|
@@ -1852,11 +1852,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1852
1852
|
* @param {*} [defaultValue]
|
|
1853
1853
|
* @return {Command} `this` command for chaining
|
|
1854
1854
|
*/
|
|
1855
|
-
requiredOption(flags,
|
|
1855
|
+
requiredOption(flags, description2, parseArg, defaultValue) {
|
|
1856
1856
|
return this._optionEx(
|
|
1857
1857
|
{ mandatory: true },
|
|
1858
1858
|
flags,
|
|
1859
|
-
|
|
1859
|
+
description2,
|
|
1860
1860
|
parseArg,
|
|
1861
1861
|
defaultValue
|
|
1862
1862
|
);
|
|
@@ -2550,10 +2550,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2550
2550
|
* @private
|
|
2551
2551
|
* @return {Command | undefined}
|
|
2552
2552
|
*/
|
|
2553
|
-
_findCommand(
|
|
2554
|
-
if (!
|
|
2553
|
+
_findCommand(name2) {
|
|
2554
|
+
if (!name2) return void 0;
|
|
2555
2555
|
return this.commands.find(
|
|
2556
|
-
(cmd) => cmd._name ===
|
|
2556
|
+
(cmd) => cmd._name === name2 || cmd._aliases.includes(name2)
|
|
2557
2557
|
);
|
|
2558
2558
|
}
|
|
2559
2559
|
/**
|
|
@@ -2834,8 +2834,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2834
2834
|
* @param {string} name
|
|
2835
2835
|
* @private
|
|
2836
2836
|
*/
|
|
2837
|
-
missingArgument(
|
|
2838
|
-
const message = `error: missing required argument '${
|
|
2837
|
+
missingArgument(name2) {
|
|
2838
|
+
const message = `error: missing required argument '${name2}'`;
|
|
2839
2839
|
this.error(message, { code: "commander.missingArgument" });
|
|
2840
2840
|
}
|
|
2841
2841
|
/**
|
|
@@ -2959,12 +2959,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2959
2959
|
* @param {string} [description]
|
|
2960
2960
|
* @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
|
|
2961
2961
|
*/
|
|
2962
|
-
version(str, flags,
|
|
2962
|
+
version(str, flags, description2) {
|
|
2963
2963
|
if (str === void 0) return this._version;
|
|
2964
2964
|
this._version = str;
|
|
2965
2965
|
flags = flags || "-V, --version";
|
|
2966
|
-
|
|
2967
|
-
const versionOption = this.createOption(flags,
|
|
2966
|
+
description2 = description2 || "output the version number";
|
|
2967
|
+
const versionOption = this.createOption(flags, description2);
|
|
2968
2968
|
this._versionOptionName = versionOption.attributeName();
|
|
2969
2969
|
this._registerOption(versionOption);
|
|
2970
2970
|
this.on("option:" + versionOption.name(), () => {
|
|
@@ -3266,7 +3266,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3266
3266
|
* @param {string} [description]
|
|
3267
3267
|
* @return {Command} `this` command for chaining
|
|
3268
3268
|
*/
|
|
3269
|
-
helpOption(flags,
|
|
3269
|
+
helpOption(flags, description2) {
|
|
3270
3270
|
if (typeof flags === "boolean") {
|
|
3271
3271
|
if (flags) {
|
|
3272
3272
|
if (this._helpOption === null) this._helpOption = void 0;
|
|
@@ -3280,9 +3280,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3280
3280
|
}
|
|
3281
3281
|
this._helpOption = this.createOption(
|
|
3282
3282
|
flags ?? "-h, --help",
|
|
3283
|
-
|
|
3283
|
+
description2 ?? "display help for command"
|
|
3284
3284
|
);
|
|
3285
|
-
if (flags ||
|
|
3285
|
+
if (flags || description2) this._initOptionGroup(this._helpOption);
|
|
3286
3286
|
return this;
|
|
3287
3287
|
}
|
|
3288
3288
|
/**
|
|
@@ -3429,9 +3429,9 @@ function requireCommander() {
|
|
|
3429
3429
|
const { Help: Help2 } = requireHelp();
|
|
3430
3430
|
const { Option: Option2 } = requireOption();
|
|
3431
3431
|
commander$1.program = new Command2();
|
|
3432
|
-
commander$1.createCommand = (
|
|
3433
|
-
commander$1.createOption = (flags,
|
|
3434
|
-
commander$1.createArgument = (
|
|
3432
|
+
commander$1.createCommand = (name2) => new Command2(name2);
|
|
3433
|
+
commander$1.createOption = (flags, description2) => new Option2(flags, description2);
|
|
3434
|
+
commander$1.createArgument = (name2, description2) => new Argument2(name2, description2);
|
|
3435
3435
|
commander$1.Command = Command2;
|
|
3436
3436
|
commander$1.Option = Option2;
|
|
3437
3437
|
commander$1.Argument = Argument2;
|
|
@@ -3457,7 +3457,10 @@ const {
|
|
|
3457
3457
|
Option,
|
|
3458
3458
|
Help
|
|
3459
3459
|
} = commander;
|
|
3460
|
-
|
|
3460
|
+
const name = "efiencrypt";
|
|
3461
|
+
const version = "1.0.0";
|
|
3462
|
+
const description = "Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)";
|
|
3463
|
+
program.name(name).description(description).showHelpAfterError(true).option("-c, --config-file <configFile>", "configuration file").option("-i, --input-file <inputFile>", "path to the input efi file to embed").option("-o, --output-file <outputFile>", "path to the output efi file to write").option("-s, --smbios <smbios>", "path to the input smbios dump file").option("-b, --build-folder <buildFolder>", "folder where to build the code").option("--skip-gen-code", "skip generating code").option("--skip-extract", "skip extracting source code").option("--skip-make", "skip calling make").version(version).action(async (options) => {
|
|
3461
3464
|
try {
|
|
3462
3465
|
let config = {};
|
|
3463
3466
|
if (options.configFile) {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"efiencrypt","version":"
|
|
1
|
+
{"name":"efiencrypt","version":"1.0.0","description":"Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)","type":"module","license":"MIT","bin":{"efiencrypt":"efiencrypt"},"repository":{"url":"https://github.com/davdiv/efiencrypt"},"exports":{".":{"types":"./index.d.ts","default":"./index.js"},"./smbios":{"types":"./smbios.d.ts","default":"./smbios.js"},"./schema.json":"./schema.json"}}
|