diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 9265e807c..5c9958bec 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1955,7 +1955,7 @@ define([ // If send is true, send the request to the owner. if (owner) { if (data.send) { - store.mailbox.sendTo(data.query, { + Mailbox.sendToAnon(store.anon_rpc, data.query, { channel: data.channel, data: data.msgData }, { diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 8f9860a41..3e85585dc 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -164,6 +164,22 @@ proxy.mailboxes = { }); }); }; + Mailbox.sendToAnon = function (anonRpc, type, msg, user, cb) { + var Nacl = Crypto.Nacl; + var curveSeed = Nacl.randomBytes(32); + var curvePair = Nacl.box.keyPair.fromSecretKey(new Uint8Array(curveSeed)); + var curvePrivate = Nacl.util.encodeBase64(curvePair.secretKey); + var curvePublic = Nacl.util.encodeBase64(curvePair.publicKey); + sendTo({ + store: { + anon_rpc: anonRpc, + proxy: { + curvePrivate: curvePrivate, + curvePublic: curvePublic + } + } + }, type, msg, user, cb); + }; // Mark a message as read var dismiss = function (ctx, data, cId, cb) {