A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
587 B

import { EncryptionService } from "../service/EncryptionService";
import { ChatMessageDTO } from "../dto/ChatMessageDTO";
import * as log from "loglevel";
import { getOneMessage } from "./messages";
export async function isPassphraseValid(
passphrase: string,
userName: string,
es: EncryptionService
): Promise<boolean> {
const messages: ChatMessageDTO[] = await getOneMessage(userName, 0);
if (messages.length === 0) return true;
try {
es.decrypt(passphrase, messages[0].messageCipher);
} catch (error) {
log.debug("here");
return false;
}
return true;
}