diff --git a/backend/src/services/external-migration/external-migration-fns.ts b/backend/src/services/external-migration/external-migration-fns.ts index 1e5b2cde1..9d12f5767 100644 --- a/backend/src/services/external-migration/external-migration-fns.ts +++ b/backend/src/services/external-migration/external-migration-fns.ts @@ -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; }; diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/ImportTab/ImportTab.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/ImportTab/ImportTab.tsx index b6dae5128..7f9dd056a 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/ImportTab/ImportTab.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/ImportTab/ImportTab.tsx @@ -189,8 +189,17 @@ export const ImportTab = () => { onClick={() => { fileUploadRef?.current?.click(); }} - > + > + {fileUploadRef?.current?.value ? ( + + {fileUploadRef?.current?.value.split("\\").pop()} + + ) : ( + <> + Upload export file  + + )}