mc8yp 2.8.2 → 2.8.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/dist/{add-B3clXbA3.mjs → add-Bt0fMQY3.mjs} +91 -6
- package/dist/cli.mjs +37360 -37149
- package/dist/{creds-CgE3Umno.mjs → creds-BQypJsxt.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({
|
|
@@ -737,15 +799,38 @@ const command = defineCommand({
|
|
|
737
799
|
exit();
|
|
738
800
|
}
|
|
739
801
|
}
|
|
740
|
-
|
|
741
|
-
tenantUrl,
|
|
802
|
+
const creds = {
|
|
803
|
+
tenantUrl: cleanTenantUrl(tenantUrl),
|
|
742
804
|
user,
|
|
743
805
|
password: passwordPrompt
|
|
806
|
+
};
|
|
807
|
+
try {
|
|
808
|
+
await setStoredC8yAuth(creds);
|
|
809
|
+
consola.success("Credentials saved successfully!");
|
|
810
|
+
exit();
|
|
811
|
+
return;
|
|
812
|
+
} catch (error) {
|
|
813
|
+
if (!(error instanceof TfaRequiredError)) throw error;
|
|
814
|
+
}
|
|
815
|
+
consola.info("Two-factor authentication is enabled for this user.");
|
|
816
|
+
const tfaCode = await text({
|
|
817
|
+
message: "TFA code from your authenticator app:",
|
|
818
|
+
validate: (value) => /^\s*\d{6,8}\s*$/.test(value ?? "") ? void 0 : "Enter the 6-digit code."
|
|
819
|
+
});
|
|
820
|
+
if (isCancel(tfaCode)) {
|
|
821
|
+
cancel("Cancelled.");
|
|
822
|
+
exit();
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const tfaSession = await requestTfaSession(creds, tfaCode);
|
|
826
|
+
await setStoredC8yAuth({
|
|
827
|
+
...creds,
|
|
828
|
+
tfaSession
|
|
744
829
|
});
|
|
745
|
-
consola.success(
|
|
830
|
+
consola.success(`Credentials saved successfully! TFA session valid until ${new Date(tfaSession.expiresAt).toLocaleString()}.`);
|
|
746
831
|
exit();
|
|
747
832
|
} catch (error) {
|
|
748
|
-
consola.error(
|
|
833
|
+
consola.error(`Failed to add credentials: ${error instanceof Error ? error.message : String(error)}`);
|
|
749
834
|
exit();
|
|
750
835
|
}
|
|
751
836
|
}
|