mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-04 18:49:39 -06:00
* add uniqueResponseId to link survey * add uniqueResponseId to survey response * add singUseId to database and link survey * add singleUseId to api * add single use option in survey response options * add single use to getSurvey * add getResponseBySingleUseId * add ZSurveySingleUse schema to survey schema * add logic to check if link with suid has response * pass singleUseId as props, revert SWR changes * generation of single-use url in LinkSurveyModal * add singleUseId to SingleResponseCard * update SurveyInactive for invalid link * add suId to ZResponse schema * fix typo in SurveyInactive * update ResponseOptionCard * add suId to response select * add default message for SurveyLinkUsed * update logic to render SurveyLinkUsed * add comment for suId in prisma schema * fix types * refresh server component on save survey * update logic * fix build errors * fix prisma schema * add db migration * update wording * add singleUseId to localstorage * fix survey link used over thank you * add suid to people responses * fix preview and copy link on surveys page. * update text and icon for link survey modal * check survey not finished before setting question * update show surveylink used logic * add zodtype to prisma * fix logic to render last question answered/stored * add better comments * update default message for single use surveys * add LinkSingleUseSurveyModal * add guard before getting response with suid * fix build error * add default message for link used page * add key and group imports * add suId encryption and validation * make survey url encryption optional * fix build errors * move singleUseId to server side in surveyList * added validation to getResponseBySingleUseId service * restored env var names * import FORMBRICKS_ENCRYPTION_KEY from constants * check if encryption environment variable is set, add length validation for env variable --------- Co-authored-by: Ty Kerr <tykerr@Tys-MacBook-Pro.local> Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com> Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
19 lines
821 B
TypeScript
19 lines
821 B
TypeScript
import { createHash, createCipheriv, createDecipheriv } from "crypto";
|
|
|
|
export const getHash = (key: string): string => createHash("sha256").update(key).digest("hex");
|
|
|
|
// create an aes128 encryption function
|
|
export const encryptAES128 = (encryptionKey: string, data: string): string => {
|
|
const cipher = createCipheriv("aes-128-ecb", Buffer.from(encryptionKey, "base64"), "");
|
|
let encrypted = cipher.update(data, "utf-8", "hex");
|
|
encrypted += cipher.final("hex");
|
|
return encrypted;
|
|
};
|
|
// create an aes128 decryption function
|
|
export const decryptAES128 = (encryptionKey: string, data: string): string => {
|
|
const cipher = createDecipheriv("aes-128-ecb", Buffer.from(encryptionKey, "base64"), "");
|
|
let decrypted = cipher.update(data, "hex", "utf-8");
|
|
decrypted += cipher.final("utf-8");
|
|
return decrypted;
|
|
};
|