@leofcoin/peernet 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/peernet.js +10530 -9455
- package/dist/commonjs/{messages-7c05afbc.js → messages-f46a3ca1.js} +1 -1
- package/dist/commonjs/peernet.js +115 -27
- package/dist/module/{messages-d7278178.js → messages-1b12e93b.js} +28 -15
- package/dist/module/peernet.js +151 -38
- package/index.html +2 -2
- package/package.json +11 -5
- package/rollup.config.js +2 -1
- package/src/peer-info.js +9 -9
- package/src/peernet.js +26 -28
- package/src/proto/file.proto.js +1 -1
- package/webpack.config.js +13 -7
- package/dist/browser/generate-account.js +0 -50
- package/dist/browser/messages.js +0 -404
- package/dist/browser/pako.js +0 -6731
- package/dist/browser/peernet-swarm.js +0 -836
- package/dist/browser/protons.js +0 -3829
- package/dist/browser/storage.js +0 -12
- package/dist/browser/wrtc.js +0 -28
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "",
|
|
5
|
+
"source": "src/peernet.js",
|
|
5
6
|
"main": "dist/commonjs/peernet.js",
|
|
6
|
-
"module": "
|
|
7
|
+
"module": "dist/module/peernet.js",
|
|
8
|
+
"targets": [
|
|
9
|
+
"browser"
|
|
10
|
+
],
|
|
7
11
|
"scripts": {
|
|
8
12
|
"build": "npm run c && webpack",
|
|
9
13
|
"test": "node test/index.js",
|
|
@@ -15,18 +19,20 @@
|
|
|
15
19
|
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
|
16
20
|
"c": "rollup -c",
|
|
17
21
|
"w": "rollup -c -w",
|
|
18
|
-
"
|
|
22
|
+
"watch": "parcel watch",
|
|
23
|
+
"parcel-build": "parcel build",
|
|
24
|
+
"b": "browserify dist/module/peernet.js -o dist/module/peernet.js --standalone Peernet && rm browser.js"
|
|
19
25
|
},
|
|
20
26
|
"keywords": [],
|
|
21
27
|
"author": "",
|
|
22
28
|
"license": "MIT",
|
|
23
|
-
"browserslist": ">
|
|
29
|
+
"browserslist": "> 5%, last 2 versions, not dead",
|
|
24
30
|
"dependencies": {
|
|
25
31
|
"@leofcoin/codec-format-interface": "^1.2.5",
|
|
26
32
|
"@leofcoin/generate-account": "^1.0.4",
|
|
27
33
|
"@leofcoin/multi-wallet": "^2.1.2",
|
|
28
34
|
"@leofcoin/peernet-swarm": "^0.3.3",
|
|
29
|
-
"@leofcoin/storage": "^
|
|
35
|
+
"@leofcoin/storage": "^3.0.0",
|
|
30
36
|
"@vandeurenglenn/base32": "^1.1.0",
|
|
31
37
|
"@vandeurenglenn/base58": "^1.1.0",
|
|
32
38
|
"@vandeurenglenn/debug": "^1.0.0",
|
package/rollup.config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
2
|
import json from '@rollup/plugin-json'
|
|
3
3
|
import modify from 'rollup-plugin-modify'
|
|
4
|
+
import resolve from 'rollup-plugin-node-resolve'
|
|
4
5
|
|
|
5
6
|
try {
|
|
6
7
|
execSync('rm dist -r')
|
|
@@ -26,7 +27,7 @@ export default [{
|
|
|
26
27
|
input: 'src/peernet.js',
|
|
27
28
|
output: {
|
|
28
29
|
dir: 'dist/module',
|
|
29
|
-
format: '
|
|
30
|
+
format: 'cjs'
|
|
30
31
|
},
|
|
31
32
|
plugins: [
|
|
32
33
|
json(),
|
package/src/peer-info.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import CodecFormat from './codec/codec-format-interface'
|
|
2
|
-
|
|
3
|
-
export default class PeerInfo extends CodecFormat {
|
|
4
|
-
constructor(data, options) {
|
|
5
|
-
super(data, options)
|
|
6
|
-
|
|
7
|
-
this.keys = ['id', 'address', 'family']
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import CodecFormat from './codec/codec-format-interface'
|
|
2
|
+
|
|
3
|
+
export default class PeerInfo extends CodecFormat {
|
|
4
|
+
constructor(data, options) {
|
|
5
|
+
super(data, options)
|
|
6
|
+
|
|
7
|
+
this.keys = ['id', 'address', 'family']
|
|
8
|
+
}
|
|
9
|
+
}
|
package/src/peernet.js
CHANGED
|
@@ -2,14 +2,13 @@ import '@vandeurenglenn/debug'
|
|
|
2
2
|
import PubSub from '@vandeurenglenn/little-pubsub'
|
|
3
3
|
import PeerDiscovery from './discovery/peer-discovery'
|
|
4
4
|
import DHT from './dht/dht.js'
|
|
5
|
-
import
|
|
5
|
+
import codecs from './../node_modules/@leofcoin/codec-format-interface/src/codecs'
|
|
6
6
|
import { protoFor, target } from './utils/utils.js'
|
|
7
7
|
import MessageHandler from './handlers/message.js'
|
|
8
8
|
import dataHandler from './handlers/data.js'
|
|
9
9
|
import { encapsulatedError, dhtError,
|
|
10
10
|
nothingFoundError } from './errors/errors.js'
|
|
11
|
-
|
|
12
|
-
import {parse} from 'path'
|
|
11
|
+
|
|
13
12
|
globalThis.leofcoin = globalThis.leofcoin || {}
|
|
14
13
|
globalThis.pubsub = globalThis.pubsub || new PubSub()
|
|
15
14
|
globalThis.globalSub = globalThis.globalSub || new PubSub({verbose: true})
|
|
@@ -197,36 +196,33 @@ export default class Peernet {
|
|
|
197
196
|
await this.addStore(store, options.storePrefix, options.root)
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
|
|
199
|
+
const accountExists = await accountStore.has('public')
|
|
200
|
+
if (accountExists) {
|
|
201
201
|
const pub = await accountStore.get('public')
|
|
202
|
-
this.id = JSON.parse(
|
|
202
|
+
this.id = JSON.parse(pub).walletId
|
|
203
203
|
let accounts = await walletStore.get('accounts')
|
|
204
|
-
|
|
204
|
+
|
|
205
|
+
|
|
205
206
|
|
|
206
207
|
// fixing account issue (string while needs to be a JSON)
|
|
207
208
|
// TODO: remove when on mainnet
|
|
208
209
|
try {
|
|
209
|
-
this.accounts = JSON.parse(
|
|
210
|
+
this.accounts = JSON.parse(accounts)
|
|
210
211
|
} catch (e) {
|
|
211
212
|
this.accounts = [accounts.split(',')]
|
|
212
213
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this.id = identity.walletId
|
|
227
|
-
} else {
|
|
228
|
-
throw e
|
|
229
|
-
}
|
|
214
|
+
} else {
|
|
215
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ '@leofcoin/generate-account')
|
|
216
|
+
const generateAccount = importee.default
|
|
217
|
+
const {identity, accounts, config} = await generateAccount(this.network)
|
|
218
|
+
// await accountStore.put('config', JSON.stringify(config));
|
|
219
|
+
await accountStore.put('public', JSON.stringify({walletId: identity.walletId}));
|
|
220
|
+
|
|
221
|
+
await walletStore.put('version', String(1))
|
|
222
|
+
await walletStore.put('accounts', JSON.stringify(accounts))
|
|
223
|
+
await walletStore.put('identity', JSON.stringify(identity))
|
|
224
|
+
|
|
225
|
+
this.id = identity.walletId
|
|
230
226
|
}
|
|
231
227
|
this._peerHandler = new PeerDiscovery(this.id)
|
|
232
228
|
this.peerId = this.id
|
|
@@ -570,7 +566,7 @@ export default class Peernet {
|
|
|
570
566
|
return hash
|
|
571
567
|
}
|
|
572
568
|
|
|
573
|
-
async ls(hash) {
|
|
569
|
+
async ls(hash, options) {
|
|
574
570
|
let data
|
|
575
571
|
const has = await dataStore.has(hash)
|
|
576
572
|
if (has) data = await dataStore.get(hash)
|
|
@@ -582,18 +578,19 @@ export default class Peernet {
|
|
|
582
578
|
for (const {path, hash} of node.decoded.links) {
|
|
583
579
|
paths.push({path, hash})
|
|
584
580
|
}
|
|
585
|
-
|
|
581
|
+
if (options?.pin) await dataStore.put(hash, node.encoded)
|
|
586
582
|
return paths
|
|
587
583
|
}
|
|
588
584
|
|
|
589
|
-
async cat(hash) {
|
|
585
|
+
async cat(hash, options) {
|
|
590
586
|
let data
|
|
591
587
|
const has = await dataStore.has(hash)
|
|
592
588
|
if (has) data = await dataStore.get(hash)
|
|
593
589
|
else data = await this.requestData(hash, 'data')
|
|
594
590
|
const node = await new peernet.protos['peernet-file'](data)
|
|
595
|
-
|
|
591
|
+
|
|
596
592
|
if (node.decoded?.links.length > 0) throw new Error(`${hash} is a directory`)
|
|
593
|
+
if (options?.pin) await dataStore.put(hash, node.encoded)
|
|
597
594
|
return node.decoded.content
|
|
598
595
|
}
|
|
599
596
|
|
|
@@ -705,3 +702,4 @@ export default class Peernet {
|
|
|
705
702
|
//
|
|
706
703
|
// }
|
|
707
704
|
}
|
|
705
|
+
globalThis.Peernet = Peernet
|
package/src/proto/file.proto.js
CHANGED
package/webpack.config.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const webpack = require('webpack');
|
|
3
3
|
module.exports = [{
|
|
4
|
-
entry:
|
|
4
|
+
entry: {
|
|
5
|
+
peernet: './dist/module/peernet.js'
|
|
6
|
+
},
|
|
5
7
|
mode: 'production',
|
|
6
8
|
plugins: [
|
|
7
9
|
// Work around for Buffer is undefined:
|
|
@@ -26,9 +28,9 @@ module.exports = [{
|
|
|
26
28
|
optimization: {
|
|
27
29
|
minimize: false
|
|
28
30
|
},
|
|
29
|
-
experiments: {
|
|
30
|
-
|
|
31
|
-
},
|
|
31
|
+
// experiments: {
|
|
32
|
+
// outputModule: true
|
|
33
|
+
// },
|
|
32
34
|
resolve: {
|
|
33
35
|
extensions: [ '.ts', '.js' ],
|
|
34
36
|
fallback: {
|
|
@@ -39,15 +41,19 @@ resolve: {
|
|
|
39
41
|
"path": require.resolve("path-browserify"),
|
|
40
42
|
"os": require.resolve("os-browserify"),
|
|
41
43
|
"crypto": require.resolve("crypto-browserify"),
|
|
42
|
-
"vm": require.resolve("vm-browserify")
|
|
44
|
+
"vm": require.resolve("vm-browserify"),
|
|
45
|
+
"@store:import": require.resolve("@leofcoin/storage/src/store-shim.js")
|
|
43
46
|
}
|
|
44
47
|
},
|
|
45
48
|
output: {
|
|
49
|
+
// library: {
|
|
50
|
+
// type: 'module'
|
|
51
|
+
// },
|
|
46
52
|
library: {
|
|
47
|
-
type: '
|
|
53
|
+
type: 'global'
|
|
48
54
|
},
|
|
49
55
|
chunkFilename: '[name].js',
|
|
50
|
-
filename: '
|
|
56
|
+
filename: '[name].js',
|
|
51
57
|
path: path.resolve(__dirname, 'dist', 'browser'),
|
|
52
58
|
},
|
|
53
59
|
}];
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
(self["webpackChunk_leofcoin_peernet"] = self["webpackChunk_leofcoin_peernet"] || []).push([[510],{
|
|
2
|
-
|
|
3
|
-
/***/ 5162:
|
|
4
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
-
|
|
6
|
-
__webpack_require__.r(__webpack_exports__);
|
|
7
|
-
/* harmony import */ var _leofcoin_multi_wallet__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9755);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @params {String} network
|
|
12
|
-
* @return {object} { identity, accounts, config }
|
|
13
|
-
*/
|
|
14
|
-
/* harmony default export */ __webpack_exports__["default"] = (async network => {
|
|
15
|
-
let wallet = new _leofcoin_multi_wallet__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z(network);
|
|
16
|
-
/**
|
|
17
|
-
* @type {string}
|
|
18
|
-
*/
|
|
19
|
-
const mnemonic = await wallet.generate();
|
|
20
|
-
|
|
21
|
-
wallet = new _leofcoin_multi_wallet__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z(network)
|
|
22
|
-
await wallet.recover(mnemonic, network)
|
|
23
|
-
/**
|
|
24
|
-
* @type {object}
|
|
25
|
-
*/
|
|
26
|
-
const account = wallet.account(0)
|
|
27
|
-
/**
|
|
28
|
-
* @type {object}
|
|
29
|
-
*/
|
|
30
|
-
const external = account.external(0)
|
|
31
|
-
const internal = account.internal(0)
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
identity: {
|
|
35
|
-
mnemonic,
|
|
36
|
-
// multiWIF: wallet.export(),
|
|
37
|
-
publicKey: external.publicKey,
|
|
38
|
-
privateKey: external.privateKey,
|
|
39
|
-
walletId: external.id
|
|
40
|
-
},
|
|
41
|
-
accounts: [['main account', external.address, internal.address]]
|
|
42
|
-
// config: {
|
|
43
|
-
// }
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/***/ })
|
|
49
|
-
|
|
50
|
-
}])
|
package/dist/browser/messages.js
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
(self["webpackChunk_leofcoin_peernet"] = self["webpackChunk_leofcoin_peernet"] || []).push([[158],{
|
|
2
|
-
|
|
3
|
-
/***/ 1331:
|
|
4
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
-
|
|
6
|
-
// ESM COMPAT FLAG
|
|
7
|
-
__webpack_require__.r(__webpack_exports__);
|
|
8
|
-
|
|
9
|
-
// EXPORTS
|
|
10
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
-
"ChatMessage": function() { return /* reexport */ ChatMessage; },
|
|
12
|
-
"DHTMessage": function() { return /* reexport */ DHTMessage; },
|
|
13
|
-
"DHTMessageResponse": function() { return /* reexport */ DHTMessageResponse; },
|
|
14
|
-
"DataMessage": function() { return /* reexport */ DataMessage; },
|
|
15
|
-
"DataMessageResponse": function() { return /* reexport */ DataMessageResponse; },
|
|
16
|
-
"PeerMessage": function() { return /* reexport */ PeerMessage; },
|
|
17
|
-
"PeerMessageResponse": function() { return /* reexport */ PeerMessageResponse; },
|
|
18
|
-
"PeernetFile": function() { return /* reexport */ PeernetFile; },
|
|
19
|
-
"PeernetMessage": function() { return /* reexport */ PeernetMessage; },
|
|
20
|
-
"PsMessage": function() { return /* reexport */ PsMessage; },
|
|
21
|
-
"RequestMessage": function() { return /* reexport */ RequestMessage; },
|
|
22
|
-
"ResponseMessage": function() { return /* reexport */ ResponseMessage; }
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
;// CONCATENATED MODULE: ./src/proto/peernet.proto.js
|
|
26
|
-
/* harmony default export */ var peernet_proto = (`
|
|
27
|
-
// PeernetMessage
|
|
28
|
-
message PeernetMessage {
|
|
29
|
-
required bytes data = 1;
|
|
30
|
-
required bytes signature = 2;
|
|
31
|
-
optional string from = 3;
|
|
32
|
-
optional string to = 4;
|
|
33
|
-
optional string id = 5;
|
|
34
|
-
}`);
|
|
35
|
-
|
|
36
|
-
// EXTERNAL MODULE: ./node_modules/@leofcoin/codec-format-interface/src/index.js + 9 modules
|
|
37
|
-
var src = __webpack_require__(6745);
|
|
38
|
-
;// CONCATENATED MODULE: ./src/messages/peernet.js
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class PeernetMessage extends src/* FormatInterface */.L1 {
|
|
43
|
-
get keys() {
|
|
44
|
-
return ['data', 'signature', 'from', 'to', 'id']
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get messageName() {
|
|
48
|
-
return 'PeernetMessage'
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
constructor(buffer) {
|
|
52
|
-
const name = 'peernet-message'
|
|
53
|
-
super(buffer, peernet_proto, {name})
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
;// CONCATENATED MODULE: ./src/proto/dht.proto.js
|
|
58
|
-
/* harmony default export */ var dht_proto = (`
|
|
59
|
-
// PeernetDHTMessage
|
|
60
|
-
message PeernetDHTMessage {
|
|
61
|
-
required string hash = 1;
|
|
62
|
-
optional string store = 2;
|
|
63
|
-
}
|
|
64
|
-
`);
|
|
65
|
-
|
|
66
|
-
;// CONCATENATED MODULE: ./src/messages/dht.js
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @example `
|
|
72
|
-
new DHTMessage(hash, store)
|
|
73
|
-
// store = optional if not set, peernet checks every store
|
|
74
|
-
let message = new DHTMessage('hashmvbs124xcfd...', 'transaction')
|
|
75
|
-
message = new DHTMessage('hashmvbs124xcfd...', 'block')
|
|
76
|
-
`
|
|
77
|
-
*/
|
|
78
|
-
class DHTMessage extends src/* FormatInterface */.L1 {
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
*/
|
|
82
|
-
get keys() {
|
|
83
|
-
return ['hash', 'store']
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
get messageName() {
|
|
87
|
-
return 'PeernetDHTMessage'
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
constructor(data) {
|
|
91
|
-
const name = 'peernet-dht'
|
|
92
|
-
super(data, dht_proto, {name})
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
;// CONCATENATED MODULE: ./src/proto/dht-response.proto.js
|
|
97
|
-
/* harmony default export */ var dht_response_proto = (`
|
|
98
|
-
// PeernetDHTMessageResponse
|
|
99
|
-
message PeernetDHTMessageResponse {
|
|
100
|
-
required string hash = 1;
|
|
101
|
-
required bool has = 2;
|
|
102
|
-
}
|
|
103
|
-
`);
|
|
104
|
-
|
|
105
|
-
;// CONCATENATED MODULE: ./src/messages/dht-response.js
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
class DHTMessageResponse extends src/* FormatInterface */.L1 {
|
|
110
|
-
get keys() {
|
|
111
|
-
return ['hash', 'has']
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
get messageName() {
|
|
115
|
-
return 'PeernetDHTMessageResponse'
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
constructor(data) {
|
|
119
|
-
const name = 'peernet-dht-response'
|
|
120
|
-
super(data, dht_response_proto, {name})
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
;// CONCATENATED MODULE: ./src/proto/data.proto.js
|
|
125
|
-
/* harmony default export */ var data_proto = (`
|
|
126
|
-
// PeernetDataMessage
|
|
127
|
-
message PeernetDataMessage {
|
|
128
|
-
required string hash = 1;
|
|
129
|
-
optional string store = 2;
|
|
130
|
-
}
|
|
131
|
-
`);
|
|
132
|
-
|
|
133
|
-
;// CONCATENATED MODULE: ./src/messages/data.js
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @extends {CodecFormat}
|
|
139
|
-
*/
|
|
140
|
-
class DataMessage extends src/* FormatInterface */.L1 {
|
|
141
|
-
get keys() {
|
|
142
|
-
return ['hash', 'store']
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
get messageName() {
|
|
146
|
-
return 'PeernetDataMessage'
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
150
|
-
*/
|
|
151
|
-
constructor(data) {
|
|
152
|
-
super(data, data_proto, {name: 'peernet-data'})
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
;// CONCATENATED MODULE: ./src/proto/ps.proto.js
|
|
157
|
-
/* harmony default export */ var ps_proto = (`
|
|
158
|
-
// PsMessage
|
|
159
|
-
message PsMessage {
|
|
160
|
-
required bytes data = 1;
|
|
161
|
-
required bytes topic = 2;
|
|
162
|
-
}`);
|
|
163
|
-
|
|
164
|
-
;// CONCATENATED MODULE: ./src/messages/ps.js
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
class PsMessage extends src/* FormatInterface */.L1 {
|
|
169
|
-
get keys() {
|
|
170
|
-
return ['data', 'topic']
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
get messageName() {
|
|
174
|
-
return 'PsMessage'
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
constructor(buffer) {
|
|
178
|
-
const name = 'peernet-ps'
|
|
179
|
-
super(buffer, ps_proto, {name})
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
;// CONCATENATED MODULE: ./src/proto/peer.proto.js
|
|
184
|
-
/* harmony default export */ var peer_proto = (`
|
|
185
|
-
// PeernetPeerMessage
|
|
186
|
-
message PeernetPeerMessage {
|
|
187
|
-
required string id = 1;
|
|
188
|
-
}
|
|
189
|
-
`);
|
|
190
|
-
|
|
191
|
-
;// CONCATENATED MODULE: ./src/messages/peer.js
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
class PeerMessage extends src/* FormatInterface */.L1 {
|
|
196
|
-
get keys() {
|
|
197
|
-
return ['id']
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
get messageName() {
|
|
201
|
-
return 'PeernetPeerMessage'
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
constructor(data) {
|
|
205
|
-
const name = 'peernet-peer'
|
|
206
|
-
super(data, peer_proto, {name})
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
;// CONCATENATED MODULE: ./src/proto/request.proto.js
|
|
211
|
-
/* harmony default export */ var request_proto = (`
|
|
212
|
-
// PeernetRequestMessage
|
|
213
|
-
message PeernetRequestMessage {
|
|
214
|
-
required string request = 1;
|
|
215
|
-
}
|
|
216
|
-
`);
|
|
217
|
-
|
|
218
|
-
;// CONCATENATED MODULE: ./src/messages/request.js
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
class RequestMessage extends src/* FormatInterface */.L1 {
|
|
223
|
-
get keys() {
|
|
224
|
-
return ['request']
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
get messageName() {
|
|
228
|
-
return 'PeernetRequestMessage'
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
constructor(data) {
|
|
232
|
-
const name = 'peernet-request'
|
|
233
|
-
super(data, request_proto, {name})
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
;// CONCATENATED MODULE: ./src/proto/response.proto.js
|
|
238
|
-
/* harmony default export */ var response_proto = (`
|
|
239
|
-
// PeernetResponseMessage
|
|
240
|
-
message PeernetResponseMessage {
|
|
241
|
-
required bytes response = 1;
|
|
242
|
-
}
|
|
243
|
-
`);
|
|
244
|
-
|
|
245
|
-
;// CONCATENATED MODULE: ./src/messages/response.js
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
class ResponseMessage extends src/* FormatInterface */.L1 {
|
|
250
|
-
get keys() {
|
|
251
|
-
return ['response']
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
get messageName() {
|
|
255
|
-
return 'PeernetResponseMessage'
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
constructor(data) {
|
|
259
|
-
const name = 'peernet-response'
|
|
260
|
-
super(data, response_proto, {name})
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
;// CONCATENATED MODULE: ./src/proto/peer-response.proto.js
|
|
265
|
-
/* harmony default export */ var peer_response_proto = (`
|
|
266
|
-
// PeernetPeerMessageResponse
|
|
267
|
-
message PeernetPeerMessageResponse {
|
|
268
|
-
required string id = 1;
|
|
269
|
-
}
|
|
270
|
-
`);
|
|
271
|
-
|
|
272
|
-
;// CONCATENATED MODULE: ./src/messages/peer-response.js
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
class PeerMessageResponse extends src/* FormatInterface */.L1 {
|
|
277
|
-
get keys() {
|
|
278
|
-
return ['id']
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
get messageName() {
|
|
282
|
-
return 'PeernetPeerMessageResponse'
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
constructor(data) {
|
|
286
|
-
const name = 'peernet-peer-response'
|
|
287
|
-
super(data, peer_response_proto, {name})
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
;// CONCATENATED MODULE: ./src/proto/data-response.proto.js
|
|
292
|
-
/* harmony default export */ var data_response_proto = (`
|
|
293
|
-
// PeernetDataMessageResponse
|
|
294
|
-
message PeernetDataMessageResponse {
|
|
295
|
-
required string hash = 1;
|
|
296
|
-
required bytes data = 2;
|
|
297
|
-
}
|
|
298
|
-
`);
|
|
299
|
-
|
|
300
|
-
;// CONCATENATED MODULE: ./src/messages/data-response.js
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
class DataMessageResponse extends src/* FormatInterface */.L1 {
|
|
305
|
-
get keys() {
|
|
306
|
-
return ['hash', 'data']
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
get messageName() {
|
|
310
|
-
return 'PeernetDataMessageResponse'
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
constructor(data) {
|
|
314
|
-
const name = 'peernet-data-response'
|
|
315
|
-
super(data, data_response_proto, {name})
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
;// CONCATENATED MODULE: ./src/proto/chat-message.proto.js
|
|
320
|
-
/* harmony default export */ var chat_message_proto = (`
|
|
321
|
-
message ChatMessage {
|
|
322
|
-
required string value = 1;
|
|
323
|
-
required string author = 2;
|
|
324
|
-
required uint64 timestamp = 3;
|
|
325
|
-
repeated string files = 4;
|
|
326
|
-
}`);
|
|
327
|
-
|
|
328
|
-
;// CONCATENATED MODULE: ./src/messages/chat.js
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
class ChatMessage extends src/* FormatInterface */.L1 {
|
|
333
|
-
get keys() {
|
|
334
|
-
return ['author', 'value', 'timestamp', 'files']
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
get messageName() {
|
|
338
|
-
return 'ChatMessage'
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
constructor(buffer) {
|
|
342
|
-
const name = 'chat-message'
|
|
343
|
-
super(buffer, chat_message_proto, {name})
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
;// CONCATENATED MODULE: ./src/proto/file.proto.js
|
|
348
|
-
/* harmony default export */ var file_proto = (`
|
|
349
|
-
// PeernetFolder
|
|
350
|
-
message PeernetFileLink {
|
|
351
|
-
required string hash = 1;
|
|
352
|
-
required string path = 2;
|
|
353
|
-
optional string size = 3;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
message PeernetFile {
|
|
357
|
-
required string path = 1;
|
|
358
|
-
optional bytes content = 2;
|
|
359
|
-
repeated PeernetFileLink links = 3;
|
|
360
|
-
}
|
|
361
|
-
`);
|
|
362
|
-
|
|
363
|
-
;// CONCATENATED MODULE: ./src/messages/file.js
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @extends {CodecFormat}
|
|
369
|
-
*/
|
|
370
|
-
class PeernetFile extends src/* FormatInterface */.L1 {
|
|
371
|
-
get keys() {
|
|
372
|
-
return ['path', 'content', 'links']
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
get messageName() {
|
|
376
|
-
return 'PeernetFile'
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
380
|
-
*/
|
|
381
|
-
constructor(data) {
|
|
382
|
-
super(data, file_proto, {name: 'peernet-file'})
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
;// CONCATENATED MODULE: ./src/messages.js
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
// export { default as FolderMessageResponse } from './messages/folder-response.js'
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
/***/ })
|
|
403
|
-
|
|
404
|
-
}])
|