Reimplemented outdated code, added encryption keys for each room, added support for profile images, added friend requests via url/qr-code
This commit is contained in:
1 parent
508f17315e
commit
32e4bf8b32
58 files changed
+3270
-362
No files matched your search
@@ -1,44 +1,7 @@
|
||||
"use server";
|
||||
import { subtle } from "crypto";
|
||||
import { createClient } from "@/utils/supabase/server";
|
||||
import { deriveKey } from "./encryption";
|
||||
import { retreiveAccessKey_Cookie } from "./access_storage";
|
||||
|
||||
export async function setAccessKey(plain_pw: string) {
|
||||
const supabase = await createClient();
|
||||
const { data: key_data, error } = await supabase
|
||||
.from("users")
|
||||
.select("private_key_enc, salt, iv, auth_tag")
|
||||
.eq("id", (await supabase.auth.getUser()).data.user?.id)
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
return null;
|
||||
}
|
||||
const salt_Base64 = key_data?.salt || "";
|
||||
const encryptedPrivateKey_Base64 = key_data?.private_key_enc || "";
|
||||
const authTag_base64 = key_data?.auth_tag || "";
|
||||
|
||||
const encodedPrivateKey = Uint8Array.from(
|
||||
atob(encryptedPrivateKey_Base64),
|
||||
(c) => c.charCodeAt(0),
|
||||
);
|
||||
const authTag = Uint8Array.from(atob(authTag_base64), (c) => c.charCodeAt(0));
|
||||
const salt = Uint8Array.from(atob(salt_Base64), (c) => c.charCodeAt(0));
|
||||
|
||||
const dataWithAuthTag = new Uint8Array(
|
||||
encodedPrivateKey.length + authTag.length,
|
||||
);
|
||||
dataWithAuthTag.set(encodedPrivateKey, 0);
|
||||
dataWithAuthTag.set(authTag, encodedPrivateKey.length);
|
||||
|
||||
const key = await deriveKey(plain_pw, salt);
|
||||
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
import { retrieveAccessKey_Cookie } from "./access_storage";
|
||||
|
||||
export async function decryptPrivateKey() {
|
||||
const supabase = await createClient();
|
||||
@@ -68,7 +31,7 @@ export async function decryptPrivateKey() {
|
||||
dataWithAuthTag.set(encodedPrivateKey, 0);
|
||||
dataWithAuthTag.set(authTag, encodedPrivateKey.length);
|
||||
|
||||
const key = await retreiveAccessKey_Cookie();
|
||||
const key = await retrieveAccessKey_Cookie();
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user