From bcf7e8ecaae7bbfa8f32d19a432a5023c0ae57d4 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 26 Oct 2023 23:57:33 +0200 Subject: [PATCH 1/9] Use testbot with noUse --- package-lock.json | 6 +++--- package.json | 2 +- test/helpers/test-bot.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3abb70a..2598387 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "devDependencies": { "cross-env": "^7.0.3", "is-canonical-base64": "^1.1.1", - "scuttle-testbot": "^2.1.0", + "scuttle-testbot": "github:ssbc/scuttle-testbot#no-use", "ssb-box2": "ssbc/ssb-box2#pobox", "ssb-db2": "^7.1.1", "ssb-replicate": "^1.3.3", @@ -4716,9 +4716,9 @@ }, "node_modules/scuttle-testbot": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/scuttle-testbot/-/scuttle-testbot-2.1.0.tgz", - "integrity": "sha512-v519Xn31VZTs629fbd1Gb73W0Qu8/6qhWEq6Df2HDPVpmP+ovSXc87eVEZG1qC2vlP94DHu6kzMNmLSvrdQOTw==", + "resolved": "git+ssh://git@github.com/ssbc/scuttle-testbot.git#4ce8fc01d8c11bca63c36ffb78d29a395d08a35b", "dev": true, + "license": "MIT", "dependencies": { "color-tag": "^1.0.2", "pull-paramap": "^1.2.2", diff --git a/package.json b/package.json index 58dc24f..ef27f29 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "devDependencies": { "cross-env": "^7.0.3", "is-canonical-base64": "^1.1.1", - "scuttle-testbot": "^2.1.0", + "scuttle-testbot": "github:ssbc/scuttle-testbot#no-use", "ssb-box2": "ssbc/ssb-box2#pobox", "ssb-db2": "^7.1.1", "ssb-replicate": "^1.3.3", diff --git a/test/helpers/test-bot.js b/test/helpers/test-bot.js index 7db2d4f..07fbda9 100644 --- a/test/helpers/test-bot.js +++ b/test/helpers/test-bot.js @@ -33,8 +33,8 @@ module.exports = function TestBot (opts = {}) { legacyMode: true, ...opts.box2 }, - // we don't want testbot to import db2 for us, we want more granularity and control of dep versions - db1: true, + // we don't want testbot to import db1 or db2 for us, we want to control what db2 plugins get imported + noUse: true, ...opts }) From 3b89efba021b5bc4695995f52ba1e55153661333 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Fri, 27 Oct 2023 00:06:54 +0200 Subject: [PATCH 2/9] Don't use db1 index functions --- test/rebuild.test.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/test/rebuild.test.js b/test/rebuild.test.js index 38b2da6..68fd2dc 100644 --- a/test/rebuild.test.js +++ b/test/rebuild.test.js @@ -34,8 +34,6 @@ test('rebuild (I am added to a group)', async t => { // time for rebuilding await p(setTimeout)(500) - t.true(me.status().sync.sync, 'all indexes updated') - const msgs = await pull( me.db.query( where(and( @@ -243,12 +241,6 @@ test('rebuild from listen.addMember', t => { // NOTE with auto-rebuild active, this listener gets hit twice: // 1. first time we see group/add-member (unboxed with DM key) // 2. after rebuild - function checkRebuildDone (done) { - if (A.status().sync.sync) return done() - - console.log('waiting for rebuild') - setTimeout(() => checkRebuildDone(done), 500) - } pull( listen.addMember(A), pull.filter(m => !m.sync), @@ -259,12 +251,12 @@ test('rebuild from listen.addMember', t => { // (2) B invites A if (heardCount === 2) { - checkRebuildDone(() => { + setTimeout(() => { A.close(err => { t.error(err, 'A closed') t.end() }) - }) + }, 500) } }) ) From cb9d20903abf51dc9fb594d4615c0cd67d4dd97e Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Mon, 30 Oct 2023 13:25:43 +0100 Subject: [PATCH 3/9] noUse->noDefaultUse --- package-lock.json | 2 +- test/helpers/test-bot.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2598387..2c8fbfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4716,7 +4716,7 @@ }, "node_modules/scuttle-testbot": { "version": "2.1.0", - "resolved": "git+ssh://git@github.com/ssbc/scuttle-testbot.git#4ce8fc01d8c11bca63c36ffb78d29a395d08a35b", + "resolved": "git+ssh://git@github.com/ssbc/scuttle-testbot.git#06a268a788e7b4e39672020c197309fd793eb15e", "dev": true, "license": "MIT", "dependencies": { diff --git a/test/helpers/test-bot.js b/test/helpers/test-bot.js index 07fbda9..0e27c02 100644 --- a/test/helpers/test-bot.js +++ b/test/helpers/test-bot.js @@ -34,7 +34,7 @@ module.exports = function TestBot (opts = {}) { ...opts.box2 }, // we don't want testbot to import db1 or db2 for us, we want to control what db2 plugins get imported - noUse: true, + noDefaultUse: true, ...opts }) From ffa84811a3abe8da3d3dca318eaab704d704f39d Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 20:28:26 +0100 Subject: [PATCH 4/9] Fix replicate tests by using new fixed post compat --- package-lock.json | 8 ++++---- package.json | 2 +- test/helpers/test-bot.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a9ed0b..4a98a9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "is-canonical-base64": "^1.1.1", "scuttle-testbot": "github:ssbc/scuttle-testbot#no-use", "ssb-box2": "^7.2.0", - "ssb-db2": "^7.1.1", + "ssb-db2": "github:ssbc/ssb-db2#fix-post-compat", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", "tap-arc": "^0.4.0", @@ -5313,10 +5313,10 @@ } }, "node_modules/ssb-db2": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/ssb-db2/-/ssb-db2-7.1.1.tgz", - "integrity": "sha512-mRnqDY2XTTdgT0ILsWPcOWL2/WdAPlYwBEhXYm1vtnPeS2da8RcTSMIOzBAp/bAcnfJWMgUOgRNupQnbiLjMCg==", + "version": "7.2.0", + "resolved": "git+ssh://git@github.com/ssbc/ssb-db2.git#eda707a65a608f4ddef85e7ac32ca09f41503a49", "dev": true, + "license": "LGPL-3.0-only", "dependencies": { "async-append-only-log": "^4.3.7", "atomic-file-rw": "^0.3.0", diff --git a/package.json b/package.json index 3c3ee9d..357d2bd 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "is-canonical-base64": "^1.1.1", "scuttle-testbot": "github:ssbc/scuttle-testbot#no-use", "ssb-box2": "^7.2.0", - "ssb-db2": "^7.1.1", + "ssb-db2": "github:ssbc/ssb-db2#fix-post-compat", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", "tap-arc": "^0.4.0", diff --git a/test/helpers/test-bot.js b/test/helpers/test-bot.js index 0e27c02..eec8f11 100644 --- a/test/helpers/test-bot.js +++ b/test/helpers/test-bot.js @@ -18,7 +18,7 @@ module.exports = function TestBot (opts = {}) { .use(require('ssb-classic')) .use(require('ssb-db2/compat')) .use(require('ssb-db2/compat/feedstate')) - // .use(require("ssb-db2/compat/publish")) + .use(require("ssb-db2/compat/post")) .use(require('ssb-box2')) .use(require('../..')) // ssb-tribes - NOTE load it after ssb-backlinks From c1ec519a5f770704f6dc418f9121927f94a46f66 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 21:20:38 +0100 Subject: [PATCH 5/9] Install box2 with getOwnDMKey fn --- README.md | 2 +- package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a250799..ab69684 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ A Secret-Stack server running the plugins: - `ssb-tribes` - `ssb-db2/compat` - `ssb-db2/compat/feedstate` -- `ssb-box2` >= 7.2.0 +- `ssb-box2` >= TODO - `ssb-replicate` - (optional) used to auto-replicate people who you're in groups with The secret stack option `config.box2.legacyMode` also needs to be `true`. diff --git a/package-lock.json b/package-lock.json index 069df3e..a5a1b03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "cross-env": "^7.0.3", "is-canonical-base64": "^1.1.1", "scuttle-testbot": "^2.1.0", - "ssb-box2": "^7.2.0", + "ssb-box2": "github:ssbc/ssb-box2#get-own-dm", "ssb-db2": "^7.1.1", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", @@ -5073,9 +5073,9 @@ }, "node_modules/ssb-box2": { "version": "7.2.0", - "resolved": "https://registry.npmjs.org/ssb-box2/-/ssb-box2-7.2.0.tgz", - "integrity": "sha512-LOIgzULj8wNPNk89zmLTRcc35Xq35uOuG/4Rq74ae4pPVY50oYEir7mdRNRiAjuIPTxbVmY6YwXVUehBEkxk1w==", + "resolved": "git+ssh://git@github.com/ssbc/ssb-box2.git#39e35310591ae24a4ee1b5d8c9c9244170b7979e", "dev": true, + "license": "LGPL-3.0-only", "dependencies": { "envelope-js": "^1.3.2", "private-group-spec": "^2.1.1", diff --git a/package.json b/package.json index 2382753..8863126 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "cross-env": "^7.0.3", "is-canonical-base64": "^1.1.1", "scuttle-testbot": "^2.1.0", - "ssb-box2": "^7.2.0", + "ssb-box2": "github:ssbc/ssb-box2#get-own-dm", "ssb-db2": "^7.1.1", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", From aded0206f990168943874038721bae1d49c0db5f Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 21:34:47 +0100 Subject: [PATCH 6/9] Re-enable ownKey functions and document in readme --- README.md | 3 +++ index.js | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ab69684..ea304a7 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,9 @@ These endpoints give you access to additional features, such as: - `ssb.tribes.poBox.create(opts, cb)` - `ssb.tribes.addPOBox(groupId, cb)` - `ssb.tribes.poBox.get(groupId, cb)` +- **self-DM keys** + - `ssb.tribes.ownKeys.list(cb)`: returns a list of self-DM keyinfo. Always a length of 1 (only a list for historical reasons). The keyinfo has the format `{ key: Buffer, scheme: String }`. + - `ssb.tribes.ownKeys.register(key)`: sets the self-DM key (buffer). - **managing people applying to join to a group** - deprecated, please use [ssb-tribes-registration](https://gitlab.com/ahau/lib/ssb-plugins/ssb-tribes-registration) - for the old docs, [see here](./README.deprecated.md) diff --git a/index.js b/index.js index c8cd188..6095a3b 100644 --- a/index.js +++ b/index.js @@ -371,24 +371,20 @@ function init (ssb, config) { }) }, get: scuttle.group.getPOBox - } + }, // for internal use - ssb-ahau uses this for backups - // TODO: does ahau use this for backups though? - // i couldn't find a self.get function in box2 so we might have to add that if this is needed - // ownKeys: { - // list (cb) { - // onKeystoreReady(() => { - // cb(null, [keystore.self.get()]) - // }) - // }, - // register (key, cb) { - // onKeystoreReady(() => { - // //ssb.box2.setOwnDMKey(key) - // keystore.self.set(key, cb) - // }) - // } - // } + ownKeys: { + list (cb) { + ssb.box2.getOwnDMKey((err, dmKeyInfo) => { + if (err) return cb(Error("Couldn't get own dm key on ownKeys.list", { cause: err })) + return cb(null, [dmKeyInfo]) + }) + }, + register (key) { + ssb.box2.setOwnDMKey(key) + } + } } } From dc58f150a24f80e79d84857017b4ac45d697e495 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 22:01:23 +0100 Subject: [PATCH 7/9] Add test for ownKeys --- test/api/own-keys/register-and-list.test.js | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/api/own-keys/register-and-list.test.js diff --git a/test/api/own-keys/register-and-list.test.js b/test/api/own-keys/register-and-list.test.js new file mode 100644 index 0000000..699d8ef --- /dev/null +++ b/test/api/own-keys/register-and-list.test.js @@ -0,0 +1,23 @@ +const { promisify: p } = require('util') +const test = require('tape') +const { keySchemes } = require('private-group-spec') +const { Server } = require('../../helpers') + +test('can set and get own self dm key', async (t) => { + const alice = Server() + + const ownKey = Buffer.from( + '30720d8f9cbf37f6d7062826f6decac93e308060a8aaaa77e6a4747f40ee1a76', + 'hex' + ) + + alice.tribes.ownKeys.register(ownKey) + + const gottenKeyList = await p(alice.tribes.ownKeys.list)() + const gottenKey = gottenKeyList[0] + + t.equal(gottenKey.key, ownKey, 'got correct key') + t.equal(gottenKey.scheme, keySchemes.feed_id_self, 'got correct scheme') + + await p(alice.close)() +}) \ No newline at end of file From 86e79eedbe131d02651101c5c11864d1d978b6c1 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 22:02:12 +0100 Subject: [PATCH 8/9] Fix lint --- test/api/own-keys/register-and-list.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/own-keys/register-and-list.test.js b/test/api/own-keys/register-and-list.test.js index 699d8ef..55f4e62 100644 --- a/test/api/own-keys/register-and-list.test.js +++ b/test/api/own-keys/register-and-list.test.js @@ -20,4 +20,4 @@ test('can set and get own self dm key', async (t) => { t.equal(gottenKey.scheme, keySchemes.feed_id_self, 'got correct scheme') await p(alice.close)() -}) \ No newline at end of file +}) From 5ca89c13d21e83f89e0de4f2f95b73ea7fc671a6 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Tue, 7 Nov 2023 13:52:54 +0100 Subject: [PATCH 9/9] Update box2 with getDM fn --- README.md | 2 +- package-lock.json | 8 ++++---- package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ea304a7..f70c1de 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ A Secret-Stack server running the plugins: - `ssb-tribes` - `ssb-db2/compat` - `ssb-db2/compat/feedstate` -- `ssb-box2` >= TODO +- `ssb-box2` >= 7.4.0 - `ssb-replicate` - (optional) used to auto-replicate people who you're in groups with The secret stack option `config.box2.legacyMode` also needs to be `true`. diff --git a/package-lock.json b/package-lock.json index a5a1b03..622bcee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "cross-env": "^7.0.3", "is-canonical-base64": "^1.1.1", "scuttle-testbot": "^2.1.0", - "ssb-box2": "github:ssbc/ssb-box2#get-own-dm", + "ssb-box2": "^7.4.0", "ssb-db2": "^7.1.1", "ssb-replicate": "^1.3.3", "standard": "^17.1.0", @@ -5072,10 +5072,10 @@ } }, "node_modules/ssb-box2": { - "version": "7.2.0", - "resolved": "git+ssh://git@github.com/ssbc/ssb-box2.git#39e35310591ae24a4ee1b5d8c9c9244170b7979e", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/ssb-box2/-/ssb-box2-7.4.0.tgz", + "integrity": "sha512-LH4NeFnKrIYEYKJZOFWkaJKgjN5ZTTDdplFkuUGr7GA36oPfvapAz/xrFIVE3Q3I+ffBZmjbWGIQe/aiWuhi7A==", "dev": true, - "license": "LGPL-3.0-only", "dependencies": { "envelope-js": "^1.3.2", "private-group-spec": "^2.1.1", diff --git a/package.json b/package.json index 8863126..7ba1b2c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "cross-env": "^7.0.3", "is-canonical-base64": "^1.1.1", "scuttle-testbot": "^2.1.0", - "ssb-box2": "github:ssbc/ssb-box2#get-own-dm", + "ssb-box2": "^7.4.0", "ssb-db2": "^7.1.1", "ssb-replicate": "^1.3.3", "standard": "^17.1.0",