mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 15:27:46 +00:00
fix: improve UI and lint fix
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
import { randomUUID } from "crypto";
|
import { randomUUID } from "crypto";
|
||||||
import { codec, hash } from "sjcl";
|
import sjcl from "sjcl";
|
||||||
import { secretbox } from "tweetnacl";
|
import tweetnacl from "tweetnacl";
|
||||||
import { decodeBase64, encodeUTF8 } from "tweetnacl-util";
|
import tweetnaclUtil from "tweetnacl-util";
|
||||||
|
|
||||||
import { InfisicalImportData, TEnvKeyExportJSON } from "./external-migration-types";
|
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 }) => {
|
export const decryptEnvKeyData = async (decryptionKey: string, encryptedJson: { nonce: string; data: string }) => {
|
||||||
const key = decodeBase64(codec.base64.fromBits(hash.sha256.hash(decryptionKey)));
|
const key = tweetnaclUtil.decodeBase64(codec.base64.fromBits(hash.sha256.hash(decryptionKey)));
|
||||||
const nonce = decodeBase64(encryptedJson.nonce);
|
const nonce = tweetnaclUtil.decodeBase64(encryptedJson.nonce);
|
||||||
const encryptedData = decodeBase64(encryptedJson.data);
|
const encryptedData = tweetnaclUtil.decodeBase64(encryptedJson.data);
|
||||||
|
|
||||||
const decrypted = secretbox.open(encryptedData, nonce, key);
|
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");
|
throw new Error("Decryption failed, please check the entered encryption key");
|
||||||
}
|
}
|
||||||
|
|
||||||
const decryptedJson = encodeUTF8(decrypted);
|
const decryptedJson = tweetnaclUtil.encodeUTF8(decrypted);
|
||||||
return decryptedJson;
|
return decryptedJson;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -189,8 +189,17 @@ export const ImportTab = () => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
fileUploadRef?.current?.click();
|
fileUploadRef?.current?.click();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{fileUploadRef?.current?.value ? (
|
||||||
|
<span className="text-green text-sm">
|
||||||
|
{fileUploadRef?.current?.value.split("\\").pop()}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
Upload export file
|
||||||
<FontAwesomeIcon icon={faUpload} size="xs" />
|
<FontAwesomeIcon icon={faUpload} size="xs" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</>
|
</>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user