Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ppk download #30

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/settings/privacySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Dialog, Transition } from "@headlessui/react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faLock, faCircleNotch } from "@fortawesome/free-solid-svg-icons";
import toast from "react-hot-toast";
import { decryptAuthPM } from "solun-general-package";

const PublicKeyModal = ({ isOpen, onClose, onDownload }: any) => (
<Transition show={isOpen} as={Fragment}>
Expand Down Expand Up @@ -223,17 +224,20 @@ function PrivacySettings({ userDetails, userInfo }: any) {

const downloadPrivateKey = async () => {
if (await validatePassword()) {
const key = userInfo.private_key; // Get from JWT
const key = userDetails.private_key;
// Encrypt private key with password
const decryptedKey = decryptAuthPM(key, password);
setIsPrivateKeyOpen(false);

const element = document.createElement("a");
const file = new Blob([key], { type: "text/plain" });
const file = new Blob([decryptedKey], { type: "text/plain" });
element.href = URL.createObjectURL(file);
element.download = "privatekey." + userInfo.fqe + ".asc";
document.body.appendChild(element);
element.click();

toast.success("Private key downloaded successfully.");
setPassword("");

setTimeout(function () {
document.body.removeChild(element);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solun-auth",
"version": "0.1.26",
"version": "0.1.27",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down