@qodalis/cli 2.0.0-beta.6 → 2.0.0-beta.7
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/package.json +2 -2
- package/public-api.d.mts +3 -60
- package/public-api.d.ts +3 -60
- package/public-api.js +1 -618
- package/public-api.js.map +1 -1
- package/public-api.mjs +2 -614
- package/public-api.mjs.map +1 -1
package/public-api.js
CHANGED
|
@@ -411,7 +411,7 @@ var CliBackgroundServiceRegistry_TOKEN = "cli-background-service-registry";
|
|
|
411
411
|
var CliPackageManagerService_TOKEN = "cli-package-manager-service";
|
|
412
412
|
|
|
413
413
|
// src/lib/version.ts
|
|
414
|
-
var LIBRARY_VERSION = "2.0.0-beta.
|
|
414
|
+
var LIBRARY_VERSION = "2.0.0-beta.7";
|
|
415
415
|
var API_VERSION = 2;
|
|
416
416
|
var CliAliasCommandProcessor = class {
|
|
417
417
|
constructor() {
|
|
@@ -606,105 +606,6 @@ var CliCaptureCommandProcessor = class {
|
|
|
606
606
|
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
607
607
|
}
|
|
608
608
|
};
|
|
609
|
-
var CliBase64CommandProcessor = class {
|
|
610
|
-
constructor() {
|
|
611
|
-
this.command = "base64";
|
|
612
|
-
this.aliases = ["b64"];
|
|
613
|
-
this.description = "Encode or decode Base64 strings";
|
|
614
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
615
|
-
this.processors = [];
|
|
616
|
-
this.metadata = {
|
|
617
|
-
icon: "\u{1F523}",
|
|
618
|
-
module: "misc"
|
|
619
|
-
};
|
|
620
|
-
this.processors = [
|
|
621
|
-
{
|
|
622
|
-
command: "encode",
|
|
623
|
-
aliases: ["enc", "e"],
|
|
624
|
-
description: "Encode text to Base64",
|
|
625
|
-
acceptsRawInput: true,
|
|
626
|
-
valueRequired: true,
|
|
627
|
-
processCommand: async (command2, context2) => {
|
|
628
|
-
const text = command2.value || command2.data || "";
|
|
629
|
-
const encoded = btoa(
|
|
630
|
-
new TextEncoder().encode(text).reduce(
|
|
631
|
-
(data, byte) => data + String.fromCharCode(byte),
|
|
632
|
-
""
|
|
633
|
-
)
|
|
634
|
-
);
|
|
635
|
-
context2.writer.writeln(encoded);
|
|
636
|
-
context2.process.output(encoded);
|
|
637
|
-
},
|
|
638
|
-
writeDescription: (context2) => {
|
|
639
|
-
const { writer } = context2;
|
|
640
|
-
writer.writeln("Encode text to Base64 format");
|
|
641
|
-
writer.writeln();
|
|
642
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
643
|
-
writer.writeln(
|
|
644
|
-
` ${writer.wrapInColor("base64 encode <text>", cliCore.CliForegroundColor.Cyan)}`
|
|
645
|
-
);
|
|
646
|
-
writer.writeln();
|
|
647
|
-
writer.writeln(`\u{1F4DD} ${context2.translator.t("cli.common.examples", "Examples:")}`);
|
|
648
|
-
writer.writeln(
|
|
649
|
-
` base64 encode Hello World ${writer.wrapInColor("# \u2192 SGVsbG8gV29ybGQ=", cliCore.CliForegroundColor.Green)}`
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
{
|
|
654
|
-
command: "decode",
|
|
655
|
-
aliases: ["dec", "d"],
|
|
656
|
-
description: "Decode a Base64 string",
|
|
657
|
-
acceptsRawInput: true,
|
|
658
|
-
valueRequired: true,
|
|
659
|
-
processCommand: async (command2, context2) => {
|
|
660
|
-
const encoded = command2.value || command2.data || "";
|
|
661
|
-
try {
|
|
662
|
-
const bytes = Uint8Array.from(
|
|
663
|
-
atob(encoded),
|
|
664
|
-
(c) => c.charCodeAt(0)
|
|
665
|
-
);
|
|
666
|
-
const decoded = new TextDecoder().decode(bytes);
|
|
667
|
-
context2.writer.writeln(decoded);
|
|
668
|
-
context2.process.output(decoded);
|
|
669
|
-
} catch {
|
|
670
|
-
context2.writer.writeError("Invalid Base64 string");
|
|
671
|
-
context2.process.exit(-1);
|
|
672
|
-
}
|
|
673
|
-
},
|
|
674
|
-
writeDescription: (context2) => {
|
|
675
|
-
const { writer } = context2;
|
|
676
|
-
writer.writeln("Decode a Base64 string back to text");
|
|
677
|
-
writer.writeln();
|
|
678
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
679
|
-
writer.writeln(
|
|
680
|
-
` ${writer.wrapInColor("base64 decode <base64>", cliCore.CliForegroundColor.Cyan)}`
|
|
681
|
-
);
|
|
682
|
-
writer.writeln();
|
|
683
|
-
writer.writeln(`\u{1F4DD} ${context2.translator.t("cli.common.examples", "Examples:")}`);
|
|
684
|
-
writer.writeln(
|
|
685
|
-
` base64 decode SGVsbG8gV29ybGQ= ${writer.wrapInColor("# \u2192 Hello World", cliCore.CliForegroundColor.Green)}`
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
];
|
|
690
|
-
}
|
|
691
|
-
async processCommand(command2, context2) {
|
|
692
|
-
context2.executor.showHelp(command2, context2);
|
|
693
|
-
}
|
|
694
|
-
writeDescription(context2) {
|
|
695
|
-
const { writer, translator: t } = context2;
|
|
696
|
-
writer.writeln(t.t("cli.base64.long_description", "Encode and decode Base64 strings"));
|
|
697
|
-
writer.writeln(t.t("cli.base64.utf8_note", "Supports UTF-8 text encoding"));
|
|
698
|
-
writer.writeln();
|
|
699
|
-
writer.writeln(`\u{1F4CB} ${t.t("cli.common.usage", "Usage:")}`);
|
|
700
|
-
writer.writeln(
|
|
701
|
-
` ${writer.wrapInColor("base64 encode <text>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.base64.encode_desc", "Encode text to Base64")}`
|
|
702
|
-
);
|
|
703
|
-
writer.writeln(
|
|
704
|
-
` ${writer.wrapInColor("base64 decode <base64>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.base64.decode_desc", "Decode Base64 to text")}`
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
609
|
var CliCalCommandProcessor = class {
|
|
709
610
|
constructor() {
|
|
710
611
|
this.command = "cal";
|
|
@@ -1480,255 +1381,6 @@ var CliEvalCommandProcessor = class {
|
|
|
1480
1381
|
);
|
|
1481
1382
|
}
|
|
1482
1383
|
};
|
|
1483
|
-
var CliHashCommandProcessor = class {
|
|
1484
|
-
constructor() {
|
|
1485
|
-
this.command = "hash";
|
|
1486
|
-
this.description = "Generate hash digests of text";
|
|
1487
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
1488
|
-
this.processors = [];
|
|
1489
|
-
this.metadata = {
|
|
1490
|
-
icon: "#\uFE0F\u20E3",
|
|
1491
|
-
module: "misc"
|
|
1492
|
-
};
|
|
1493
|
-
const algorithms = [
|
|
1494
|
-
{ command: "sha256", algo: "SHA-256", aliases: ["sha-256"] },
|
|
1495
|
-
{ command: "sha1", algo: "SHA-1", aliases: ["sha-1"] },
|
|
1496
|
-
{ command: "sha384", algo: "SHA-384", aliases: ["sha-384"] },
|
|
1497
|
-
{ command: "sha512", algo: "SHA-512", aliases: ["sha-512"] }
|
|
1498
|
-
];
|
|
1499
|
-
this.processors = algorithms.map(({ command: command2, algo, aliases }) => ({
|
|
1500
|
-
command: command2,
|
|
1501
|
-
aliases,
|
|
1502
|
-
description: `Generate ${algo} hash`,
|
|
1503
|
-
acceptsRawInput: true,
|
|
1504
|
-
valueRequired: true,
|
|
1505
|
-
processCommand: async (cmd, context2) => {
|
|
1506
|
-
const text = cmd.value || cmd.data || "";
|
|
1507
|
-
try {
|
|
1508
|
-
const encoded = new TextEncoder().encode(text);
|
|
1509
|
-
const hashBuffer = await crypto.subtle.digest(
|
|
1510
|
-
algo,
|
|
1511
|
-
encoded
|
|
1512
|
-
);
|
|
1513
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
1514
|
-
const hex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1515
|
-
context2.writer.writeln(hex);
|
|
1516
|
-
context2.process.output(hex);
|
|
1517
|
-
} catch {
|
|
1518
|
-
context2.writer.writeError(`Failed to compute ${algo} hash`);
|
|
1519
|
-
context2.process.exit(-1);
|
|
1520
|
-
}
|
|
1521
|
-
},
|
|
1522
|
-
writeDescription: (context2) => {
|
|
1523
|
-
const { writer } = context2;
|
|
1524
|
-
writer.writeln(
|
|
1525
|
-
`Generate a ${algo} hash digest of the input text`
|
|
1526
|
-
);
|
|
1527
|
-
writer.writeln();
|
|
1528
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
1529
|
-
writer.writeln(
|
|
1530
|
-
` ${writer.wrapInColor(`hash ${command2} <text>`, cliCore.CliForegroundColor.Cyan)}`
|
|
1531
|
-
);
|
|
1532
|
-
}
|
|
1533
|
-
}));
|
|
1534
|
-
}
|
|
1535
|
-
async processCommand(command2, context2) {
|
|
1536
|
-
context2.executor.showHelp(command2, context2);
|
|
1537
|
-
}
|
|
1538
|
-
writeDescription(context2) {
|
|
1539
|
-
const { writer, translator: t } = context2;
|
|
1540
|
-
writer.writeln(
|
|
1541
|
-
t.t("cli.hash.long_description", "Generate cryptographic hash digests using the Web Crypto API")
|
|
1542
|
-
);
|
|
1543
|
-
writer.writeln();
|
|
1544
|
-
writer.writeln(`\u{1F4CB} ${t.t("cli.common.usage", "Usage:")}`);
|
|
1545
|
-
writer.writeln(
|
|
1546
|
-
` ${writer.wrapInColor("hash sha256 <text>", cliCore.CliForegroundColor.Cyan)} SHA-256 hash`
|
|
1547
|
-
);
|
|
1548
|
-
writer.writeln(
|
|
1549
|
-
` ${writer.wrapInColor("hash sha1 <text>", cliCore.CliForegroundColor.Cyan)} SHA-1 hash`
|
|
1550
|
-
);
|
|
1551
|
-
writer.writeln(
|
|
1552
|
-
` ${writer.wrapInColor("hash sha384 <text>", cliCore.CliForegroundColor.Cyan)} SHA-384 hash`
|
|
1553
|
-
);
|
|
1554
|
-
writer.writeln(
|
|
1555
|
-
` ${writer.wrapInColor("hash sha512 <text>", cliCore.CliForegroundColor.Cyan)} SHA-512 hash`
|
|
1556
|
-
);
|
|
1557
|
-
writer.writeln();
|
|
1558
|
-
writer.writeln(`\u{1F4DD} ${t.t("cli.common.examples", "Examples:")}`);
|
|
1559
|
-
writer.writeln(
|
|
1560
|
-
` hash sha256 hello ${writer.wrapInColor("# \u2192 2cf24dba5fb0a30e...", cliCore.CliForegroundColor.Green)}`
|
|
1561
|
-
);
|
|
1562
|
-
}
|
|
1563
|
-
};
|
|
1564
|
-
var CliHexCommandProcessor = class {
|
|
1565
|
-
constructor() {
|
|
1566
|
-
this.command = "hex";
|
|
1567
|
-
this.description = "Hex encode/decode and number base conversions";
|
|
1568
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
1569
|
-
this.processors = [];
|
|
1570
|
-
this.metadata = {
|
|
1571
|
-
icon: "0\uFE0F\u20E3",
|
|
1572
|
-
module: "misc"
|
|
1573
|
-
};
|
|
1574
|
-
this.processors = [
|
|
1575
|
-
{
|
|
1576
|
-
command: "encode",
|
|
1577
|
-
aliases: ["enc"],
|
|
1578
|
-
description: "Encode text to hexadecimal",
|
|
1579
|
-
acceptsRawInput: true,
|
|
1580
|
-
valueRequired: true,
|
|
1581
|
-
processCommand: async (command2, context2) => {
|
|
1582
|
-
const text = command2.value || command2.data || "";
|
|
1583
|
-
const hex = Array.from(new TextEncoder().encode(text)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1584
|
-
context2.writer.writeln(hex);
|
|
1585
|
-
context2.process.output(hex);
|
|
1586
|
-
},
|
|
1587
|
-
writeDescription: (context2) => {
|
|
1588
|
-
const { writer } = context2;
|
|
1589
|
-
writer.writeln("Encode text to hexadecimal representation");
|
|
1590
|
-
writer.writeln();
|
|
1591
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
1592
|
-
writer.writeln(
|
|
1593
|
-
` ${writer.wrapInColor("hex encode <text>", cliCore.CliForegroundColor.Cyan)}`
|
|
1594
|
-
);
|
|
1595
|
-
}
|
|
1596
|
-
},
|
|
1597
|
-
{
|
|
1598
|
-
command: "decode",
|
|
1599
|
-
aliases: ["dec"],
|
|
1600
|
-
description: "Decode hexadecimal to text",
|
|
1601
|
-
acceptsRawInput: true,
|
|
1602
|
-
valueRequired: true,
|
|
1603
|
-
processCommand: async (command2, context2) => {
|
|
1604
|
-
const hexStr = command2.value || command2.data || "";
|
|
1605
|
-
try {
|
|
1606
|
-
const bytes = new Uint8Array(
|
|
1607
|
-
(hexStr.match(/.{1,2}/g) || []).map(
|
|
1608
|
-
(byte) => parseInt(byte, 16)
|
|
1609
|
-
)
|
|
1610
|
-
);
|
|
1611
|
-
const text = new TextDecoder().decode(bytes);
|
|
1612
|
-
context2.writer.writeln(text);
|
|
1613
|
-
context2.process.output(text);
|
|
1614
|
-
} catch {
|
|
1615
|
-
context2.writer.writeError("Invalid hex string");
|
|
1616
|
-
context2.process.exit(-1);
|
|
1617
|
-
}
|
|
1618
|
-
},
|
|
1619
|
-
writeDescription: (context2) => {
|
|
1620
|
-
const { writer } = context2;
|
|
1621
|
-
writer.writeln("Decode hexadecimal back to text");
|
|
1622
|
-
writer.writeln();
|
|
1623
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
1624
|
-
writer.writeln(
|
|
1625
|
-
` ${writer.wrapInColor("hex decode <hex>", cliCore.CliForegroundColor.Cyan)}`
|
|
1626
|
-
);
|
|
1627
|
-
}
|
|
1628
|
-
},
|
|
1629
|
-
{
|
|
1630
|
-
command: "convert",
|
|
1631
|
-
aliases: ["conv"],
|
|
1632
|
-
description: "Convert a number between bases",
|
|
1633
|
-
acceptsRawInput: true,
|
|
1634
|
-
valueRequired: true,
|
|
1635
|
-
parameters: [
|
|
1636
|
-
{
|
|
1637
|
-
name: "from",
|
|
1638
|
-
description: "Source base (default: 10)",
|
|
1639
|
-
type: "number",
|
|
1640
|
-
required: false
|
|
1641
|
-
},
|
|
1642
|
-
{
|
|
1643
|
-
name: "to",
|
|
1644
|
-
description: "Target base (default: 16)",
|
|
1645
|
-
type: "number",
|
|
1646
|
-
required: false
|
|
1647
|
-
}
|
|
1648
|
-
],
|
|
1649
|
-
processCommand: async (command2, context2) => {
|
|
1650
|
-
const { writer } = context2;
|
|
1651
|
-
const input = command2.value || "";
|
|
1652
|
-
const fromBase = parseInt(command2.args["from"]) || 10;
|
|
1653
|
-
const toBase = parseInt(command2.args["to"]) || 16;
|
|
1654
|
-
if (fromBase < 2 || fromBase > 36 || toBase < 2 || toBase > 36) {
|
|
1655
|
-
writer.writeError("Base must be between 2 and 36");
|
|
1656
|
-
context2.process.exit(-1);
|
|
1657
|
-
return;
|
|
1658
|
-
}
|
|
1659
|
-
try {
|
|
1660
|
-
const num = parseInt(input, fromBase);
|
|
1661
|
-
if (isNaN(num)) {
|
|
1662
|
-
writer.writeError(
|
|
1663
|
-
`Invalid number for base ${fromBase}`
|
|
1664
|
-
);
|
|
1665
|
-
context2.process.exit(-1);
|
|
1666
|
-
return;
|
|
1667
|
-
}
|
|
1668
|
-
const result = num.toString(toBase);
|
|
1669
|
-
writer.writeln(
|
|
1670
|
-
` ${writer.wrapInColor(`Base ${fromBase}:`, cliCore.CliForegroundColor.Cyan)} ${input}`
|
|
1671
|
-
);
|
|
1672
|
-
writer.writeln(
|
|
1673
|
-
` ${writer.wrapInColor(`Base ${toBase}:`, cliCore.CliForegroundColor.Cyan)} ${result}`
|
|
1674
|
-
);
|
|
1675
|
-
if (fromBase !== 10 && toBase !== 10) {
|
|
1676
|
-
writer.writeln(
|
|
1677
|
-
` ${writer.wrapInColor("Base 10:", cliCore.CliForegroundColor.Cyan)} ${num}`
|
|
1678
|
-
);
|
|
1679
|
-
}
|
|
1680
|
-
context2.process.output(result);
|
|
1681
|
-
} catch {
|
|
1682
|
-
writer.writeError("Conversion failed");
|
|
1683
|
-
context2.process.exit(-1);
|
|
1684
|
-
}
|
|
1685
|
-
},
|
|
1686
|
-
writeDescription: (context2) => {
|
|
1687
|
-
const { writer } = context2;
|
|
1688
|
-
writer.writeln(
|
|
1689
|
-
"Convert a number between different bases (2-36)"
|
|
1690
|
-
);
|
|
1691
|
-
writer.writeln();
|
|
1692
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
1693
|
-
writer.writeln(
|
|
1694
|
-
` ${writer.wrapInColor("hex convert <number> [--from=N] [--to=N]", cliCore.CliForegroundColor.Cyan)}`
|
|
1695
|
-
);
|
|
1696
|
-
writer.writeln();
|
|
1697
|
-
writer.writeln(`\u{1F4DD} ${context2.translator.t("cli.common.examples", "Examples:")}`);
|
|
1698
|
-
writer.writeln(
|
|
1699
|
-
` hex convert 255 ${writer.wrapInColor("# Decimal \u2192 Hex (ff)", cliCore.CliForegroundColor.Green)}`
|
|
1700
|
-
);
|
|
1701
|
-
writer.writeln(
|
|
1702
|
-
` hex convert ff --from=16 --to=2 ${writer.wrapInColor("# Hex \u2192 Binary (11111111)", cliCore.CliForegroundColor.Green)}`
|
|
1703
|
-
);
|
|
1704
|
-
writer.writeln(
|
|
1705
|
-
` hex convert 1010 --from=2 ${writer.wrapInColor("# Binary \u2192 Hex (a)", cliCore.CliForegroundColor.Green)}`
|
|
1706
|
-
);
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
];
|
|
1710
|
-
}
|
|
1711
|
-
async processCommand(command2, context2) {
|
|
1712
|
-
context2.executor.showHelp(command2, context2);
|
|
1713
|
-
}
|
|
1714
|
-
writeDescription(context2) {
|
|
1715
|
-
const { writer, translator: t } = context2;
|
|
1716
|
-
writer.writeln(
|
|
1717
|
-
t.t("cli.hex.long_description", "Hex encode/decode text and convert numbers between bases")
|
|
1718
|
-
);
|
|
1719
|
-
writer.writeln();
|
|
1720
|
-
writer.writeln(`\u{1F4CB} ${t.t("cli.common.usage", "Usage:")}`);
|
|
1721
|
-
writer.writeln(
|
|
1722
|
-
` ${writer.wrapInColor("hex encode <text>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.hex.text_to_hex", "Text to hex")}`
|
|
1723
|
-
);
|
|
1724
|
-
writer.writeln(
|
|
1725
|
-
` ${writer.wrapInColor("hex decode <hex>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.hex.hex_to_text", "Hex to text")}`
|
|
1726
|
-
);
|
|
1727
|
-
writer.writeln(
|
|
1728
|
-
` ${writer.wrapInColor("hex convert <num> [--from --to]", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.hex.base_conversion", "Base conversion")}`
|
|
1729
|
-
);
|
|
1730
|
-
}
|
|
1731
|
-
};
|
|
1732
1384
|
var CliJsonCommandProcessor = class {
|
|
1733
1385
|
constructor() {
|
|
1734
1386
|
this.command = "json";
|
|
@@ -1855,134 +1507,6 @@ var CliJsonCommandProcessor = class {
|
|
|
1855
1507
|
);
|
|
1856
1508
|
}
|
|
1857
1509
|
};
|
|
1858
|
-
var CliJwtCommandProcessor = class {
|
|
1859
|
-
constructor() {
|
|
1860
|
-
this.command = "jwt";
|
|
1861
|
-
this.description = "Decode and inspect JWT tokens";
|
|
1862
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
1863
|
-
this.processors = [];
|
|
1864
|
-
this.metadata = {
|
|
1865
|
-
icon: "\u{1F511}",
|
|
1866
|
-
module: "misc"
|
|
1867
|
-
};
|
|
1868
|
-
this.processors = [
|
|
1869
|
-
{
|
|
1870
|
-
command: "decode",
|
|
1871
|
-
aliases: ["d"],
|
|
1872
|
-
description: "Decode a JWT token",
|
|
1873
|
-
acceptsRawInput: true,
|
|
1874
|
-
valueRequired: true,
|
|
1875
|
-
processCommand: async (command2, context2) => {
|
|
1876
|
-
const token = command2.value || command2.data || "";
|
|
1877
|
-
const { writer } = context2;
|
|
1878
|
-
const parts = token.split(".");
|
|
1879
|
-
if (parts.length !== 3) {
|
|
1880
|
-
writer.writeError(
|
|
1881
|
-
"Invalid JWT token (expected 3 parts separated by dots)"
|
|
1882
|
-
);
|
|
1883
|
-
context2.process.exit(-1);
|
|
1884
|
-
return;
|
|
1885
|
-
}
|
|
1886
|
-
try {
|
|
1887
|
-
const header = JSON.parse(
|
|
1888
|
-
this.base64UrlDecode(parts[0])
|
|
1889
|
-
);
|
|
1890
|
-
const payload = JSON.parse(
|
|
1891
|
-
this.base64UrlDecode(parts[1])
|
|
1892
|
-
);
|
|
1893
|
-
writer.writeln(
|
|
1894
|
-
writer.wrapInColor(
|
|
1895
|
-
"Header:",
|
|
1896
|
-
cliCore.CliForegroundColor.Yellow
|
|
1897
|
-
)
|
|
1898
|
-
);
|
|
1899
|
-
writer.writeln(JSON.stringify(header, null, 2));
|
|
1900
|
-
writer.writeln();
|
|
1901
|
-
writer.writeln(
|
|
1902
|
-
writer.wrapInColor(
|
|
1903
|
-
"Payload:",
|
|
1904
|
-
cliCore.CliForegroundColor.Yellow
|
|
1905
|
-
)
|
|
1906
|
-
);
|
|
1907
|
-
writer.writeln(JSON.stringify(payload, null, 2));
|
|
1908
|
-
writer.writeln();
|
|
1909
|
-
if (payload.exp) {
|
|
1910
|
-
const expDate = new Date(payload.exp * 1e3);
|
|
1911
|
-
const isExpired = expDate.getTime() < Date.now();
|
|
1912
|
-
writer.writeln(
|
|
1913
|
-
`${writer.wrapInColor("Expires:", cliCore.CliForegroundColor.Yellow)} ${expDate.toLocaleString()} ${isExpired ? writer.wrapInColor(
|
|
1914
|
-
"(EXPIRED)",
|
|
1915
|
-
cliCore.CliForegroundColor.Red
|
|
1916
|
-
) : writer.wrapInColor(
|
|
1917
|
-
"(valid)",
|
|
1918
|
-
cliCore.CliForegroundColor.Green
|
|
1919
|
-
)}`
|
|
1920
|
-
);
|
|
1921
|
-
}
|
|
1922
|
-
if (payload.iat) {
|
|
1923
|
-
const iatDate = new Date(payload.iat * 1e3);
|
|
1924
|
-
writer.writeln(
|
|
1925
|
-
`${writer.wrapInColor("Issued:", cliCore.CliForegroundColor.Yellow)} ${iatDate.toLocaleString()}`
|
|
1926
|
-
);
|
|
1927
|
-
}
|
|
1928
|
-
writer.writeln();
|
|
1929
|
-
writer.writeln(
|
|
1930
|
-
writer.wrapInColor(
|
|
1931
|
-
"Signature:",
|
|
1932
|
-
cliCore.CliForegroundColor.Yellow
|
|
1933
|
-
) + ` ${parts[2].substring(0, 20)}...`
|
|
1934
|
-
);
|
|
1935
|
-
context2.process.output({ header, payload });
|
|
1936
|
-
} catch {
|
|
1937
|
-
writer.writeError("Failed to decode JWT token");
|
|
1938
|
-
context2.process.exit(-1);
|
|
1939
|
-
}
|
|
1940
|
-
},
|
|
1941
|
-
writeDescription: (context2) => {
|
|
1942
|
-
const { writer } = context2;
|
|
1943
|
-
writer.writeln(
|
|
1944
|
-
"Decode a JWT token and display its header and payload"
|
|
1945
|
-
);
|
|
1946
|
-
writer.writeln(
|
|
1947
|
-
"Shows expiration status and issue date if present"
|
|
1948
|
-
);
|
|
1949
|
-
writer.writeln();
|
|
1950
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
1951
|
-
writer.writeln(
|
|
1952
|
-
` ${writer.wrapInColor("jwt decode <token>", cliCore.CliForegroundColor.Cyan)}`
|
|
1953
|
-
);
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
];
|
|
1957
|
-
}
|
|
1958
|
-
async processCommand(command2, context2) {
|
|
1959
|
-
context2.executor.showHelp(command2, context2);
|
|
1960
|
-
}
|
|
1961
|
-
writeDescription(context2) {
|
|
1962
|
-
const { writer, translator: t } = context2;
|
|
1963
|
-
writer.writeln(t.t("cli.jwt.long_description", "Decode and inspect JSON Web Tokens (JWT)"));
|
|
1964
|
-
writer.writeln();
|
|
1965
|
-
writer.writeln(`\u{1F4CB} ${t.t("cli.common.usage", "Usage:")}`);
|
|
1966
|
-
writer.writeln(
|
|
1967
|
-
` ${writer.wrapInColor("jwt decode <token>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.jwt.decode_display", "Decode and display JWT contents")}`
|
|
1968
|
-
);
|
|
1969
|
-
writer.writeln();
|
|
1970
|
-
writer.writeln(
|
|
1971
|
-
`\u{1F4DD} ${t.t("cli.jwt.shows", "Shows: header, payload, expiration status, issue date")}`
|
|
1972
|
-
);
|
|
1973
|
-
}
|
|
1974
|
-
base64UrlDecode(str) {
|
|
1975
|
-
str = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
1976
|
-
while (str.length % 4) {
|
|
1977
|
-
str += "=";
|
|
1978
|
-
}
|
|
1979
|
-
return decodeURIComponent(
|
|
1980
|
-
atob(str).split("").map(
|
|
1981
|
-
(c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)
|
|
1982
|
-
).join("")
|
|
1983
|
-
);
|
|
1984
|
-
}
|
|
1985
|
-
};
|
|
1986
1510
|
var LOREM_WORDS = [
|
|
1987
1511
|
"lorem",
|
|
1988
1512
|
"ipsum",
|
|
@@ -3079,137 +2603,6 @@ var CliUptimeCommandProcessor = class {
|
|
|
3079
2603
|
);
|
|
3080
2604
|
}
|
|
3081
2605
|
};
|
|
3082
|
-
var CliUrlCommandProcessor = class {
|
|
3083
|
-
constructor() {
|
|
3084
|
-
this.command = "url";
|
|
3085
|
-
this.description = "Encode or decode URLs";
|
|
3086
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
3087
|
-
this.processors = [];
|
|
3088
|
-
this.metadata = {
|
|
3089
|
-
icon: "\u{1F517}",
|
|
3090
|
-
module: "misc"
|
|
3091
|
-
};
|
|
3092
|
-
this.processors = [
|
|
3093
|
-
{
|
|
3094
|
-
command: "encode",
|
|
3095
|
-
aliases: ["enc"],
|
|
3096
|
-
description: "URL-encode a string",
|
|
3097
|
-
acceptsRawInput: true,
|
|
3098
|
-
valueRequired: true,
|
|
3099
|
-
processCommand: async (command2, context2) => {
|
|
3100
|
-
const text = command2.value || command2.data || "";
|
|
3101
|
-
const encoded = encodeURIComponent(text);
|
|
3102
|
-
context2.writer.writeln(encoded);
|
|
3103
|
-
context2.process.output(encoded);
|
|
3104
|
-
},
|
|
3105
|
-
writeDescription: (context2) => {
|
|
3106
|
-
const { writer } = context2;
|
|
3107
|
-
writer.writeln("URL-encode a string");
|
|
3108
|
-
writer.writeln();
|
|
3109
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
3110
|
-
writer.writeln(
|
|
3111
|
-
` ${writer.wrapInColor("url encode <text>", cliCore.CliForegroundColor.Cyan)}`
|
|
3112
|
-
);
|
|
3113
|
-
writer.writeln();
|
|
3114
|
-
writer.writeln(`\u{1F4DD} ${context2.translator.t("cli.common.examples", "Examples:")}`);
|
|
3115
|
-
writer.writeln(
|
|
3116
|
-
` url encode hello world ${writer.wrapInColor("# \u2192 hello%20world", cliCore.CliForegroundColor.Green)}`
|
|
3117
|
-
);
|
|
3118
|
-
}
|
|
3119
|
-
},
|
|
3120
|
-
{
|
|
3121
|
-
command: "decode",
|
|
3122
|
-
aliases: ["dec"],
|
|
3123
|
-
description: "URL-decode a string",
|
|
3124
|
-
acceptsRawInput: true,
|
|
3125
|
-
valueRequired: true,
|
|
3126
|
-
processCommand: async (command2, context2) => {
|
|
3127
|
-
const text = command2.value || command2.data || "";
|
|
3128
|
-
try {
|
|
3129
|
-
const decoded = decodeURIComponent(text);
|
|
3130
|
-
context2.writer.writeln(decoded);
|
|
3131
|
-
context2.process.output(decoded);
|
|
3132
|
-
} catch {
|
|
3133
|
-
context2.writer.writeError("Invalid URL-encoded string");
|
|
3134
|
-
context2.process.exit(-1);
|
|
3135
|
-
}
|
|
3136
|
-
},
|
|
3137
|
-
writeDescription: (context2) => {
|
|
3138
|
-
const { writer } = context2;
|
|
3139
|
-
writer.writeln("URL-decode a string");
|
|
3140
|
-
writer.writeln();
|
|
3141
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
3142
|
-
writer.writeln(
|
|
3143
|
-
` ${writer.wrapInColor("url decode <text>", cliCore.CliForegroundColor.Cyan)}`
|
|
3144
|
-
);
|
|
3145
|
-
writer.writeln();
|
|
3146
|
-
writer.writeln(`\u{1F4DD} ${context2.translator.t("cli.common.examples", "Examples:")}`);
|
|
3147
|
-
writer.writeln(
|
|
3148
|
-
` url decode hello%20world ${writer.wrapInColor("# \u2192 hello world", cliCore.CliForegroundColor.Green)}`
|
|
3149
|
-
);
|
|
3150
|
-
}
|
|
3151
|
-
},
|
|
3152
|
-
{
|
|
3153
|
-
command: "parse",
|
|
3154
|
-
description: "Parse a URL into its components",
|
|
3155
|
-
acceptsRawInput: true,
|
|
3156
|
-
valueRequired: true,
|
|
3157
|
-
processCommand: async (command2, context2) => {
|
|
3158
|
-
const input = command2.value || command2.data || "";
|
|
3159
|
-
try {
|
|
3160
|
-
const url = new URL(input);
|
|
3161
|
-
const parts = {
|
|
3162
|
-
protocol: url.protocol,
|
|
3163
|
-
hostname: url.hostname,
|
|
3164
|
-
port: url.port || "(default)",
|
|
3165
|
-
pathname: url.pathname,
|
|
3166
|
-
search: url.search || "(none)",
|
|
3167
|
-
hash: url.hash || "(none)",
|
|
3168
|
-
origin: url.origin
|
|
3169
|
-
};
|
|
3170
|
-
const { writer } = context2;
|
|
3171
|
-
Object.entries(parts).forEach(([key, value]) => {
|
|
3172
|
-
writer.writeln(
|
|
3173
|
-
` ${writer.wrapInColor(key.padEnd(12), cliCore.CliForegroundColor.Cyan)} ${value}`
|
|
3174
|
-
);
|
|
3175
|
-
});
|
|
3176
|
-
context2.process.output(parts);
|
|
3177
|
-
} catch {
|
|
3178
|
-
context2.writer.writeError("Invalid URL");
|
|
3179
|
-
context2.process.exit(-1);
|
|
3180
|
-
}
|
|
3181
|
-
},
|
|
3182
|
-
writeDescription: (context2) => {
|
|
3183
|
-
const { writer } = context2;
|
|
3184
|
-
writer.writeln("Parse a URL and display its components");
|
|
3185
|
-
writer.writeln();
|
|
3186
|
-
writer.writeln(`\u{1F4CB} ${context2.translator.t("cli.common.usage", "Usage:")}`);
|
|
3187
|
-
writer.writeln(
|
|
3188
|
-
` ${writer.wrapInColor("url parse <url>", cliCore.CliForegroundColor.Cyan)}`
|
|
3189
|
-
);
|
|
3190
|
-
}
|
|
3191
|
-
}
|
|
3192
|
-
];
|
|
3193
|
-
}
|
|
3194
|
-
async processCommand(command2, context2) {
|
|
3195
|
-
context2.executor.showHelp(command2, context2);
|
|
3196
|
-
}
|
|
3197
|
-
writeDescription(context2) {
|
|
3198
|
-
const { writer, translator: t } = context2;
|
|
3199
|
-
writer.writeln(t.t("cli.url.long_description", "Encode, decode, and parse URLs"));
|
|
3200
|
-
writer.writeln();
|
|
3201
|
-
writer.writeln(`\u{1F4CB} ${t.t("cli.common.usage", "Usage:")}`);
|
|
3202
|
-
writer.writeln(
|
|
3203
|
-
` ${writer.wrapInColor("url encode <text>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.url.encode_desc", "URL-encode a string")}`
|
|
3204
|
-
);
|
|
3205
|
-
writer.writeln(
|
|
3206
|
-
` ${writer.wrapInColor("url decode <text>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.url.decode_desc", "URL-decode a string")}`
|
|
3207
|
-
);
|
|
3208
|
-
writer.writeln(
|
|
3209
|
-
` ${writer.wrapInColor("url parse <url>", cliCore.CliForegroundColor.Cyan)} ${t.t("cli.url.parse_desc", "Parse URL components")}`
|
|
3210
|
-
);
|
|
3211
|
-
}
|
|
3212
|
-
};
|
|
3213
2606
|
var CliYesCommandProcessor = class {
|
|
3214
2607
|
constructor() {
|
|
3215
2608
|
this.command = "yes";
|
|
@@ -10204,21 +9597,16 @@ var miscProcessors = [
|
|
|
10204
9597
|
new CliSleepCommandProcessor(),
|
|
10205
9598
|
new CliUnameCommandProcessor(),
|
|
10206
9599
|
new CliTimeCommandProcessor(),
|
|
10207
|
-
new CliBase64CommandProcessor(),
|
|
10208
9600
|
new CliJsonCommandProcessor(),
|
|
10209
|
-
new CliUrlCommandProcessor(),
|
|
10210
|
-
new CliHashCommandProcessor(),
|
|
10211
9601
|
new CliRandomCommandProcessor(),
|
|
10212
9602
|
new CliUptimeCommandProcessor(),
|
|
10213
9603
|
new CliOpenCommandProcessor(),
|
|
10214
9604
|
new CliLoremCommandProcessor(),
|
|
10215
9605
|
new CliTimestampCommandProcessor(),
|
|
10216
9606
|
new CliColorCommandProcessor(),
|
|
10217
|
-
new CliJwtCommandProcessor(),
|
|
10218
9607
|
new CliCalCommandProcessor(),
|
|
10219
9608
|
new CliSeqCommandProcessor(),
|
|
10220
9609
|
new CliScreenCommandProcessor(),
|
|
10221
|
-
new CliHexCommandProcessor(),
|
|
10222
9610
|
new CliClipboardCommandProcessor(),
|
|
10223
9611
|
new CliConvertCommandProcessor(),
|
|
10224
9612
|
new CliYesCommandProcessor()
|
|
@@ -16109,7 +15497,6 @@ exports.CapturingTerminalWriter = CapturingTerminalWriter;
|
|
|
16109
15497
|
exports.CliAliasCommandProcessor = CliAliasCommandProcessor;
|
|
16110
15498
|
exports.CliArgsParser = CliArgsParser;
|
|
16111
15499
|
exports.CliBackgroundServiceRegistry_TOKEN = CliBackgroundServiceRegistry_TOKEN;
|
|
16112
|
-
exports.CliBase64CommandProcessor = CliBase64CommandProcessor;
|
|
16113
15500
|
exports.CliBoot = CliBoot;
|
|
16114
15501
|
exports.CliCalCommandProcessor = CliCalCommandProcessor;
|
|
16115
15502
|
exports.CliCaptureCommandProcessor = CliCaptureCommandProcessor;
|
|
@@ -16138,14 +15525,11 @@ exports.CliExecutionProcess = CliExecutionProcess;
|
|
|
16138
15525
|
exports.CliExportCommandProcessor = CliExportCommandProcessor;
|
|
16139
15526
|
exports.CliFeedbackCommandProcessor = CliFeedbackCommandProcessor;
|
|
16140
15527
|
exports.CliFontSizeCommandProcessor = CliFontSizeCommandProcessor;
|
|
16141
|
-
exports.CliHashCommandProcessor = CliHashCommandProcessor;
|
|
16142
15528
|
exports.CliHelpCommandProcessor = CliHelpCommandProcessor;
|
|
16143
|
-
exports.CliHexCommandProcessor = CliHexCommandProcessor;
|
|
16144
15529
|
exports.CliHistoryCommandProcessor = CliHistoryCommandProcessor;
|
|
16145
15530
|
exports.CliHotKeysCommandProcessor = CliHotKeysCommandProcessor;
|
|
16146
15531
|
exports.CliInputReader = CliInputReader;
|
|
16147
15532
|
exports.CliJsonCommandProcessor = CliJsonCommandProcessor;
|
|
16148
|
-
exports.CliJwtCommandProcessor = CliJwtCommandProcessor;
|
|
16149
15533
|
exports.CliKeyValueStore = CliKeyValueStore;
|
|
16150
15534
|
exports.CliKillCommandProcessor = CliKillCommandProcessor;
|
|
16151
15535
|
exports.CliLogger = CliLogger;
|
|
@@ -16190,7 +15574,6 @@ exports.CliUnAliasCommandProcessor = CliUnAliasCommandProcessor;
|
|
|
16190
15574
|
exports.CliUnameCommandProcessor = CliUnameCommandProcessor;
|
|
16191
15575
|
exports.CliUnsetCommandProcessor = CliUnsetCommandProcessor;
|
|
16192
15576
|
exports.CliUptimeCommandProcessor = CliUptimeCommandProcessor;
|
|
16193
|
-
exports.CliUrlCommandProcessor = CliUrlCommandProcessor;
|
|
16194
15577
|
exports.CliVersionCommandProcessor = CliVersionCommandProcessor;
|
|
16195
15578
|
exports.CliYesCommandProcessor = CliYesCommandProcessor;
|
|
16196
15579
|
exports.CommandParser = CommandParser;
|