From f91d2ca942c297a5025f389026eac5a65d9dfda2 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 24 Nov 2023 15:20:50 +0100 Subject: [PATCH] Only allow encryption with tribes.publish --- README.md | 2 +- index.js | 13 +------------ test/publish.test.js | 1 - 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f70c1de..c5a94ea 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ The secret stack option `config.box2.legacyMode` also needs to be `true`. ### `ssb.tribes.publish(content, cb)` -A wrapper around `ssb.db.create` that makes sure you have correct tangles (if relevant) in your message. Mutates `content`. You need to put recipients in `content.recps` if you want it to be encrypted. +A wrapper around `ssb.db.create` that makes sure you have correct tangles (if relevant) in your message. Mutates `content`. You need to put recipients in `content.recps`. ### `ssb.tribes.create(opts, cb)` diff --git a/index.js b/index.js index a4aa3fb..376df0d 100644 --- a/index.js +++ b/index.js @@ -202,19 +202,10 @@ function init (ssb, config) { const getMembersTangle = GetGroupTangle(ssb, null, 'members') const tribePublish = (content, cb) => { - // e.g. ssb-recps-guard hides options in .options, we should pass those along - const passAlongOpts = content.options ? {options: content.options} : {} - - if (!content.recps) { - return ssb.db.create({ - ...passAlongOpts, - content - }, cb) - } + if (!content.recps) return cb(Error('tribes.publish requires content.recps')) if (!isGroup(content.recps[0])) { return ssb.db.create({ - ...passAlongOpts, content, encryptionFormat: 'box2' }, cb) @@ -234,7 +225,6 @@ function init (ssb, config) { // we only want to have to calculate the members tangle if it's gonna be used if (!isMemberType(content.type)) { return ssb.db.create({ - ...passAlongOpts, content, encryptionFormat: 'box2' }, cb) @@ -247,7 +237,6 @@ function init (ssb, config) { tanglePrune(content, 'members') ssb.db.create({ - ...passAlongOpts, content, encryptionFormat: 'box2' }, cb) diff --git a/test/publish.test.js b/test/publish.test.js index dc877e1..61799ef 100644 --- a/test/publish.test.js +++ b/test/publish.test.js @@ -99,7 +99,6 @@ test('publish (DMs: myFeedId + feedId)', async t => { try { const msg = await p(alice.tribes.publish)(content) - await p(alice.tribes.publish)({ type: 'doop' }) t.true(msg.value.content.endsWith('.box2'), 'publishes envelope cipherstring') const aliceGet = await p(alice.get)({ id: msg.key, private: true, meta: true })