This commit is contained in:
Manav Rathi
2024-08-19 11:59:26 +05:30
parent c0e48c7ada
commit c39fcb3968

View File

@@ -1,4 +1,9 @@
import { decryptBlob, decryptBoxB64 } from "@/base/crypto";
import {
decryptBlob,
decryptBoxB64,
encryptBoxB64,
generateBoxKey,
} from "@/base/crypto";
import { authenticatedRequestHeaders, ensureOk, HTTPError } from "@/base/http";
import { getKV, getKVN, setKV } from "@/base/kv";
import { apiURL } from "@/base/origins";
@@ -229,6 +234,13 @@ const saveRemoteUserEntityKey = (
entityKey: RemoteUserEntityKey,
) => setKV(entityKeyKey(type), JSON.stringify(entityKey));
/**
* Generate a new entity key and return it after encrypting it using the user's
* master key.
*/
const generateEncryptedEntityKey = async () =>
encryptBoxB64(await generateBoxKey(), await masterKeyFromSession());
/**
* Decrypt an encrypted entity key using the user's master key.
*/