Merge flotilla source code into Oasis

Problem: I thought it would be a good idea to keep our SSB stack in
another module but it just creates friction and adds another layer to
our stack that has to be independently upgraded and versioned.

Solution: Merge the @fraction/flotilla source code into Oasis so that we
don't have to maintain two separate projects.
This commit is contained in:
Christian Bundy 2020-11-22 10:06:35 -08:00
parent 3600e09ab0
commit c993adc01a
4 changed files with 81 additions and 36 deletions

34
package-lock.json generated
View File

@ -253,40 +253,6 @@
"resolved": "https://registry.npmjs.org/@fraction/base16-css/-/base16-css-1.1.0.tgz",
"integrity": "sha512-Lnle0J8t+Z+jFg78GFFnGo+Fphxaco9K9SppeBDsI27QBRBumxeGAMeOg5wt6XbAuj5pQWmAEWWEwPz4PYGMHw=="
},
"@fraction/flotilla": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@fraction/flotilla/-/flotilla-5.2.0.tgz",
"integrity": "sha512-9uF6Zq/K/qpO54aWkpMK247YbNHok42NMchkBNN5TVIMK+tQKbNW3YR4xgUyUCmVExaO1L5Xk9vHcevg8Pa1NQ==",
"requires": {
"debug": "^4.1.1",
"lodash.shuffle": "^4.2.0",
"secret-stack": "^6.3.0",
"ssb-about": "^2.0.1",
"ssb-backlinks": "^1.0.0",
"ssb-blobs": "^1.2.2",
"ssb-config": "^3.4.4",
"ssb-conn": "^0.17.0",
"ssb-db": "^19.4.0",
"ssb-ebt": "^5.6.7",
"ssb-friends": "^4.1.4",
"ssb-invite": "^2.1.3",
"ssb-lan": "^0.2.0",
"ssb-logging": "^1.0.0",
"ssb-master": "^1.0.3",
"ssb-meme": "^1.0.4",
"ssb-no-auth": "^1.0.0",
"ssb-onion": "^1.0.0",
"ssb-ooo": "^1.3.1",
"ssb-plugins": "^1.0.2",
"ssb-query": "^2.4.3",
"ssb-replicate": "^1.3.0",
"ssb-room": "^1.2.2",
"ssb-search": "^1.2.1",
"ssb-tangle": "^1.0.1",
"ssb-unix-socket": "^1.0.0",
"ssb-ws": "^6.2.3"
}
},
"@koa/router": {
"version": "8.0.8",
"resolved": "https://registry.npmjs.org/@koa/router/-/router-8.0.8.tgz",

View File

@ -22,7 +22,6 @@
},
"dependencies": {
"@fraction/base16-css": "^1.1.0",
"@fraction/flotilla": "^5.2.0",
"@koa/router": "^8.0.0",
"debug": "^4.1.1",
"env-paths": "^2.2.0",
@ -35,6 +34,7 @@
"koa-mount": "^4.0.0",
"koa-static": "^5.0.0",
"lodash": "^4.17.11",
"lodash.shuffle": "^4.2.0",
"markdown-it": "^12.0.2",
"open": "^7.0.3",
"piexifjs": "^1.0.4",
@ -44,15 +44,38 @@
"pull-sort": "^1.0.2",
"pull-stream": "^3.6.12",
"require-style": "^1.1.0",
"secret-stack": "^6.3.0",
"sharp": "^0.26.3",
"ssb-about": "^2.0.1",
"ssb-backlinks": "^1.0.0",
"ssb-blobs": "^1.2.2",
"ssb-client": "^4.9.0",
"ssb-config": "^3.4.4",
"ssb-conn": "^0.17.0",
"ssb-db": "^19.4.0",
"ssb-ebt": "^5.6.7",
"ssb-friends": "^4.1.4",
"ssb-invite": "^2.1.3",
"ssb-lan": "^0.2.0",
"ssb-logging": "^1.0.0",
"ssb-markdown": "^6.0.7",
"ssb-master": "^1.0.3",
"ssb-meme": "^1.0.4",
"ssb-mentions": "^0.5.2",
"ssb-msgs": "^5.2.0",
"ssb-no-auth": "^1.0.0",
"ssb-onion": "^1.0.0",
"ssb-ooo": "^1.3.1",
"ssb-plugins": "^1.0.2",
"ssb-query": "^2.4.3",
"ssb-ref": "^2.13.9",
"ssb-replicate": "^1.3.0",
"ssb-room": "^1.2.2",
"ssb-search": "^1.2.1",
"ssb-tangle": "^1.0.1",
"ssb-thread-schema": "^1.1.1",
"ssb-unix-socket": "^1.0.0",
"ssb-ws": "^6.2.3",
"yargs": "^16.1.1"
},
"devDependencies": {

55
src/ssb/flotilla.js Normal file
View File

@ -0,0 +1,55 @@
const stack = require("secret-stack");
const shuffle = require("lodash.shuffle");
const debug = require("debug")("oasis");
const ssbConfig = require("ssb-config");
const plugins = [
// Authentication often hooked for authentication.
require("ssb-master"),
// Methods often used during init().
require("ssb-db"),
// Method `replicate()` often hooked for improvements.
require("ssb-replicate"),
// Required by ssb-about, ssb-tangle, etc.
require("ssb-backlinks"),
// Required by ssb-room
require("ssb-conn"),
shuffle([
require("ssb-about"),
require("ssb-blobs"),
require("ssb-ebt"),
require("ssb-friends"),
require("ssb-invite"),
require("ssb-lan"),
require("ssb-logging"),
require("ssb-no-auth"),
require("ssb-onion"),
require("ssb-ooo"),
require("ssb-plugins"),
require("ssb-query"),
require("ssb-room/tunnel/client"),
require("ssb-search"),
require("ssb-tangle"),
require("ssb-unix-socket"),
require("ssb-ws"),
require("ssb-meme"),
]),
];
module.exports = (config) => {
const server = stack();
// TODO: Move this out of the main function.
const walk = (input) => {
if (Array.isArray(input)) {
input.forEach(walk);
} else {
debug(input.name || "???");
server.use(input);
}
};
walk(plugins);
return server({ ...ssbConfig, ...config });
};

View File

@ -7,12 +7,13 @@
const { promisify } = require("util");
const ssbClient = require("ssb-client");
const ssbConfig = require("ssb-config");
const flotilla = require("@fraction/flotilla");
const ssbTangle = require("ssb-tangle");
const debug = require("debug")("oasis");
const path = require("path");
const lodash = require("lodash");
const flotilla = require("./flotilla");
const socketPath = path.join(ssbConfig.path, "socket");
const publicInteger = ssbConfig.keys.public.replace(".ed25519", "");
const remote = `unix:${socketPath}~noauth:${publicInteger}`;