diff --git a/app/mobile/package.json b/app/mobile/package.json index 759cdd8b..60676810 100644 --- a/app/mobile/package.json +++ b/app/mobile/package.json @@ -24,6 +24,7 @@ "expo-keep-awake": "~10.2.0", "expo-splash-screen": "~0.16.2", "expo-status-bar": "~1.4.0", + "jsencrypt": "^3.3.1", "moment": "^2.29.4", "react": "18.0.0", "react-dom": "18.0.0", diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js index fab9283f..a14c1f80 100644 --- a/app/mobile/src/context/useConversationContext.hook.js +++ b/app/mobile/src/context/useConversationContext.hook.js @@ -171,7 +171,9 @@ export function useConversationContext() { if (conversationId.current) { const { cardId, channelId } = conversationId.current; const channelItem = getChannel(cardId, channelId); - setChannel(channelItem); + if (channelItem) { + setChannel(channelItem); + } } }, [card, channel]); diff --git a/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js b/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js index e7ed5e10..32639bf2 100644 --- a/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js +++ b/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js @@ -6,6 +6,8 @@ import { AccountContext } from 'context/AccountContext'; import { AppContext } from 'context/AppContext'; import config from 'constants/Config'; import CryptoJS from "crypto-js"; +import { JSEncrypt } from 'jsencrypt' + import { RSA } from 'react-native-rsa-native'; export function useProfileBody() { @@ -122,13 +124,13 @@ export function useProfileBody() { }); // generate rsa key for sealing channel, delay for activity indicator - const keys = await RSA.generateKeys(2048); - console.log("NEW KEYS", keys); + const crypto = new JSEncrypt({ default_key_size: 2048 }); + const key = crypto.getKey(); // encrypt private key const iv = CryptoJS.lib.WordArray.random(128 / 8); - const privateKey = convertPem(keys.private); - const publicKey = convertPem(keys.public); + const privateKey = convertPem(crypto.getPrivateKey()); + const publicKey = convertPem(crypto.getPublicKey()); const enc = CryptoJS.AES.encrypt(privateKey, aes, { iv: iv }); const seal = { diff --git a/app/mobile/yarn.lock b/app/mobile/yarn.lock index 48689a8a..34ec0c02 100644 --- a/app/mobile/yarn.lock +++ b/app/mobile/yarn.lock @@ -4344,6 +4344,11 @@ jscodeshift@^0.13.1: temp "^0.8.4" write-file-atomic "^2.3.0" +jsencrypt@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/jsencrypt/-/jsencrypt-3.3.1.tgz#5d47e6c1079bb50e714a36d009ba09ea81fbfa18" + integrity sha512-dVvV54GdFuJgmEKn+oBiaifDMen4p6o6j/lJh0OVMcouME8sST0bJ7bldIgKBQk4za0zyGn0/pm4vOznR25mLw== + jsesc@^2.5.1: version "2.5.2" resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz"