diff --git a/index.js b/index.js index 503a5f1..6a05fca 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,11 +30,14 @@ let config = { }, blobs: { max: 10 * 1024 * 1024 + }, + box2: { + alwaysbox2: true } } // setup ssb browser core -ssbSingleton.setup("/.ssb-8k", config, extraModules, () => {}) +ssbSingleton.setup("/.ssb-8k", config, extraModules) ssbSingleton.getSSBEventually( -1, @@ -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..d35aadd 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,9 @@ "apps/*.js" ], "dependencies": { - "ssb-browser-core": "^11.3.0", - "ssb-meta-feeds": "^0.24.0", + "ssb-browser-core": "^12.0.0", + "ssb-db2-box2": "^0.3.1", + "ssb-meta-feeds": "^0.27.0", "vue": "^2.6.14" }, "devDependencies": {