correct decrpyt

This commit is contained in:
Daniel Lugo 2020-01-29 12:43:24 -04:00
parent 44de364ae4
commit 58cf841bdc

View file

@ -337,6 +337,7 @@ const processOutgoings = async () => {
encryptedOutgoings = {} encryptedOutgoings = {}
const mySecret = await Utils.mySecret() const mySecret = await Utils.mySecret()
const SEA = require('../Mediator').mySEA const SEA = require('../Mediator').mySEA
const user = require('../Mediator').getUser()
await Utils.asyncForEach(Object.entries(outs), async ([id, out]) => { await Utils.asyncForEach(Object.entries(outs), async ([id, out]) => {
if (out === null) { if (out === null) {
currentOutgoings[id] = null currentOutgoings[id] = null
@ -366,6 +367,11 @@ const processOutgoings = async () => {
// on each open() only "messages" should change, not "with" // on each open() only "messages" should change, not "with"
// also messages are non-nullable and non-editable // also messages are non-nullable and non-editable
const ourSecret = await SEA.secret(
await Utils.pubToEpub(currentOut.with),
user._.sea
)
await Utils.asyncForEach( await Utils.asyncForEach(
Object.entries(out.messages), Object.entries(out.messages),
async ([msgID, msg]) => { async ([msgID, msg]) => {
@ -378,7 +384,7 @@ const processOutgoings = async () => {
if (msg.body === Actions.INITIAL_MSG) { if (msg.body === Actions.INITIAL_MSG) {
decryptedBody = Actions.INITIAL_MSG decryptedBody = Actions.INITIAL_MSG
} else { } else {
decryptedBody = await SEA.decrypt(msg.body, mySecret) decryptedBody = await SEA.decrypt(msg.body, ourSecret)
} }
// each callback only looks at one particular msgID // each callback only looks at one particular msgID
// eslint-disable-next-line require-atomic-updates // eslint-disable-next-line require-atomic-updates