fix: survey url incorrect in single use share dialoge (#1464)

This commit is contained in:
Matti Nannt
2023-10-25 22:35:52 +02:00
committed by GitHub
parent e9f4edadbd
commit cb130579bb
2 changed files with 4 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ export default function LinkSingleUseSurveyModal({ survey, surveyBaseUrl }: Link
return await Promise.all(promises);
};
const defaultSurveyUrl = `${surveyBaseUrl}/${survey.id}`;
const defaultSurveyUrl = `${surveyBaseUrl}/s/${survey.id}`;
const [selectedSingleUseIds, setSelectedSingleIds] = useState<number[]>([]);
const linkTextRef = useRef<HTMLDivElement>(null);

View File

@@ -5,6 +5,7 @@ import { ENCRYPTION_KEY } from "./constants";
const ALGORITHM = "aes256";
const INPUT_ENCODING = "utf8";
const OUTPUT_ENCODING = "hex";
const BUFFER_ENCODING = ENCRYPTION_KEY.length === 32 ? "latin1" : "hex";
const IV_LENGTH = 16; // AES blocksize
/**
@@ -15,7 +16,7 @@ const IV_LENGTH = 16; // AES blocksize
* @returns Encrypted value using key
*/
export const symmetricEncrypt = function (text: string, key: string) {
const _key = Buffer.from(key, "latin1");
const _key = Buffer.from(key, BUFFER_ENCODING);
const iv = crypto.randomBytes(IV_LENGTH);
const cipher = crypto.createCipheriv(ALGORITHM, _key, iv);
@@ -32,7 +33,7 @@ export const symmetricEncrypt = function (text: string, key: string) {
* @param key Key used to decrypt value must be 32 bytes for AES256 encryption algorithm
*/
export const symmetricDecrypt = function (text: string, key: string) {
const _key = Buffer.from(key, "latin1");
const _key = Buffer.from(key, BUFFER_ENCODING);
const components = text.split(":");
const iv_from_ciphertext = Buffer.from(components.shift() || "", OUTPUT_ENCODING);