Skip to content

Commit

Permalink
Only allow encryption with tribes.publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed Nov 24, 2023
1 parent d6bce5a commit f91d2ca
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`

Expand Down
13 changes: 1 addition & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -247,7 +237,6 @@ function init (ssb, config) {
tanglePrune(content, 'members')

ssb.db.create({
...passAlongOpts,
content,
encryptionFormat: 'box2'
}, cb)
Expand Down
1 change: 0 additions & 1 deletion test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit f91d2ca

Please sign in to comment.