Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename listGroupKeys to listGroupIds #14

Merged
merged 2 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ on the `sbot.box2` namespace:
- `addGroupKey(groupId, groupKey)`: `groupId` must be a string and `groupKey`
must be a buffer. The key can then be used as a "recp" to encrypt messages to
the group. Note that the keys are not persisted in this module.
- `listGroupKeys(cb) => [groupKeys]`: Lists all groupKeys that you're able to decrypt. Returns a promise if cb isn't provided.
- `listGroupIds(cb) => [groupIds]`: Lists all groupIds whose messages you're able to decrypt. Returns a promise if cb isn't provided.

## Usage as a standalone

Expand Down
6 changes: 3 additions & 3 deletions format.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function makeEncryptionFormat() {
})
}

function listGroupKeys(cb) {
if (cb === undefined) return promisify(listGroupKeys)()
function listGroupIds(cb) {
if (cb === undefined) return promisify(listGroupIds)()

_keyringReady.onReady(() => {
cb(null, _keyring.group.list())
Expand Down Expand Up @@ -162,7 +162,7 @@ function makeEncryptionFormat() {
// ssb-box2 specific APIs:
setOwnDMKey,
addGroupKey,
listGroupKeys,
listGroupIds,
addKeypair,
}
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.init = function (ssb, config) {
return {
setOwnDMKey: encryptionFormat.setOwnDMKey,
addGroupKey: encryptionFormat.addGroupKey,
listGroupKeys: encryptionFormat.listGroupKeys,
listGroupIds: encryptionFormat.listGroupIds,
addKeypair: encryptionFormat.addKeypair,
}
}
9 changes: 6 additions & 3 deletions test/tribes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const rimraf = require('rimraf')
const mkdirp = require('mkdirp')
const SecretStack = require('secret-stack')
const caps = require('ssb-caps')
const ref = require('ssb-ref')

function readyDir(dir) {
rimraf.sync(dir)
Expand Down Expand Up @@ -215,9 +216,11 @@ test('we can decrypt a group message created with tribes', (t) => {
})
})

test('can list group keys', (t) => {
sbot.box2.listGroupKeys().then(keys=> {
t.equal(keys.length, 1)
test('can list group ids', (t) => {
sbot.box2.listGroupIds().then(ids=> {
t.equal(ids.length, 1, 'lists the one group we are in')

t.true(ref.isCloakedMsg(ids[0]), 'lists a group id and not something else')

t.end()
})
Expand Down