fix: improve UI and lint fix

This commit is contained in:
Meet
2024-09-27 03:13:33 +05:30
parent 54e4314e88
commit b0e536e576
2 changed files with 20 additions and 8 deletions

View File

@@ -1,14 +1,17 @@
import { randomUUID } from "crypto";
import { codec, hash } from "sjcl";
import { secretbox } from "tweetnacl";
import { decodeBase64, encodeUTF8 } from "tweetnacl-util";
import sjcl from "sjcl";
import tweetnacl from "tweetnacl";
import tweetnaclUtil from "tweetnacl-util";
import { InfisicalImportData, TEnvKeyExportJSON } from "./external-migration-types";
const { codec, hash } = sjcl;
const { secretbox } = tweetnacl;
export const decryptEnvKeyData = async (decryptionKey: string, encryptedJson: { nonce: string; data: string }) => {
const key = decodeBase64(codec.base64.fromBits(hash.sha256.hash(decryptionKey)));
const nonce = decodeBase64(encryptedJson.nonce);
const encryptedData = decodeBase64(encryptedJson.data);
const key = tweetnaclUtil.decodeBase64(codec.base64.fromBits(hash.sha256.hash(decryptionKey)));
const nonce = tweetnaclUtil.decodeBase64(encryptedJson.nonce);
const encryptedData = tweetnaclUtil.decodeBase64(encryptedJson.data);
const decrypted = secretbox.open(encryptedData, nonce, key);
@@ -16,7 +19,7 @@ export const decryptEnvKeyData = async (decryptionKey: string, encryptedJson: {
throw new Error("Decryption failed, please check the entered encryption key");
}
const decryptedJson = encodeUTF8(decrypted);
const decryptedJson = tweetnaclUtil.encodeUTF8(decrypted);
return decryptedJson;
};

View File

@@ -189,8 +189,17 @@ export const ImportTab = () => {
onClick={() => {
fileUploadRef?.current?.click();
}}
>
>
{fileUploadRef?.current?.value ? (
<span className="text-green text-sm">
{fileUploadRef?.current?.value.split("\\").pop()}
</span>
) : (
<>
Upload export file&nbsp;
<FontAwesomeIcon icon={faUpload} size="xs" />
</>
)}
</IconButton>
</>
</FormControl>