-
-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReactNative / Expo 42 - Sending encrypted messages is not reliable #1800
Comments
@ppulwey any news on this? I stuck at the same point. |
@Electrofenster we Switched to implementing things on our own. The SDK will be a good choice for web apps but not RN. The SDK developers seem to care only for simple problems. The real nuts seem to be ignored. Tried it also on the matrix channel (hrhrhr) but same ignorance there 🤷♂️ |
@ppulwey Yesterday I got the encryption runnig on RN with the |
@Electrofenster Did you do anything special to get encryption running? |
@ppulwey yes. I used a few more functions that I found across tickets in GitHub. As second thing I must remove the the payload for the second const payload = {
userId: response.user_id,
accessToken: response.access_token,
homeserver: BASE_URL,
deviceId: response.device_id,
crypto: true,
baseUrl: BASE_URL,
timelineSupport: true,
store: new sdk.MemoryStore({localStorage: AsyncStorage}),
sessionStore: {
getLocalTrustedBackupPubKey: () => null,
},
}; I used this two functions before loading messages of a (encrypted)room: useEffect(() => {
autoVerify(client, room.roomId, client.deviceId).then(() => {
console.log('VERIFIED');
});
}, [client, room.roomId]); because I don't know where I found these functions I can't link it, but here's the source: export const autoVerify = async (client, room_id, deviceId) => {
console.log('AUTO_VERIFY');
let room = client.getRoom(room_id);
const e2eMembers = await room.getEncryptionTargetMembers();
for (const member of e2eMembers) {
const devices = client.getStoredDevicesForUser(member.userId);
for (const device of devices) {
if (device.isUnverified()) {
console.log(`DEVICE_ID -> ${deviceId}`);
console.log({device});
await verifyDevice(client, member.userId, device.deviceId);
}
}
}
};
export async function verifyDevice(client, userId, deviceId) {
if (!userId || typeof userId !== 'string') {
throw new Error('"userId" is required and must be a string.');
}
if (!deviceId || typeof deviceId !== 'string') {
throw new Error('"deviceId" is required and must be a string.');
}
await client.setDeviceKnown(userId, deviceId, true);
await client.setDeviceVerified(userId, deviceId, true);
} I changed the deviceId in Maybe I could share a minimal repo with setup to use it because it's really hard to setup. FYI: You need to add a verification process after login to load old messages from a encrypted room. |
@Electrofenster a minimal repo with setup would be extremely useful |
@Electrofenster Have you proceed with your work? After a while I came back to the SDK giving it a try again.
Various devices can decrypt encrypted messages only after they themselves have written a message in the room. What could be the reason for this? |
@ppulwey nope, but maybe I could create a sample project on this weekend. A good point to know how it is done in the For your problem:
It could be the cross-signing problem. You need to verify the devices after you login.
On android we've a lot of performance problems after logging in (with SSO over an IDP as Google, Okta, Auth0, ...) and loading the chat for the first time. Also we've the problem, that only a few messages are decrypted after entering a room. Currently I'm on the restoring process of the backup with a security key and it's pure pain. 😅
Are you verifying each device with your device (react-native) when you enter the room? I think this could be the problem.
There is nothing good out there. We used the one from ditto-chat and modified it a bit to add the missing functions. |
@Electrofenster Thank you for your reply. I'm "happy" that other have the same obstacles in their way. I will try what you've pointed out. |
A look at an alternative implementation of ed25519 may be useful for reference here... |
Describe the bug
It took me a few days to get the SDK running with ReactNative (Expo) with E2EE ... more or less-
Sometimes it works, sometimes not. I cannot figure out the circumstances when it is working. It seems when you wait long enough for the devices to do "things" you can send encrypted messages.
But I always receive the following error message:
And sometimes
It is really frustrating that there is no working example on how to implement. "Go and have a look in fluffy chat" is really not enough.
I've spend days searching the internet and looking into the SDK source code to find a path through the jungle but it seems there is no way out.
I would be very grateful for help. I would also like to show my appreciation if someone can help me. But it can not go on like this.
To Reproduce
const [joinedRoomId, setJoinedRoomId] = useState<string>( "!gmKoGceSQXuFtkresp:my.matrix.host" );
to a valid room idExpected behavior
Encrypted messages are sent reliably
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: