feat: SSH key generator save-to-file buttons
Some checks failed
Build & Sign Wraith / Build Windows + Sign (push) Failing after 6s
Some checks failed
Build & Sign Wraith / Build Windows + Sign (push) Failing after 6s
Save Private Key and Save Public Key buttons download the generated keys as id_ed25519/id_rsa (private) and .pub (public) files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
248381e4ce
commit
6b5fad2289
@ -36,9 +36,13 @@
|
|||||||
<textarea readonly :value="key.privateKey" rows="8" class="w-full px-3 py-2 text-xs font-mono rounded bg-[#161b22] border border-[#30363d] text-[#e0e0e0] resize-none" />
|
<textarea readonly :value="key.privateKey" rows="8" class="w-full px-3 py-2 text-xs font-mono rounded bg-[#161b22] border border-[#30363d] text-[#e0e0e0] resize-none" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
<div class="text-xs text-[#8b949e]">
|
<div class="text-xs text-[#8b949e]">
|
||||||
Fingerprint: <span class="font-mono text-[#e0e0e0]">{{ key.fingerprint }}</span>
|
Fingerprint: <span class="font-mono text-[#e0e0e0]">{{ key.fingerprint }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<button class="px-3 py-1 text-xs rounded bg-[#58a6ff] text-black font-bold cursor-pointer" @click="savePrivateKey">Save Private Key</button>
|
||||||
|
<button class="px-3 py-1 text-xs rounded border border-[#30363d] text-[#8b949e] hover:text-white cursor-pointer" @click="savePublicKey">Save Public Key</button>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -62,4 +66,26 @@ async function generate(): Promise<void> {
|
|||||||
function copy(text: string): void {
|
function copy(text: string): void {
|
||||||
navigator.clipboard.writeText(text).catch(() => {});
|
navigator.clipboard.writeText(text).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveFile(content: string, filename: string): void {
|
||||||
|
const blob = new Blob([content], { type: "text/plain" });
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = URL.createObjectURL(blob);
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(a.href);
|
||||||
|
}
|
||||||
|
|
||||||
|
function savePrivateKey(): void {
|
||||||
|
if (!key.value) return;
|
||||||
|
const name = comment.value || "wraith_key";
|
||||||
|
const ext = key.value.keyType === "ed25519" ? "id_ed25519" : "id_rsa";
|
||||||
|
saveFile(key.value.privateKey, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
function savePublicKey(): void {
|
||||||
|
if (!key.value) return;
|
||||||
|
const ext = key.value.keyType === "ed25519" ? "id_ed25519.pub" : "id_rsa.pub";
|
||||||
|
saveFile(key.value.publicKey, ext);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user