Added commenting functionality (#135)

This commit is contained in:
Vladyslav Matsiiako
2022-12-26 21:28:55 -05:00
parent ab3f3600e5
commit f3e3a9edf1
10 changed files with 172 additions and 62 deletions
@@ -65,6 +65,16 @@ const pushKeys = async({ obj, workspaceId, env }: { obj: object; workspaceId: st
key: randomBytes,
});
// encrypt comment
const {
ciphertext: ciphertextComment,
iv: ivComment,
tag: tagComment,
} = encryptSymmetric({
plaintext: obj[key as keyof typeof obj][1],
key: randomBytes,
});
const visibility = key.charAt(0) == "p" ? "personal" : "shared";
return {
@@ -76,6 +86,10 @@ const pushKeys = async({ obj, workspaceId, env }: { obj: object; workspaceId: st
ivValue,
tagValue,
hashValue: crypto.createHash("sha256").update(obj[key as keyof typeof obj][0]).digest("hex"),
ciphertextComment,
ivComment,
tagComment,
hashComment: crypto.createHash("sha256").update(obj[key as keyof typeof obj][1]).digest("hex"),
type: visibility,
};
});