Skip to content

Commit

Permalink
Merge pull request #38 from ssbc/pobox-unknown
Browse files Browse the repository at this point in the history
Add support for encrypting to unknown pobox
  • Loading branch information
Powersource authored Dec 8, 2023
2 parents fe9eec2 + f80cf3e commit d46cef9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion format.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function makeEncryptionFormat() {
return dmEncryptionKey(opts.keys, recp)
} else if (isGroupId(recp) && keyring.group.has(recp)) {
return keyring.group.get(recp).writeKey
} else if (isPoBoxId(recp) && keyring.poBox.has(recp)) {
} else if (isPoBoxId(recp)) {
return easyPoBoxKey(recp)
} else throw new Error('Unsupported recipient: ' + recp)
})
Expand Down
19 changes: 19 additions & 0 deletions test/pobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,22 @@ test('pobox functions', async (t) => {

await tearDown()
})

test("can encrypt to a pobox we haven't added", t => {
setup()

const opts = {
keys,
content: { type: 'post', text: 'super secret post to strange pobox' },
encryptionFormat: 'box2',
recps: [poBoxId],
}

sbot.db.create(opts, (err, privateMsg) => {
t.error(err, 'no err')

t.equal(typeof privateMsg.value.content, 'string')

tearDown(t.end)
})
})

0 comments on commit d46cef9

Please sign in to comment.