From 0ed92fdc170e21a360ce691069c90e0c0243e166 Mon Sep 17 00:00:00 2001 From: Inbestigator Date: Sat, 2 Mar 2024 03:17:57 -0800 Subject: [PATCH] Raised key size and added creategroup button --- src/plugins/encryptcord/index.tsx | 19 ++++++++++++++++--- src/plugins/encryptcord/rsa-utils.tsx | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/plugins/encryptcord/index.tsx b/src/plugins/encryptcord/index.tsx index cca5e2e6a..2ef5096a7 100644 --- a/src/plugins/encryptcord/index.tsx +++ b/src/plugins/encryptcord/index.tsx @@ -26,7 +26,6 @@ import { Message } from "discord-types/general"; const MessageCreator = findByPropsLazy("createBotMessage"); const CloudUtils = findByPropsLazy("CloudUpload"); import { getCurrentChannel } from "@utils/discord"; -import forge from 'node-forge'; let enabled; let setEnabled; @@ -83,7 +82,17 @@ const ChatBarIcon: ChatBarButton = ({ isMainChat }) => { if (await DataStore.get('encryptcordGroup') == false) { await startGroup("", { channel: { id: getCurrentChannel().id } }); } else if (getCurrentChannel().id !== groupChannel) { - sendBotMessage(getCurrentChannel().id, { content: `You must be in <#${groupChannel}> to send an encrypted message!`, author: { username: "false" } }); + sendBotMessage(getCurrentChannel().id, { + content: `You are already in an encrypted group in <#${groupChannel}>.\n> Would you like to create a new one?`, components: [{ + type: 1, + components: [{ + type: 2, + style: 3, + label: 'Yes', + custom_id: 'createGroup' + }] + }] + }); return; } setEnabled(!enabled); @@ -136,7 +145,7 @@ export default definePlugin({ ], async joinGroup(interaction) { const sender = await UserUtils.getUser(interaction.application_id).catch(() => null); - if (!sender || sender.bot == true) return; + if (!sender || (sender.bot == true && sender.id != "1")) return; if (interaction.data.component_type != 2) return; switch (interaction.data.custom_id) { case "acceptGroup": @@ -158,6 +167,10 @@ export default definePlugin({ mlDeleted: true }); break; + case "createGroup": + await leave("", { channel: { id: interaction.channel_id } }); + await startGroup("", { channel: { id: interaction.channel_id } }); + break; default: return; } diff --git a/src/plugins/encryptcord/rsa-utils.tsx b/src/plugins/encryptcord/rsa-utils.tsx index 9d06256ba..219d76d67 100644 --- a/src/plugins/encryptcord/rsa-utils.tsx +++ b/src/plugins/encryptcord/rsa-utils.tsx @@ -2,7 +2,7 @@ export const generateKeys = async () => { const keyPair = await crypto.subtle.generateKey( { name: "RSA-OAEP", - modulusLength: 2048, + modulusLength: 4096, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256", }, @@ -19,7 +19,7 @@ export const generateKeys = async () => { export const encryptData = async (pemPublicKey, data) => { const publicKey = await importPemPublicKey(pemPublicKey); - const chunkSize = 190; + const chunkSize = 446; const encryptedChunks: any[] = []; const encoder = new TextEncoder();