From dbbd667a59d14e2e9328c900e6cafb2439a995b9 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Tue, 26 Oct 2021 01:32:11 +0200 Subject: [PATCH 1/4] Proof of concept box2 --- index.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +++ 2 files changed, 52 insertions(+) diff --git a/index.js b/index.js index 503a5f1..7d4b0b3 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const source = require('./source') function extraModules(secretStack) { return secretStack .use(require("ssb-meta-feeds")) + .use(require("ssb-db2-box2")) } let config = { @@ -29,6 +30,9 @@ let config = { }, blobs: { max: 10 * 1024 * 1024 + }, + box2: { + alwaysbox2: true } } @@ -94,6 +98,51 @@ function ssbReady(SSB) { //console.log("got sbot", SSB) //dumpDB() + const testkey = Buffer.from( + '30720d8f9cbf37f6d7062826f6decac93e308060a8aaaa77e6a4747f40ee1a76', + 'hex' + ) + + SSB.net.box2.addOwnDMKey(testkey) + SSB.net.box2.setReady() + + // monkey patch some methods + Uint8Array.prototype.equals = function equals (b) { + let a = this + + if (a === b) { + return true + } + + if (a.byteLength !== b.byteLength) { + return false + } + + for (let i = 0; i < a.byteLength; i++) { + if (a[i] !== b[i]) { + return false + } + } + + return true + } + + Uint8Array.prototype.copy = function equals (b) { + let a = this + for (let i = 0; i < a.length; ++i) + b[i] = a[i] + } + + let content = { type: 'post', text: 'super secret', recps: [SSB.net.id] } + + SSB.db.publish(content, (err, privateMsg) => { + console.log("encode", err, privateMsg) + + SSB.db.get(privateMsg.key, (err, msg) => { + console.log("decode", msg.content.text) + }) + }) + app.id = SSB.net.id SSB.net.ebt.registerFormat(require('ssb-ebt/formats/bendy-butt')) diff --git a/package.json b/package.json index 44aad83..071f067 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,10 @@ "apps/*.js" ], "dependencies": { + "sodium-universal": "^3.0.4", "ssb-browser-core": "^11.3.0", + "ssb-db2": "github:ssb-ngi-pointer/ssb-db2#support-bendy-butt-box2", + "ssb-db2-box2": "^0.2.0", "ssb-meta-feeds": "^0.24.0", "vue": "^2.6.14" }, From 3504a42725fbe9087c404f69b00e00623a6668a0 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Wed, 27 Oct 2021 23:27:43 +0200 Subject: [PATCH 2/4] Bump ssb-browser-core --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 7d4b0b3..6a05fca 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ let config = { } // setup ssb browser core -ssbSingleton.setup("/.ssb-8k", config, extraModules, () => {}) +ssbSingleton.setup("/.ssb-8k", config, extraModules) ssbSingleton.getSSBEventually( -1, diff --git a/package.json b/package.json index 071f067..5aa7c39 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ ], "dependencies": { "sodium-universal": "^3.0.4", - "ssb-browser-core": "^11.3.0", + "ssb-browser-core": "^12.0.0", "ssb-db2": "github:ssb-ngi-pointer/ssb-db2#support-bendy-butt-box2", "ssb-db2-box2": "^0.2.0", "ssb-meta-feeds": "^0.24.0", From 538dccd9c20e127e6e8e7a67aa0018a3918ed3d9 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Thu, 28 Oct 2021 21:18:53 +0200 Subject: [PATCH 3/4] Update to released versions of all deps --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 5aa7c39..b079084 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,8 @@ "apps/*.js" ], "dependencies": { - "sodium-universal": "^3.0.4", "ssb-browser-core": "^12.0.0", - "ssb-db2": "github:ssb-ngi-pointer/ssb-db2#support-bendy-butt-box2", - "ssb-db2-box2": "^0.2.0", + "ssb-db2-box2": "^0.3.1", "ssb-meta-feeds": "^0.24.0", "vue": "^2.6.14" }, From 86508243dbb744e800852e91a7f65bbc41e879f7 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Fri, 29 Oct 2021 10:21:27 +0200 Subject: [PATCH 4/4] Bump ssb-meta-feeds for encryption support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b079084..d35aadd 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dependencies": { "ssb-browser-core": "^12.0.0", "ssb-db2-box2": "^0.3.1", - "ssb-meta-feeds": "^0.24.0", + "ssb-meta-feeds": "^0.27.0", "vue": "^2.6.14" }, "devDependencies": {