git ssb

3+

Dominic / ssb-blobs



Tree: 1441dc6aaf4517378c3ba5640cf67739944c68a2

Files: 1441dc6aaf4517378c3ba5640cf67739944c68a2 / index.js

926 bytesRaw
1var create = require('./create')
2var path = require('path')
3var Inject = require('./inject')
4var Set = require('./set')
5var Level = require('level')
6
7exports.manifest = {
8 get: 'source',
9 getSlice: 'source',
10 add: 'sink',
11 rm: 'async',
12 ls: 'source',
13 has: 'async',
14 size: 'async',
15 meta: 'async',
16 want: 'async',
17 push: 'async',
18 changes: 'source',
19 createWants: 'source'
20}
21
22exports.name = 'blobs'
23
24exports.version = require('./package.json').version
25
26exports.permissions = {
27 anonymous: {allow: ['has', 'get', 'getSlice', 'changes', 'createWants']},
28}
29
30exports.init = function (sbot, config) {
31 var blobs = Inject(
32 create(path.join(config.path, 'blobs')),
33 Set(Level(path.join(config.path, 'blobs_push'), {valueEncoding: 'json'})),
34 sbot.id,
35 config.blobs
36 )
37
38 sbot.on('rpc:connect', function (rpc) {
39 if (rpc.id === sbot.id) return
40 blobs._onConnect(rpc, rpc.id)
41 })
42 return blobs
43}
44
45

Built with git-ssb-web