forked from ssb-junkyard/react-native-scuttlebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssb-peer.js
129 lines (122 loc) · 2.74 KB
/
ssb-peer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const fs = require("fs");
const os = require("os");
const path = require("path");
const ssbKeys = require("ssb-keys");
const serveBlobs = require("./serve-blobs");
const mkdirp = require("mkdirp");
const ssbPath = path.resolve(os.homedir(), '.ssb');
if (!fs.existsSync(ssbPath)) {
mkdirp.sync(ssbPath);
}
const secretPath = path.join(ssbPath, "/secret");
const keys = ssbKeys.loadOrCreateSync(secretPath);
const config = require("ssb-config/inject")();
const manifest = {
auth: "async",
address: "sync",
manifest: "sync",
get: "async",
createFeedStream: "source",
createLogStream: "source",
messagesByType: "source",
createHistoryStream: "source",
createUserStream: "source",
links: "source",
relatedMessages: "async",
add: "async",
publish: "async",
getAddress: "sync",
getLatest: "async",
latest: "source",
latestSequence: "async",
whoami: "sync",
usage: "sync",
plugins: {
install: "source",
uninstall: "source",
enable: "async",
disable: "async"
},
gossip: {
peers: "sync",
add: "sync",
remove: "sync",
ping: "duplex",
connect: "async",
changes: "source",
reconnect: "sync"
},
friends: {
get: "async",
createFriendStream: "source",
hops: "async"
},
replicate: {
changes: "source",
upto: "source"
},
blobs: {
get: "source",
getSlice: "source",
add: "sink",
rm: "async",
ls: "source",
has: "async",
size: "async",
meta: "async",
want: "async",
push: "async",
changes: "source",
createWants: "source"
},
backlinks: {
read: "source"
},
about: {
stream: "source",
get: "async"
},
contacts: {
stream: "source",
get: "async"
},
query: {
read: "source"
},
invite: {
create: "async",
accept: "async",
use: "async"
},
block: {
isBlocked: "sync"
},
private: {
publish: "async",
unbox: "sync",
read: "source"
}
};
const createSbot = require("scuttlebot/index")
.use(require("scuttlebot/plugins/plugins"))
.use(require("scuttlebot/plugins/master"))
.use(require("scuttlebot/plugins/gossip"))
.use(require("scuttlebot/plugins/replicate"))
.use(require("ssb-friends"))
.use(require("ssb-blobs"))
.use(require("ssb-backlinks"))
.use(require("ssb-private"))
.use(require("ssb-about"))
.use(require("ssb-contacts"))
.use(require("ssb-query"))
.use(require("scuttlebot/plugins/invite"))
.use(require("scuttlebot/plugins/block"))
.use(require("scuttlebot/plugins/local"))
.use(require("scuttlebot/plugins/logging"));
// add third-party plugins
require("scuttlebot/plugins/plugins").loadUserPlugins(createSbot, config);
// start server
config.keys = keys;
config.path = ssbPath;
const sbot = createSbot(config);
serveBlobs(sbot);