Skip to content

Commit

Permalink
revert randomization here
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Sep 25, 2024
1 parent 26ef939 commit 4a966a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions apps/meteor/app/e2e/client/rocketchat.e2e.room.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Base64 } from '@rocket.chat/base64';
import { Emitter } from '@rocket.chat/emitter';
import { Random } from '@rocket.chat/random';
import EJSON from 'ejson';

import { RoomManager } from '../../../client/lib/RoomManager';
Expand Down Expand Up @@ -68,13 +67,12 @@ export class E2ERoom extends Emitter {

[PAUSED] = undefined;

constructor(userId, room, t) {
constructor(userId, roomId, t) {
super();

this.userId = userId;
this.roomId = room._id;
this.roomId = roomId;
this.typeOfRoom = t;
this.roomKeyId = room.e2eKeyId;

this.once(E2ERoomState.READY, () => this.decryptPendingMessages());
this.once(E2ERoomState.READY, () => this.decryptSubscription());
Expand Down Expand Up @@ -295,7 +293,7 @@ export class E2ERoom extends Emitter {
return false;
}

this.keyID = this.roomKeyId;
this.keyID = Base64.encode(this.sessionKeyExportedString).slice(0, 12);

// Import session key for use.
try {
Expand Down Expand Up @@ -323,10 +321,8 @@ export class E2ERoom extends Emitter {
try {
const sessionKeyExported = await exportJWKKey(this.groupSessionKey);
this.sessionKeyExportedString = JSON.stringify(sessionKeyExported);
console.log(this.groupSessionKey, sessionKeyExported);
this.keyID = Random.id(12);
this.keyID = Base64.encode(this.sessionKeyExportedString).slice(0, 12);

this.log(sessionKeyExported, this.sessionKeyExportedString, this.keyID, this.groupSessionKey);
await sdk.call('e2e.setRoomKeyID', this.roomId, this.keyID);
await this.encryptKeyForOtherParticipants();
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/e2e/client/rocketchat.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class E2E extends Emitter {
}

if (!this.instancesByRoomId[rid]) {
this.instancesByRoomId[rid] = new E2ERoom(Meteor.userId(), room, room.t);
this.instancesByRoomId[rid] = new E2ERoom(Meteor.userId(), rid, room.t);
}

return this.instancesByRoomId[rid];
Expand Down

0 comments on commit 4a966a9

Please sign in to comment.