mc8yp 2.8.2 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-B3clXbA3.mjs → add-Sf15gY0D.mjs} +97 -6
- package/dist/cli.mjs +37376 -37082
- package/dist/{creds-CgE3Umno.mjs → creds-DXlyJw6X.mjs} +5 -5
- package/dist/{list-DGPagAtJ.mjs → list-Cr6LlrRt.mjs} +5 -2
- package/dist/{remove-C6FCjW31.mjs → remove-DeJzuKJK.mjs} +1 -1
- package/dist/{undici-C4eXkUym.mjs → undici-I2uXV0WL.mjs} +1 -1
- package/package.json +1 -1
- package/dist/rolldown-runtime-CMFfr-1z.mjs +0 -26
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as parse, c as url, i as setStoredC8yAuth, l as consola, o as pipe, r as getStoredC8yAuth, s as string, t as cleanTenantUrl, u as defineCommand } from "./cli.mjs";
|
|
1
|
+
import { a as requestTfaSession, c as pipe, d as consola, f as defineCommand, i as getStoredC8yAuth, l as string, m as __commonJSMin, n as cleanTenantUrl, o as setStoredC8yAuth, s as parse, t as TfaRequiredError, u as url } from "./cli.mjs";
|
|
3
2
|
import process$1, { exit, stdin, stdout } from "node:process";
|
|
4
3
|
import { styleText } from "node:util";
|
|
5
4
|
import "node:path";
|
|
@@ -637,6 +636,28 @@ let u$1 = class u extends y {
|
|
|
637
636
|
});
|
|
638
637
|
}
|
|
639
638
|
};
|
|
639
|
+
var n = class extends y {
|
|
640
|
+
get userInputWithCursor() {
|
|
641
|
+
if (this.state === "submit") return this.userInput;
|
|
642
|
+
const t = this.userInput;
|
|
643
|
+
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
644
|
+
const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
|
|
645
|
+
return `${r}${styleText("inverse", s)}${e}`;
|
|
646
|
+
}
|
|
647
|
+
get cursor() {
|
|
648
|
+
return this._cursor;
|
|
649
|
+
}
|
|
650
|
+
constructor(t) {
|
|
651
|
+
super({
|
|
652
|
+
...t,
|
|
653
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
654
|
+
}), this.on("userInput", (r) => {
|
|
655
|
+
this._setValue(r);
|
|
656
|
+
}), this.on("finalize", () => {
|
|
657
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
};
|
|
640
661
|
//#endregion
|
|
641
662
|
//#region node_modules/.pnpm/@clack+prompts@1.8.0/node_modules/@clack/prompts/dist/index.mjs
|
|
642
663
|
function isUnicodeSupported() {
|
|
@@ -698,6 +719,47 @@ ${e ? styleText("cyan", S_BAR_END) : ""}
|
|
|
698
719
|
}).prompt();
|
|
699
720
|
`${styleText("dim", "↑/↓")}`, `${styleText("dim", "Enter:")}`;
|
|
700
721
|
`${styleText("gray", S_BAR)}`;
|
|
722
|
+
const text = (t) => new n({
|
|
723
|
+
validate: t.validate,
|
|
724
|
+
placeholder: t.placeholder,
|
|
725
|
+
defaultValue: t.defaultValue,
|
|
726
|
+
initialValue: t.initialValue,
|
|
727
|
+
output: t.output,
|
|
728
|
+
signal: t.signal,
|
|
729
|
+
input: t.input,
|
|
730
|
+
render() {
|
|
731
|
+
const r = t?.withGuide ?? settings.withGuide, l = `${`${r ? `${styleText("gray", S_BAR)}
|
|
732
|
+
` : ""}${symbol(this.state)} `}${t.message}
|
|
733
|
+
`, d = t.placeholder && t.placeholder.length > 0 ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
|
|
734
|
+
switch (this.state) {
|
|
735
|
+
case "validating": {
|
|
736
|
+
const n = r ? `${styleText("cyan", S_BAR)} ` : "", i = r ? styleText("cyan", S_BAR_END) : "";
|
|
737
|
+
return `${l}${n}${styleText("dim", o)}
|
|
738
|
+
${i} ${styleText("dim", "Validating...")}
|
|
739
|
+
`;
|
|
740
|
+
}
|
|
741
|
+
case "error": {
|
|
742
|
+
const n = this.error ? ` ${styleText("yellow", this.error)}` : "", i = r ? `${styleText("yellow", S_BAR)} ` : "", c = r ? styleText("yellow", S_BAR_END) : "";
|
|
743
|
+
return `${l.trim()}
|
|
744
|
+
${i}${o}
|
|
745
|
+
${c}${n}
|
|
746
|
+
`;
|
|
747
|
+
}
|
|
748
|
+
case "submit": {
|
|
749
|
+
const n = s ? `${r ? " " : ""}${styleText("dim", s)}` : "";
|
|
750
|
+
return `${l}${r ? styleText("gray", S_BAR) : ""}${n}`;
|
|
751
|
+
}
|
|
752
|
+
case "cancel": {
|
|
753
|
+
const n = s ? ` ${styleText(["strikethrough", "dim"], s)}` : "", i = r ? styleText("gray", S_BAR) : "";
|
|
754
|
+
return `${l}${i}${n}${s.trim() ? `
|
|
755
|
+
${i}` : ""}`;
|
|
756
|
+
}
|
|
757
|
+
default: return `${l}${r ? `${styleText("cyan", S_BAR)} ` : ""}${o}
|
|
758
|
+
${r ? styleText("cyan", S_BAR_END) : ""}
|
|
759
|
+
`;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}).prompt();
|
|
701
763
|
//#endregion
|
|
702
764
|
//#region src/cli/subcommands/subcommands/add.ts
|
|
703
765
|
const command = defineCommand({
|
|
@@ -712,6 +774,12 @@ const command = defineCommand({
|
|
|
712
774
|
cancel: "reject"
|
|
713
775
|
});
|
|
714
776
|
parse(pipe(string(), url()), tenantUrl);
|
|
777
|
+
const { protocol, hostname } = new URL(tenantUrl);
|
|
778
|
+
if (protocol === "http:" && ![
|
|
779
|
+
"localhost",
|
|
780
|
+
"127.0.0.1",
|
|
781
|
+
"[::1]"
|
|
782
|
+
].includes(hostname)) consola.warn(`${tenantUrl} uses plain http — your password (and TFA code) would be sent unencrypted. Use https unless this is a trusted local setup.`);
|
|
715
783
|
const user = await consola.prompt("Username:", {
|
|
716
784
|
type: "text",
|
|
717
785
|
cancel: "reject"
|
|
@@ -737,15 +805,38 @@ const command = defineCommand({
|
|
|
737
805
|
exit();
|
|
738
806
|
}
|
|
739
807
|
}
|
|
740
|
-
|
|
741
|
-
tenantUrl,
|
|
808
|
+
const creds = {
|
|
809
|
+
tenantUrl: cleanTenantUrl(tenantUrl),
|
|
742
810
|
user,
|
|
743
811
|
password: passwordPrompt
|
|
812
|
+
};
|
|
813
|
+
try {
|
|
814
|
+
await setStoredC8yAuth(creds);
|
|
815
|
+
consola.success("Credentials saved successfully!");
|
|
816
|
+
exit();
|
|
817
|
+
return;
|
|
818
|
+
} catch (error) {
|
|
819
|
+
if (!(error instanceof TfaRequiredError)) throw error;
|
|
820
|
+
}
|
|
821
|
+
consola.info("Two-factor authentication is enabled for this user.");
|
|
822
|
+
const tfaCode = await text({
|
|
823
|
+
message: "TFA code from your authenticator app:",
|
|
824
|
+
validate: (value) => /^\s*\d{6,8}\s*$/.test(value ?? "") ? void 0 : "Enter the 6-digit code."
|
|
825
|
+
});
|
|
826
|
+
if (isCancel(tfaCode)) {
|
|
827
|
+
cancel("Cancelled.");
|
|
828
|
+
exit();
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
const tfaSession = await requestTfaSession(creds, tfaCode);
|
|
832
|
+
await setStoredC8yAuth({
|
|
833
|
+
...creds,
|
|
834
|
+
tfaSession
|
|
744
835
|
});
|
|
745
|
-
consola.success(
|
|
836
|
+
consola.success(`Credentials saved successfully! TFA session valid until ${new Date(tfaSession.expiresAt).toLocaleString()}.`);
|
|
746
837
|
exit();
|
|
747
838
|
} catch (error) {
|
|
748
|
-
consola.error(
|
|
839
|
+
consola.error(`Failed to add credentials: ${error instanceof Error ? error.message : String(error)}`);
|
|
749
840
|
exit();
|
|
750
841
|
}
|
|
751
842
|
}
|