Skip to content

Commit

Permalink
fix(SEA): encryption *sighs*
Browse files Browse the repository at this point in the history
  • Loading branch information
retrouser955 committed Sep 27, 2024
1 parent 88938d8 commit 5e2fa49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/Structs/DMChannel/DMChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export class DMChannel {
* @returns Event end function
*/
listenToMessages() {
console.log(this.__createChannelQuery())
const listener = this._db
.get(this.__createChannelQuery())
.map()
.once(async (d) => {
if(!d) return
const decrypted = await this.client.decrypt(d.content, this.peer.epub);
console.log(decrypted)
d.content = decrypted;
d.timestamp = Util.getGunKey(d);
const message = new Message(d);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/utils/Chats/chatData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class ChatData {
},
);

channel.listenToMessages()

return channel;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/Gun/SEA/SEA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ExperimentalSEA {
) {
const secret = await GunSEA.secret(peerEpub, mySea);

if (secret) return GunSEA.encrypt(encrypted, secret);
if (secret) return GunSEA.decrypt(encrypted, secret);

throw new Error('Unable to decrypt data');
}
Expand Down

0 comments on commit 5e2fa49

Please sign in to comment.