@leofcoin/peernet 1.2.6 → 1.2.7
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/exports/browser/{client-1JlanVkr.js → client-AodRTAgI.js} +1 -1
- package/exports/browser/{messages-pDchwT17.js → messages-Dy2W05lC.js} +1 -1
- package/exports/browser/{peernet-CpcIFBTX.js → peernet-Cmg8trCq.js} +2 -51
- package/exports/browser/peernet.js +1 -1
- package/exports/peernet.js +1 -50
- package/exports/types/peernet.d.ts +2 -2
- package/package.json +225 -7
- package/rollup.config.js +7 -1
- package/src/messages.js +0 -1
- package/src/peernet.ts +2 -57
- package/exports/browser/dht/dht.d.ts +0 -38
- package/exports/browser/discovery/peer-discovery.d.ts +0 -7
- package/exports/browser/errors/errors.d.ts +0 -3
- package/exports/browser/handlers/data.d.ts +0 -2
- package/exports/browser/handlers/message.d.ts +0 -30
- package/exports/browser/identity.d.ts +0 -19
- package/exports/browser/messages/data.d.ts +0 -10
- package/exports/browser/messages/file-link.d.ts +0 -10
- package/exports/browser/messages/file.d.ts +0 -10
- package/exports/browser/messages.d.ts +0 -12
- package/exports/browser/peer-info.d.ts +0 -4
- package/exports/browser/peernet.d.ts +0 -301
- package/exports/browser/prompts/password/browser.d.ts +0 -2
- package/exports/browser/prompts/password/node.d.ts +0 -2
- package/exports/browser/proto/chat-message.proto.d.ts +0 -7
- package/exports/browser/proto/data-response.proto.d.ts +0 -5
- package/exports/browser/proto/data.proto.d.ts +0 -5
- package/exports/browser/proto/dht-response.proto.d.ts +0 -5
- package/exports/browser/proto/dht.proto.d.ts +0 -5
- package/exports/browser/proto/file-link.proto.d.ts +0 -6
- package/exports/browser/proto/file.proto.d.ts +0 -6
- package/exports/browser/proto/peer-response.proto.d.ts +0 -4
- package/exports/browser/proto/peer.proto.d.ts +0 -4
- package/exports/browser/proto/peernet.proto.d.ts +0 -8
- package/exports/browser/proto/ps.proto.d.ts +0 -5
- package/exports/browser/proto/request.proto.d.ts +0 -5
- package/exports/browser/proto/response.proto.d.ts +0 -4
- package/exports/browser/types.d.ts +0 -15
- package/exports/browser/utils/utils.d.ts +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-
|
|
1
|
+
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-Cmg8trCq.js';
|
|
2
2
|
import './identity-nIyW_Xm8.js';
|
|
3
3
|
import './value-C3vAp-wb.js';
|
|
4
4
|
|
|
@@ -8383,9 +8383,7 @@ class Peernet {
|
|
|
8383
8383
|
await getAddress();
|
|
8384
8384
|
this.storePrefix = options.storePrefix;
|
|
8385
8385
|
this.root = options.root;
|
|
8386
|
-
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
8387
|
-
// FolderMessageResponse
|
|
8388
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-pDchwT17.js');
|
|
8386
|
+
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-Dy2W05lC.js');
|
|
8389
8387
|
/**
|
|
8390
8388
|
* proto Object containing protos
|
|
8391
8389
|
* @type {Object}
|
|
@@ -8419,58 +8417,11 @@ class Peernet {
|
|
|
8419
8417
|
await this.identity.load(password);
|
|
8420
8418
|
this._peerHandler = new PeerDiscovery(this.id);
|
|
8421
8419
|
this.peerId = this.id;
|
|
8422
|
-
// this.addRequestHandler('handshake', () => {
|
|
8423
|
-
// return new peernet.protos['peernet-response']({
|
|
8424
|
-
// response: { peerId: this.id }
|
|
8425
|
-
// })
|
|
8426
|
-
// })
|
|
8427
|
-
// pubsub.subscribe('peer:discovered', async (peer) => {
|
|
8428
|
-
// // console.log(peer);
|
|
8429
|
-
// if (this.requestProtos['version'] && !peer.version) {
|
|
8430
|
-
// let data = await new globalThis.peernet.protos['peernet-request']({
|
|
8431
|
-
// request: 'version'
|
|
8432
|
-
// })
|
|
8433
|
-
// let node = await globalThis.peernet.prepareMessage(data)
|
|
8434
|
-
// let response = await peer.request(node.encoded)
|
|
8435
|
-
// response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)))
|
|
8436
|
-
// peer.version = response.decoded.response.version
|
|
8437
|
-
// }
|
|
8438
|
-
// if (!peer.peerId) {
|
|
8439
|
-
// let data = await new globalThis.peernet.protos['peernet-request']({
|
|
8440
|
-
// request: 'handshake'
|
|
8441
|
-
// })
|
|
8442
|
-
// let node = await globalThis.peernet.prepareMessage(data)
|
|
8443
|
-
// let response = await peer.request(node.encoded)
|
|
8444
|
-
// response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)))
|
|
8445
|
-
// // todo: response.decoded should be the response and not response.peerId
|
|
8446
|
-
// // todo: ignore above and remove discover completly
|
|
8447
|
-
// response.decoded.response.peerId
|
|
8448
|
-
// }
|
|
8449
|
-
// this.connections[peer.peerId] = peer
|
|
8450
|
-
// pubsub.publish('peer:connected', peer)
|
|
8451
|
-
// todo: cleanup discovered
|
|
8452
|
-
// })
|
|
8453
|
-
// pubsub.subscribe('peer:left', this.#peerLeft.bind(this))
|
|
8454
8420
|
/**
|
|
8455
8421
|
* converts data -> message -> proto
|
|
8456
8422
|
* @see DataHandler
|
|
8457
8423
|
*/
|
|
8458
8424
|
pubsub.subscribe('peer:data', dataHandler);
|
|
8459
|
-
// // todo: remove below, already handles in the swarm
|
|
8460
|
-
// if (globalThis.navigator) {
|
|
8461
|
-
// globalThis.addEventListener('beforeunload', async () => this.client.close())
|
|
8462
|
-
// } else {
|
|
8463
|
-
// process.on('SIGTERM', async () => {
|
|
8464
|
-
// process.stdin.resume()
|
|
8465
|
-
// try {
|
|
8466
|
-
// await this.client.close()
|
|
8467
|
-
// } catch (error) {
|
|
8468
|
-
// // @ts-ignore
|
|
8469
|
-
// await this.client.close()
|
|
8470
|
-
// }
|
|
8471
|
-
// process.exit()
|
|
8472
|
-
// })
|
|
8473
|
-
// }
|
|
8474
8425
|
if (this.autoStart)
|
|
8475
8426
|
await this.start();
|
|
8476
8427
|
return this;
|
|
@@ -8479,7 +8430,7 @@ class Peernet {
|
|
|
8479
8430
|
if (this.#starting || this.#started)
|
|
8480
8431
|
return;
|
|
8481
8432
|
this.#starting = true;
|
|
8482
|
-
const importee = await import('./client-
|
|
8433
|
+
const importee = await import('./client-AodRTAgI.js');
|
|
8483
8434
|
/**
|
|
8484
8435
|
* @access public
|
|
8485
8436
|
* @type {PeernetClient}
|
package/exports/peernet.js
CHANGED
|
@@ -451,9 +451,7 @@ class Peernet {
|
|
|
451
451
|
await getAddress();
|
|
452
452
|
this.storePrefix = options.storePrefix;
|
|
453
453
|
this.root = options.root;
|
|
454
|
-
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
455
|
-
// FolderMessageResponse
|
|
456
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-C9lYBAhD.js');
|
|
454
|
+
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-C9lYBAhD.js');
|
|
457
455
|
/**
|
|
458
456
|
* proto Object containing protos
|
|
459
457
|
* @type {Object}
|
|
@@ -487,58 +485,11 @@ class Peernet {
|
|
|
487
485
|
await this.identity.load(password);
|
|
488
486
|
this._peerHandler = new PeerDiscovery(this.id);
|
|
489
487
|
this.peerId = this.id;
|
|
490
|
-
// this.addRequestHandler('handshake', () => {
|
|
491
|
-
// return new peernet.protos['peernet-response']({
|
|
492
|
-
// response: { peerId: this.id }
|
|
493
|
-
// })
|
|
494
|
-
// })
|
|
495
|
-
// pubsub.subscribe('peer:discovered', async (peer) => {
|
|
496
|
-
// // console.log(peer);
|
|
497
|
-
// if (this.requestProtos['version'] && !peer.version) {
|
|
498
|
-
// let data = await new globalThis.peernet.protos['peernet-request']({
|
|
499
|
-
// request: 'version'
|
|
500
|
-
// })
|
|
501
|
-
// let node = await globalThis.peernet.prepareMessage(data)
|
|
502
|
-
// let response = await peer.request(node.encoded)
|
|
503
|
-
// response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)))
|
|
504
|
-
// peer.version = response.decoded.response.version
|
|
505
|
-
// }
|
|
506
|
-
// if (!peer.peerId) {
|
|
507
|
-
// let data = await new globalThis.peernet.protos['peernet-request']({
|
|
508
|
-
// request: 'handshake'
|
|
509
|
-
// })
|
|
510
|
-
// let node = await globalThis.peernet.prepareMessage(data)
|
|
511
|
-
// let response = await peer.request(node.encoded)
|
|
512
|
-
// response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)))
|
|
513
|
-
// // todo: response.decoded should be the response and not response.peerId
|
|
514
|
-
// // todo: ignore above and remove discover completly
|
|
515
|
-
// response.decoded.response.peerId
|
|
516
|
-
// }
|
|
517
|
-
// this.connections[peer.peerId] = peer
|
|
518
|
-
// pubsub.publish('peer:connected', peer)
|
|
519
|
-
// todo: cleanup discovered
|
|
520
|
-
// })
|
|
521
|
-
// pubsub.subscribe('peer:left', this.#peerLeft.bind(this))
|
|
522
488
|
/**
|
|
523
489
|
* converts data -> message -> proto
|
|
524
490
|
* @see DataHandler
|
|
525
491
|
*/
|
|
526
492
|
pubsub.subscribe('peer:data', dataHandler);
|
|
527
|
-
// // todo: remove below, already handles in the swarm
|
|
528
|
-
// if (globalThis.navigator) {
|
|
529
|
-
// globalThis.addEventListener('beforeunload', async () => this.client.close())
|
|
530
|
-
// } else {
|
|
531
|
-
// process.on('SIGTERM', async () => {
|
|
532
|
-
// process.stdin.resume()
|
|
533
|
-
// try {
|
|
534
|
-
// await this.client.close()
|
|
535
|
-
// } catch (error) {
|
|
536
|
-
// // @ts-ignore
|
|
537
|
-
// await this.client.close()
|
|
538
|
-
// }
|
|
539
|
-
// process.exit()
|
|
540
|
-
// })
|
|
541
|
-
// }
|
|
542
493
|
if (this.autoStart)
|
|
543
494
|
await this.start();
|
|
544
495
|
return this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import PubSub from '@vandeurenglenn/little-pubsub';
|
|
1
|
+
import PubSub, { Handler } from '@vandeurenglenn/little-pubsub';
|
|
2
2
|
import PeerDiscovery from './discovery/peer-discovery.js';
|
|
3
3
|
import DHT from './dht/dht.js';
|
|
4
4
|
import MessageHandler from './handlers/message.js';
|
|
@@ -295,7 +295,7 @@ export default class Peernet {
|
|
|
295
295
|
* @param {String} topic
|
|
296
296
|
* @param {Method} cb
|
|
297
297
|
*/
|
|
298
|
-
subscribe(topic: string, callback:
|
|
298
|
+
subscribe(topic: string, callback: Handler): Promise<void>;
|
|
299
299
|
removePeer(peer: any): Promise<void>;
|
|
300
300
|
get Buffer(): BufferConstructor;
|
|
301
301
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,237 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "./exports/browser/peernet.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./exports/peernet.js",
|
|
9
|
-
"require": "./exports/commonjs/peernet.js",
|
|
10
9
|
"types": "./exports/types/peernet.d.ts"
|
|
11
10
|
},
|
|
11
|
+
"./browser": {
|
|
12
|
+
"import": "././exports/browser.js",
|
|
13
|
+
"types": "./exports/types/prompts/password/browser.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./browser.js": {
|
|
16
|
+
"import": "././exports/browser.js",
|
|
17
|
+
"types": "./exports/types/prompts/password/browser.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./chat-message.proto": {
|
|
20
|
+
"import": "././exports/chat-message.proto.js",
|
|
21
|
+
"types": "./exports/types/proto/chat-message.proto.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./chat-message.proto.js": {
|
|
24
|
+
"import": "././exports/chat-message.proto.js",
|
|
25
|
+
"types": "./exports/types/proto/chat-message.proto.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./data-response.proto": {
|
|
28
|
+
"import": "././exports/data-response.proto.js",
|
|
29
|
+
"types": "./exports/types/proto/data-response.proto.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./data-response.proto.js": {
|
|
32
|
+
"import": "././exports/data-response.proto.js",
|
|
33
|
+
"types": "./exports/types/proto/data-response.proto.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./data": {
|
|
36
|
+
"import": "././exports/data.js",
|
|
37
|
+
"types": "./exports/types/handlers/data.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./data.js": {
|
|
40
|
+
"import": "././exports/data.js",
|
|
41
|
+
"types": "./exports/types/handlers/data.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./data.proto": {
|
|
44
|
+
"import": "././exports/data.proto.js",
|
|
45
|
+
"types": "./exports/types/proto/data.proto.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./data.proto.js": {
|
|
48
|
+
"import": "././exports/data.proto.js",
|
|
49
|
+
"types": "./exports/types/proto/data.proto.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./dht-response.proto": {
|
|
52
|
+
"import": "././exports/dht-response.proto.js",
|
|
53
|
+
"types": "./exports/types/proto/dht-response.proto.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./dht-response.proto.js": {
|
|
56
|
+
"import": "././exports/dht-response.proto.js",
|
|
57
|
+
"types": "./exports/types/proto/dht-response.proto.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./dht": {
|
|
60
|
+
"import": "././exports/dht.js",
|
|
61
|
+
"types": "./exports/types/dht/dht.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./dht.js": {
|
|
64
|
+
"import": "././exports/dht.js",
|
|
65
|
+
"types": "./exports/types/dht/dht.d.ts"
|
|
66
|
+
},
|
|
67
|
+
"./dht.proto": {
|
|
68
|
+
"import": "././exports/dht.proto.js",
|
|
69
|
+
"types": "./exports/types/proto/dht.proto.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./dht.proto.js": {
|
|
72
|
+
"import": "././exports/dht.proto.js",
|
|
73
|
+
"types": "./exports/types/proto/dht.proto.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./errors": {
|
|
76
|
+
"import": "././exports/errors.js",
|
|
77
|
+
"types": "./exports/types/errors/errors.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./errors.js": {
|
|
80
|
+
"import": "././exports/errors.js",
|
|
81
|
+
"types": "./exports/types/errors/errors.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./file-link": {
|
|
84
|
+
"import": "././exports/file-link.js",
|
|
85
|
+
"types": "./exports/types/messages/file-link.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"./file-link.js": {
|
|
88
|
+
"import": "././exports/file-link.js",
|
|
89
|
+
"types": "./exports/types/messages/file-link.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./file-link.proto": {
|
|
92
|
+
"import": "././exports/file-link.proto.js",
|
|
93
|
+
"types": "./exports/types/proto/file-link.proto.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./file-link.proto.js": {
|
|
96
|
+
"import": "././exports/file-link.proto.js",
|
|
97
|
+
"types": "./exports/types/proto/file-link.proto.d.ts"
|
|
98
|
+
},
|
|
99
|
+
"./file": {
|
|
100
|
+
"import": "././exports/file.js",
|
|
101
|
+
"types": "./exports/types/messages/file.d.ts"
|
|
102
|
+
},
|
|
103
|
+
"./file.js": {
|
|
104
|
+
"import": "././exports/file.js",
|
|
105
|
+
"types": "./exports/types/messages/file.d.ts"
|
|
106
|
+
},
|
|
107
|
+
"./file.proto": {
|
|
108
|
+
"import": "././exports/file.proto.js",
|
|
109
|
+
"types": "./exports/types/proto/file.proto.d.ts"
|
|
110
|
+
},
|
|
111
|
+
"./file.proto.js": {
|
|
112
|
+
"import": "././exports/file.proto.js",
|
|
113
|
+
"types": "./exports/types/proto/file.proto.d.ts"
|
|
114
|
+
},
|
|
12
115
|
"./identity": {
|
|
13
|
-
"import": "
|
|
14
|
-
"require": "./exports/commonjs/identity.js",
|
|
116
|
+
"import": "././exports/identity.js",
|
|
15
117
|
"types": "./exports/types/identity.d.ts"
|
|
16
118
|
},
|
|
17
|
-
"./
|
|
119
|
+
"./identity.js": {
|
|
120
|
+
"import": "././exports/identity.js",
|
|
121
|
+
"types": "./exports/types/identity.d.ts"
|
|
122
|
+
},
|
|
123
|
+
"./message": {
|
|
124
|
+
"import": "././exports/message.js",
|
|
125
|
+
"types": "./exports/types/handlers/message.d.ts"
|
|
126
|
+
},
|
|
127
|
+
"./message.js": {
|
|
128
|
+
"import": "././exports/message.js",
|
|
129
|
+
"types": "./exports/types/handlers/message.d.ts"
|
|
130
|
+
},
|
|
131
|
+
"./messages": {
|
|
132
|
+
"import": "././exports/messages.js",
|
|
133
|
+
"types": "./exports/types/messages.d.ts"
|
|
134
|
+
},
|
|
135
|
+
"./messages.js": {
|
|
136
|
+
"import": "././exports/messages.js",
|
|
137
|
+
"types": "./exports/types/messages.d.ts"
|
|
138
|
+
},
|
|
139
|
+
"./node": {
|
|
140
|
+
"import": "././exports/node.js",
|
|
141
|
+
"types": "./exports/types/prompts/password/node.d.ts"
|
|
142
|
+
},
|
|
143
|
+
"./node.js": {
|
|
144
|
+
"import": "././exports/node.js",
|
|
145
|
+
"types": "./exports/types/prompts/password/node.d.ts"
|
|
146
|
+
},
|
|
147
|
+
"./peer-discovery": {
|
|
148
|
+
"import": "././exports/peer-discovery.js",
|
|
149
|
+
"types": "./exports/types/discovery/peer-discovery.d.ts"
|
|
150
|
+
},
|
|
151
|
+
"./peer-discovery.js": {
|
|
152
|
+
"import": "././exports/peer-discovery.js",
|
|
153
|
+
"types": "./exports/types/discovery/peer-discovery.d.ts"
|
|
154
|
+
},
|
|
155
|
+
"./peer-info": {
|
|
156
|
+
"import": "././exports/peer-info.js",
|
|
157
|
+
"types": "./exports/types/peer-info.d.ts"
|
|
158
|
+
},
|
|
159
|
+
"./peer-info.js": {
|
|
160
|
+
"import": "././exports/peer-info.js",
|
|
161
|
+
"types": "./exports/types/peer-info.d.ts"
|
|
162
|
+
},
|
|
163
|
+
"./peer-response.proto": {
|
|
164
|
+
"import": "././exports/peer-response.proto.js",
|
|
165
|
+
"types": "./exports/types/proto/peer-response.proto.d.ts"
|
|
166
|
+
},
|
|
167
|
+
"./peer-response.proto.js": {
|
|
168
|
+
"import": "././exports/peer-response.proto.js",
|
|
169
|
+
"types": "./exports/types/proto/peer-response.proto.d.ts"
|
|
170
|
+
},
|
|
171
|
+
"./peer.proto": {
|
|
172
|
+
"import": "././exports/peer.proto.js",
|
|
173
|
+
"types": "./exports/types/proto/peer.proto.d.ts"
|
|
174
|
+
},
|
|
175
|
+
"./peer.proto.js": {
|
|
176
|
+
"import": "././exports/peer.proto.js",
|
|
177
|
+
"types": "./exports/types/proto/peer.proto.d.ts"
|
|
178
|
+
},
|
|
179
|
+
"./peernet": {
|
|
180
|
+
"import": "././exports/peernet.js",
|
|
181
|
+
"types": "./exports/types/peernet.d.ts"
|
|
182
|
+
},
|
|
183
|
+
"./peernet.js": {
|
|
184
|
+
"import": "././exports/peernet.js",
|
|
185
|
+
"types": "./exports/types/peernet.d.ts"
|
|
186
|
+
},
|
|
187
|
+
"./peernet.proto": {
|
|
188
|
+
"import": "././exports/peernet.proto.js",
|
|
189
|
+
"types": "./exports/types/proto/peernet.proto.d.ts"
|
|
190
|
+
},
|
|
191
|
+
"./peernet.proto.js": {
|
|
192
|
+
"import": "././exports/peernet.proto.js",
|
|
193
|
+
"types": "./exports/types/proto/peernet.proto.d.ts"
|
|
194
|
+
},
|
|
195
|
+
"./ps.proto": {
|
|
196
|
+
"import": "././exports/ps.proto.js",
|
|
197
|
+
"types": "./exports/types/proto/ps.proto.d.ts"
|
|
198
|
+
},
|
|
199
|
+
"./ps.proto.js": {
|
|
200
|
+
"import": "././exports/ps.proto.js",
|
|
201
|
+
"types": "./exports/types/proto/ps.proto.d.ts"
|
|
202
|
+
},
|
|
203
|
+
"./request.proto": {
|
|
204
|
+
"import": "././exports/request.proto.js",
|
|
205
|
+
"types": "./exports/types/proto/request.proto.d.ts"
|
|
206
|
+
},
|
|
207
|
+
"./request.proto.js": {
|
|
208
|
+
"import": "././exports/request.proto.js",
|
|
209
|
+
"types": "./exports/types/proto/request.proto.d.ts"
|
|
210
|
+
},
|
|
211
|
+
"./response.proto": {
|
|
212
|
+
"import": "././exports/response.proto.js",
|
|
213
|
+
"types": "./exports/types/proto/response.proto.d.ts"
|
|
214
|
+
},
|
|
215
|
+
"./response.proto.js": {
|
|
216
|
+
"import": "././exports/response.proto.js",
|
|
217
|
+
"types": "./exports/types/proto/response.proto.d.ts"
|
|
218
|
+
},
|
|
219
|
+
"./types": {
|
|
220
|
+
"import": "././exports/types.js",
|
|
221
|
+
"types": "./exports/types/types.d.ts"
|
|
222
|
+
},
|
|
223
|
+
"./types.js": {
|
|
224
|
+
"import": "././exports/types.js",
|
|
225
|
+
"types": "./exports/types/types.d.ts"
|
|
226
|
+
},
|
|
227
|
+
"./utils": {
|
|
228
|
+
"import": "././exports/utils.js",
|
|
229
|
+
"types": "./exports/types/utils/utils.d.ts"
|
|
230
|
+
},
|
|
231
|
+
"./utils.js": {
|
|
232
|
+
"import": "././exports/utils.js",
|
|
233
|
+
"types": "./exports/types/utils/utils.d.ts"
|
|
234
|
+
}
|
|
18
235
|
},
|
|
19
236
|
"type": "module",
|
|
20
237
|
"engines": {
|
|
@@ -38,7 +255,7 @@
|
|
|
38
255
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
39
256
|
"@leofcoin/storage": "^3.5.38",
|
|
40
257
|
"@mapbox/node-pre-gyp": "^2.0.3",
|
|
41
|
-
"@netpeer/swarm": "^0.9.
|
|
258
|
+
"@netpeer/swarm": "^0.9.3",
|
|
42
259
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
43
260
|
"@vandeurenglenn/debug": "^1.4.0",
|
|
44
261
|
"@vandeurenglenn/little-pubsub": "^1.5.2",
|
|
@@ -55,6 +272,7 @@
|
|
|
55
272
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
56
273
|
"@types/node": "^25.2.0",
|
|
57
274
|
"@types/qrcode": "^1.5.6",
|
|
58
|
-
"rollup": "^4.57.1"
|
|
275
|
+
"rollup": "^4.57.1",
|
|
276
|
+
"rollup-plugin-auto-exports": "^1.1.1"
|
|
59
277
|
}
|
|
60
278
|
}
|
package/rollup.config.js
CHANGED
|
@@ -4,6 +4,7 @@ import json from '@rollup/plugin-json'
|
|
|
4
4
|
import wasm from '@rollup/plugin-wasm'
|
|
5
5
|
import rimraf from 'rimraf'
|
|
6
6
|
import typescript from '@rollup/plugin-typescript'
|
|
7
|
+
import autoExports from 'rollup-plugin-auto-exports'
|
|
7
8
|
|
|
8
9
|
rimraf.sync('./exports/**')
|
|
9
10
|
|
|
@@ -26,7 +27,7 @@ export default [
|
|
|
26
27
|
mainFields: ['browser', 'module', 'main']
|
|
27
28
|
}),
|
|
28
29
|
|
|
29
|
-
typescript({ compilerOptions: { outDir: './exports/browser' } })
|
|
30
|
+
typescript({ compilerOptions: { outDir: './exports/browser', declaration: false } })
|
|
30
31
|
],
|
|
31
32
|
external: ['./prompts/password.js']
|
|
32
33
|
},
|
|
@@ -42,6 +43,11 @@ export default [
|
|
|
42
43
|
outDir: './exports',
|
|
43
44
|
declarationDir: './exports/types'
|
|
44
45
|
}
|
|
46
|
+
}),
|
|
47
|
+
autoExports({
|
|
48
|
+
defaultExports: {
|
|
49
|
+
'.': { import: './exports/peernet.js', types: './exports/types/peernet.d.ts' }
|
|
50
|
+
}
|
|
45
51
|
})
|
|
46
52
|
],
|
|
47
53
|
external: ['./prompts/password.js']
|
package/src/messages.js
CHANGED
|
@@ -10,4 +10,3 @@ export { default as PeerMessageResponse } from './messages/peer-response.js'
|
|
|
10
10
|
export { default as DataMessageResponse } from './messages/data-response.js'
|
|
11
11
|
export { default as ChatMessage } from './messages/chat.js'
|
|
12
12
|
export { default as PeernetFile } from './messages/file.js'
|
|
13
|
-
// export { default as FolderMessageResponse } from './messages/folder-response.js'
|
package/src/peernet.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDebugger } from '@vandeurenglenn/debug'
|
|
2
|
-
import PubSub from '@vandeurenglenn/little-pubsub'
|
|
2
|
+
import PubSub, { Handler } from '@vandeurenglenn/little-pubsub'
|
|
3
3
|
import PeerDiscovery from './discovery/peer-discovery.js'
|
|
4
4
|
import DHT, { DHTProvider, DHTProviderDistanceResult, getAddress } from './dht/dht.js'
|
|
5
5
|
import { BufferToUint8Array, protoFor, target } from './utils/utils.js'
|
|
@@ -214,7 +214,6 @@ export default class Peernet {
|
|
|
214
214
|
PsMessage,
|
|
215
215
|
ChatMessage,
|
|
216
216
|
PeernetFile
|
|
217
|
-
// FolderMessageResponse
|
|
218
217
|
} = await import(/* webpackChunkName: "messages" */ './messages.js')
|
|
219
218
|
|
|
220
219
|
/**
|
|
@@ -257,66 +256,12 @@ export default class Peernet {
|
|
|
257
256
|
this._peerHandler = new PeerDiscovery(this.id)
|
|
258
257
|
this.peerId = this.id
|
|
259
258
|
|
|
260
|
-
// this.addRequestHandler('handshake', () => {
|
|
261
|
-
// return new peernet.protos['peernet-response']({
|
|
262
|
-
// response: { peerId: this.id }
|
|
263
|
-
// })
|
|
264
|
-
// })
|
|
265
|
-
|
|
266
|
-
// pubsub.subscribe('peer:discovered', async (peer) => {
|
|
267
|
-
// // console.log(peer);
|
|
268
|
-
|
|
269
|
-
// if (this.requestProtos['version'] && !peer.version) {
|
|
270
|
-
// let data = await new globalThis.peernet.protos['peernet-request']({
|
|
271
|
-
// request: 'version'
|
|
272
|
-
// })
|
|
273
|
-
// let node = await globalThis.peernet.prepareMessage(data)
|
|
274
|
-
// let response = await peer.request(node.encoded)
|
|
275
|
-
// response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)))
|
|
276
|
-
// peer.version = response.decoded.response.version
|
|
277
|
-
// }
|
|
278
|
-
|
|
279
|
-
// if (!peer.peerId) {
|
|
280
|
-
// let data = await new globalThis.peernet.protos['peernet-request']({
|
|
281
|
-
// request: 'handshake'
|
|
282
|
-
// })
|
|
283
|
-
// let node = await globalThis.peernet.prepareMessage(data)
|
|
284
|
-
// let response = await peer.request(node.encoded)
|
|
285
|
-
|
|
286
|
-
// response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)))
|
|
287
|
-
// // todo: response.decoded should be the response and not response.peerId
|
|
288
|
-
// // todo: ignore above and remove discover completly
|
|
289
|
-
// response.decoded.response.peerId
|
|
290
|
-
// }
|
|
291
|
-
|
|
292
|
-
// this.connections[peer.peerId] = peer
|
|
293
|
-
// pubsub.publish('peer:connected', peer)
|
|
294
|
-
// todo: cleanup discovered
|
|
295
|
-
// })
|
|
296
|
-
|
|
297
|
-
// pubsub.subscribe('peer:left', this.#peerLeft.bind(this))
|
|
298
|
-
|
|
299
259
|
/**
|
|
300
260
|
* converts data -> message -> proto
|
|
301
261
|
* @see DataHandler
|
|
302
262
|
*/
|
|
303
263
|
pubsub.subscribe('peer:data', dataHandler)
|
|
304
264
|
|
|
305
|
-
// // todo: remove below, already handles in the swarm
|
|
306
|
-
// if (globalThis.navigator) {
|
|
307
|
-
// globalThis.addEventListener('beforeunload', async () => this.client.close())
|
|
308
|
-
// } else {
|
|
309
|
-
// process.on('SIGTERM', async () => {
|
|
310
|
-
// process.stdin.resume()
|
|
311
|
-
// try {
|
|
312
|
-
// await this.client.close()
|
|
313
|
-
// } catch (error) {
|
|
314
|
-
// // @ts-ignore
|
|
315
|
-
// await this.client.close()
|
|
316
|
-
// }
|
|
317
|
-
// process.exit()
|
|
318
|
-
// })
|
|
319
|
-
// }
|
|
320
265
|
if (this.autoStart) await this.start()
|
|
321
266
|
return this
|
|
322
267
|
}
|
|
@@ -957,7 +902,7 @@ export default class Peernet {
|
|
|
957
902
|
* @param {String} topic
|
|
958
903
|
* @param {Method} cb
|
|
959
904
|
*/
|
|
960
|
-
async subscribe(topic: string, callback:
|
|
905
|
+
async subscribe(topic: string, callback: Handler) {
|
|
961
906
|
// TODO: if peer subscribed
|
|
962
907
|
globalSub.subscribe(topic, callback)
|
|
963
908
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export declare type DHTProvider = {
|
|
2
|
-
address: string;
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
5
|
-
export declare type DHTProviderDistanceResult = {
|
|
6
|
-
provider: DHTProvider;
|
|
7
|
-
/**
|
|
8
|
-
* distance on earth between peers in km
|
|
9
|
-
*/
|
|
10
|
-
distance: number;
|
|
11
|
-
};
|
|
12
|
-
export declare type DHTProviderMapValue = {
|
|
13
|
-
[index: string]: DHTProvider;
|
|
14
|
-
};
|
|
15
|
-
declare type Coordinates = {
|
|
16
|
-
longitude: number;
|
|
17
|
-
latitude: number;
|
|
18
|
-
};
|
|
19
|
-
export declare const getAddress: () => Promise<any>;
|
|
20
|
-
export default class DhtEarth {
|
|
21
|
-
providerMap: Map<string, DHTProviderMapValue>;
|
|
22
|
-
getCoordinates(address: string): Promise<Coordinates>;
|
|
23
|
-
/**
|
|
24
|
-
* @param {Object} peer
|
|
25
|
-
* @param {Object} provider
|
|
26
|
-
* @return {Object} {provider, distance}
|
|
27
|
-
*/
|
|
28
|
-
getDistance(peer: {
|
|
29
|
-
latitude: number;
|
|
30
|
-
longitude: number;
|
|
31
|
-
}, provider: DHTProvider): Promise<DHTProviderDistanceResult>;
|
|
32
|
-
closestPeer(providers: Array<any>): Promise<DHTProvider>;
|
|
33
|
-
hasProvider(hash: string): boolean;
|
|
34
|
-
providersFor(hash: string): DHTProviderMapValue;
|
|
35
|
-
addProvider(provider: DHTProvider, hash: string): void;
|
|
36
|
-
removeProvider(address: string, hash: string): void;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export default class MessageHandler {
|
|
2
|
-
constructor(network: any);
|
|
3
|
-
network: any;
|
|
4
|
-
/**
|
|
5
|
-
* hash and sign message
|
|
6
|
-
*
|
|
7
|
-
* @param {object} message
|
|
8
|
-
* @param {Buffer} message.from peer id
|
|
9
|
-
* @param {Buffer} message.to peer id
|
|
10
|
-
* @param {string} message.data Peernet message
|
|
11
|
-
* (PeernetMessage excluded) encoded as a string
|
|
12
|
-
* @return message
|
|
13
|
-
*/
|
|
14
|
-
hashAndSignMessage(message: {
|
|
15
|
-
from: Buffer;
|
|
16
|
-
to: Buffer;
|
|
17
|
-
data: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
from: Buffer;
|
|
20
|
-
to: Buffer;
|
|
21
|
-
data: string;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* @param {String} from - peer id
|
|
25
|
-
* @param {String} to - peer id
|
|
26
|
-
* @param {String|PeernetMessage} data - data encoded message string
|
|
27
|
-
* or the messageNode itself
|
|
28
|
-
*/
|
|
29
|
-
prepareMessage(message: any): Promise<any>;
|
|
30
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { base58String } from '@vandeurenglenn/base58';
|
|
2
|
-
export default class Identity {
|
|
3
|
-
#private;
|
|
4
|
-
network: any;
|
|
5
|
-
id: string;
|
|
6
|
-
selectedAccount: string;
|
|
7
|
-
constructor(network: string);
|
|
8
|
-
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
9
|
-
getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
10
|
-
load(password?: string): Promise<void>;
|
|
11
|
-
selectAccount(account: string): Promise<unknown>;
|
|
12
|
-
sign(hash: Uint8Array): any;
|
|
13
|
-
lock(password: string): void;
|
|
14
|
-
unlock(password: string): void;
|
|
15
|
-
export(password: string): Promise<any>;
|
|
16
|
-
import(password: any, encrypted: base58String): Promise<void>;
|
|
17
|
-
exportQR(password: string): Promise<string>;
|
|
18
|
-
importQR(image: File | Blob, password: string): Promise<void>;
|
|
19
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @extends {CodecFormat}
|
|
3
|
-
*/
|
|
4
|
-
export default class DataMessage {
|
|
5
|
-
/**
|
|
6
|
-
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
-
*/
|
|
8
|
-
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
-
get messageName(): string;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @extends {CodecFormat}
|
|
3
|
-
*/
|
|
4
|
-
export default class PeernetFileLink {
|
|
5
|
-
/**
|
|
6
|
-
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
-
*/
|
|
8
|
-
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
-
get messageName(): string;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @extends {CodecFormat}
|
|
3
|
-
*/
|
|
4
|
-
export default class PeernetFile {
|
|
5
|
-
/**
|
|
6
|
-
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
-
*/
|
|
8
|
-
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
-
get messageName(): string;
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { default as PeernetMessage } from "./messages/peernet.js";
|
|
2
|
-
export { default as DHTMessage } from "./messages/dht.js";
|
|
3
|
-
export { default as DHTMessageResponse } from "./messages/dht-response.js";
|
|
4
|
-
export { default as DataMessage } from "./messages/data.js";
|
|
5
|
-
export { default as PsMessage } from "./messages/ps.js";
|
|
6
|
-
export { default as PeerMessage } from "./messages/peer.js";
|
|
7
|
-
export { default as RequestMessage } from "./messages/request.js";
|
|
8
|
-
export { default as ResponseMessage } from "./messages/response.js";
|
|
9
|
-
export { default as PeerMessageResponse } from "./messages/peer-response.js";
|
|
10
|
-
export { default as DataMessageResponse } from "./messages/data-response.js";
|
|
11
|
-
export { default as ChatMessage } from "./messages/chat.js";
|
|
12
|
-
export { default as PeernetFile } from "./messages/file.js";
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import PubSub from '@vandeurenglenn/little-pubsub';
|
|
2
|
-
import PeerDiscovery from './discovery/peer-discovery.js';
|
|
3
|
-
import DHT from './dht/dht.js';
|
|
4
|
-
import MessageHandler from './handlers/message.js';
|
|
5
|
-
import { Storage as LeofcoinStorageClass } from '@leofcoin/storage';
|
|
6
|
-
import Identity from './identity.js';
|
|
7
|
-
import swarm from '@netpeer/swarm/client';
|
|
8
|
-
declare global {
|
|
9
|
-
var LeofcoinStorage: typeof LeofcoinStorageClass;
|
|
10
|
-
var peernet: Peernet;
|
|
11
|
-
var pubsub: PubSub;
|
|
12
|
-
var globalSub: PubSub;
|
|
13
|
-
var blockStore: LeofcoinStorageClass;
|
|
14
|
-
var transactionStore: LeofcoinStorageClass;
|
|
15
|
-
var messageStore: LeofcoinStorageClass;
|
|
16
|
-
var dataStore: LeofcoinStorageClass;
|
|
17
|
-
var walletStore: LeofcoinStorageClass;
|
|
18
|
-
var chainStore: LeofcoinStorageClass;
|
|
19
|
-
var shareStore: LeofcoinStorageClass;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @access public
|
|
23
|
-
* @example
|
|
24
|
-
* const peernet = new Peernet();
|
|
25
|
-
*/
|
|
26
|
-
export default class Peernet {
|
|
27
|
-
#private;
|
|
28
|
-
storePrefix: string;
|
|
29
|
-
root: string;
|
|
30
|
-
identity: Identity;
|
|
31
|
-
stores: string[];
|
|
32
|
-
peerId: string;
|
|
33
|
-
/**
|
|
34
|
-
* @type {Object}
|
|
35
|
-
* @property {Object} peer Instance of Peer
|
|
36
|
-
*/
|
|
37
|
-
dht: DHT;
|
|
38
|
-
/** @leofcoin/peernet-swarm/client */
|
|
39
|
-
client: swarm;
|
|
40
|
-
network: string;
|
|
41
|
-
stars: string[];
|
|
42
|
-
networkVersion: string;
|
|
43
|
-
bw: {
|
|
44
|
-
up: number;
|
|
45
|
-
down: number;
|
|
46
|
-
};
|
|
47
|
-
hasDaemon: boolean;
|
|
48
|
-
autoStart: boolean;
|
|
49
|
-
requestProtos: {};
|
|
50
|
-
_messageHandler: MessageHandler;
|
|
51
|
-
_peerHandler: PeerDiscovery;
|
|
52
|
-
protos: {};
|
|
53
|
-
version: any;
|
|
54
|
-
private _inMemoryBroadcasts;
|
|
55
|
-
/**
|
|
56
|
-
* @access public
|
|
57
|
-
* @param {Object} options
|
|
58
|
-
* @param {String} options.network - desired network
|
|
59
|
-
* @param {String} options.stars - star list for selected network (these should match, don't mix networks)
|
|
60
|
-
* @param {String} options.root - path to root directory
|
|
61
|
-
* @param {String} options.version - path to root directory
|
|
62
|
-
* @param {String} options.storePrefix - prefix for datatores (lfc)
|
|
63
|
-
*
|
|
64
|
-
* @return {Promise} instance of Peernet
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* const peernet = new Peernet({network: 'leofcoin', root: '.leofcoin'});
|
|
68
|
-
*/
|
|
69
|
-
constructor(options: any, password: any);
|
|
70
|
-
get id(): string;
|
|
71
|
-
get selectedAccount(): string;
|
|
72
|
-
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
73
|
-
get defaultStores(): string[];
|
|
74
|
-
selectAccount(account: string): Promise<unknown>;
|
|
75
|
-
addProto(name: any, proto: any): void;
|
|
76
|
-
addCodec(codec: any): void;
|
|
77
|
-
addStore(name: any, prefix: any, root: any, isPrivate?: boolean): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* @see MessageHandler
|
|
80
|
-
*/
|
|
81
|
-
prepareMessage(data: any): Promise<any>;
|
|
82
|
-
/**
|
|
83
|
-
* @access public
|
|
84
|
-
*
|
|
85
|
-
* @return {Array} peerId
|
|
86
|
-
*/
|
|
87
|
-
get peers(): [string, import("@netpeer/swarm/peer").default][];
|
|
88
|
-
get connections(): {
|
|
89
|
-
[index: string]: import("@netpeer/swarm/peer").default;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* @return {String} id - peerId
|
|
93
|
-
*/
|
|
94
|
-
getConnection(id: any): import("@netpeer/swarm/peer").default;
|
|
95
|
-
/**
|
|
96
|
-
* @private
|
|
97
|
-
*
|
|
98
|
-
* @param {Object} options
|
|
99
|
-
* @param {String} options.root - path to root directory
|
|
100
|
-
*
|
|
101
|
-
* @return {Promise} instance of Peernet
|
|
102
|
-
*/
|
|
103
|
-
_init(options: {
|
|
104
|
-
storePrefix?: string;
|
|
105
|
-
root?: string;
|
|
106
|
-
}, password: string): Promise<Peernet>;
|
|
107
|
-
start(): Promise<void>;
|
|
108
|
-
addRequestHandler(name: any, method: any): void;
|
|
109
|
-
sendMessage(peer: any, id: any, data: any): Promise<any>;
|
|
110
|
-
handleDHT(peer: any, id: any, proto: any): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Broadcasts data to the network and returns a hash that can be used by another peer
|
|
113
|
-
* to directly connect and download the data from the broadcasting peer.
|
|
114
|
-
*
|
|
115
|
-
* @param {Uint8Array|Buffer|Object|string} data - The data to broadcast
|
|
116
|
-
* @param {string} [storeName='data'] - The store to use for storing the data
|
|
117
|
-
* @returns {Promise<string>} The hash that can be shared for direct download
|
|
118
|
-
*/
|
|
119
|
-
/**
|
|
120
|
-
* Broadcasts data to the network and returns a hash that can be used by another peer
|
|
121
|
-
* to directly connect and download the data from the broadcasting peer.
|
|
122
|
-
* The data is kept in memory only and not persisted to storage.
|
|
123
|
-
* @param {string} path - The path or identifier for the content being broadcasted
|
|
124
|
-
* @param {{content?: Uint8Array, links?: any[]}} data - The data to broadcast
|
|
125
|
-
|
|
126
|
-
* @returns {Promise<string>} The hash that can be shared for direct download
|
|
127
|
-
*/
|
|
128
|
-
broadcast(path: string, { content, links }: {
|
|
129
|
-
content?: Uint8Array;
|
|
130
|
-
links?: any[];
|
|
131
|
-
}): Promise<string>;
|
|
132
|
-
handleData(peer: any, id: any, proto: any): Promise<any>;
|
|
133
|
-
handleRequest(peer: any, id: any, proto: any): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* @private
|
|
136
|
-
*
|
|
137
|
-
* @param {Buffer} message - peernet message
|
|
138
|
-
* @param {PeernetPeer} peer - peernet peer
|
|
139
|
-
*/
|
|
140
|
-
_protoHandler(message: any, peer: any, from: any): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* performs a walk and resolves first encounter
|
|
143
|
-
*
|
|
144
|
-
* @param {String} hash
|
|
145
|
-
*/
|
|
146
|
-
walk(hash: any): Promise<any>;
|
|
147
|
-
/**
|
|
148
|
-
* Override DHT behavior, try's finding the content three times
|
|
149
|
-
*
|
|
150
|
-
* @param {String} hash
|
|
151
|
-
*/
|
|
152
|
-
providersFor(hash: string, store?: undefined): Promise<import("./dht/dht.js").DHTProviderMapValue>;
|
|
153
|
-
get block(): {
|
|
154
|
-
get: (hash: string) => Promise<any>;
|
|
155
|
-
put: (hash: string, data: Uint8Array) => Promise<unknown>;
|
|
156
|
-
has: (hash: string) => Promise<boolean | any[]>;
|
|
157
|
-
};
|
|
158
|
-
get transaction(): {
|
|
159
|
-
get: (hash: string) => Promise<any>;
|
|
160
|
-
put: (hash: string, data: Uint8Array) => Promise<unknown>;
|
|
161
|
-
has: (hash: string) => Promise<boolean | any[]>;
|
|
162
|
-
};
|
|
163
|
-
requestData(hash: any, store: any): any;
|
|
164
|
-
get message(): {
|
|
165
|
-
/**
|
|
166
|
-
* Get content for given message hash
|
|
167
|
-
*
|
|
168
|
-
* @param {String} hash
|
|
169
|
-
*/
|
|
170
|
-
get: (hash: any) => Promise<any>;
|
|
171
|
-
/**
|
|
172
|
-
* put message content
|
|
173
|
-
*
|
|
174
|
-
* @param {String} hash
|
|
175
|
-
* @param {Buffer} message
|
|
176
|
-
*/
|
|
177
|
-
put: (hash: any, message: any) => Promise<unknown>;
|
|
178
|
-
/**
|
|
179
|
-
* @param {String} hash
|
|
180
|
-
* @return {Boolean}
|
|
181
|
-
*/
|
|
182
|
-
has: (hash: any) => Promise<boolean | any[]>;
|
|
183
|
-
};
|
|
184
|
-
get data(): {
|
|
185
|
-
/**
|
|
186
|
-
* Get content for given data hash
|
|
187
|
-
*
|
|
188
|
-
* @param {String} hash
|
|
189
|
-
*/
|
|
190
|
-
get: (hash: any) => Promise<any>;
|
|
191
|
-
/**
|
|
192
|
-
* put data content
|
|
193
|
-
*
|
|
194
|
-
* @param {String} hash
|
|
195
|
-
* @param {Buffer} data
|
|
196
|
-
*/
|
|
197
|
-
put: (hash: any, data: any) => Promise<unknown>;
|
|
198
|
-
/**
|
|
199
|
-
* @param {String} hash
|
|
200
|
-
* @return {Boolean}
|
|
201
|
-
*/
|
|
202
|
-
has: (hash: any) => Promise<boolean | any[]>;
|
|
203
|
-
};
|
|
204
|
-
get folder(): {
|
|
205
|
-
/**
|
|
206
|
-
* Get content for given data hash
|
|
207
|
-
*
|
|
208
|
-
* @param {String} hash
|
|
209
|
-
*/
|
|
210
|
-
get: (hash: any) => Promise<any>;
|
|
211
|
-
/**
|
|
212
|
-
* put data content
|
|
213
|
-
*
|
|
214
|
-
* @param {String} hash
|
|
215
|
-
* @param {Buffer} data
|
|
216
|
-
*/
|
|
217
|
-
put: (hash: any, data: any) => Promise<unknown>;
|
|
218
|
-
/**
|
|
219
|
-
* @param {String} hash
|
|
220
|
-
* @return {Boolean}
|
|
221
|
-
*/
|
|
222
|
-
has: (hash: any) => Promise<boolean | any[]>;
|
|
223
|
-
};
|
|
224
|
-
get share(): {
|
|
225
|
-
/**
|
|
226
|
-
* Get content for given share hash
|
|
227
|
-
*
|
|
228
|
-
* @todo Add peer permission checking to validate if requesting peer has access
|
|
229
|
-
*
|
|
230
|
-
* @param {String} hash
|
|
231
|
-
*/
|
|
232
|
-
get: (hash: any) => Promise<any>;
|
|
233
|
-
/**
|
|
234
|
-
* put share content
|
|
235
|
-
*
|
|
236
|
-
* @param {String} hash
|
|
237
|
-
* @param {Buffer} data
|
|
238
|
-
*/
|
|
239
|
-
put: (hash: any, data: any) => Promise<unknown>;
|
|
240
|
-
/**
|
|
241
|
-
* @param {String} hash
|
|
242
|
-
* @return {Boolean}
|
|
243
|
-
*/
|
|
244
|
-
has: (hash: any) => Promise<boolean | any[]>;
|
|
245
|
-
/**
|
|
246
|
-
* Put folder content
|
|
247
|
-
*
|
|
248
|
-
* @param {Array} files
|
|
249
|
-
*/
|
|
250
|
-
putFolder: (files: any) => Promise<any>;
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Get all shared hashes
|
|
254
|
-
*
|
|
255
|
-
* @returns {Promise<string[]>} Array of all shared hashes
|
|
256
|
-
*/
|
|
257
|
-
allSharedHashes(): Promise<string[]>;
|
|
258
|
-
addFolder(files: any): Promise<any>;
|
|
259
|
-
ls(hash: any, options: any): Promise<any[]>;
|
|
260
|
-
cat(hash: any, options: any): Promise<any>;
|
|
261
|
-
/**
|
|
262
|
-
* goes trough given stores and tries to find data for given hash
|
|
263
|
-
* @param {Array} stores
|
|
264
|
-
* @param {string} hash
|
|
265
|
-
*/
|
|
266
|
-
whichStore(stores: any, hash: any): any;
|
|
267
|
-
/**
|
|
268
|
-
* Get content for given hash
|
|
269
|
-
*
|
|
270
|
-
* @param {String} hash - the hash of the wanted data
|
|
271
|
-
* @param {String} store - storeName to access
|
|
272
|
-
*/
|
|
273
|
-
get(hash: any, store: any): Promise<any>;
|
|
274
|
-
/**
|
|
275
|
-
* put content
|
|
276
|
-
*
|
|
277
|
-
* @param {String} hash
|
|
278
|
-
* @param {Buffer} data
|
|
279
|
-
* @param {String} storeName - storeName to access
|
|
280
|
-
*/
|
|
281
|
-
put(hash: string, data: Uint8Array, storeName?: string | LeofcoinStorageClass): Promise<unknown>;
|
|
282
|
-
/**
|
|
283
|
-
* @param {String} hash
|
|
284
|
-
* @return {Boolean}
|
|
285
|
-
*/
|
|
286
|
-
has(hash: any): Promise<boolean>;
|
|
287
|
-
/**
|
|
288
|
-
*
|
|
289
|
-
* @param {String} topic
|
|
290
|
-
* @param {String|Object|Array|Boolean|Buffer} data
|
|
291
|
-
*/
|
|
292
|
-
publish(topic: any, data: any): Promise<void>;
|
|
293
|
-
/**
|
|
294
|
-
*
|
|
295
|
-
* @param {String} topic
|
|
296
|
-
* @param {Method} cb
|
|
297
|
-
*/
|
|
298
|
-
subscribe(topic: string, callback: Function): Promise<void>;
|
|
299
|
-
removePeer(peer: any): Promise<void>;
|
|
300
|
-
get Buffer(): BufferConstructor;
|
|
301
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import '@vandeurenglenn/debug';
|
|
2
|
-
import PubSub from '@vandeurenglenn/little-pubsub';
|
|
3
|
-
import Peernet from './peernet.js';
|
|
4
|
-
import { Storage as LeofcoinStorageClass } from '@leofcoin/storage';
|
|
5
|
-
declare global {
|
|
6
|
-
var globalSub: PubSub;
|
|
7
|
-
var pubsub: PubSub;
|
|
8
|
-
var peernet: Peernet;
|
|
9
|
-
var LeofcoinStorage: typeof LeofcoinStorageClass;
|
|
10
|
-
var LeofcoinStorageClient: any;
|
|
11
|
-
var messageStore: LeofcoinStorageClass;
|
|
12
|
-
var dataStore: LeofcoinStorageClass;
|
|
13
|
-
var transactionStore: LeofcoinStorageClass;
|
|
14
|
-
var blockStore: LeofcoinStorageClass;
|
|
15
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function BufferToUint8Array(data: any): any;
|
|
2
|
-
export function expected(expected: any, actual: any): string;
|
|
3
|
-
export function protoFor(message: any): any;
|
|
4
|
-
export function hasDaemon(): boolean;
|
|
5
|
-
export function https(): boolean;
|
|
6
|
-
export function environment(): string;
|
|
7
|
-
export function target(): any;
|