@leofcoin/peernet 1.1.80 → 1.1.81

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.
Files changed (71) hide show
  1. package/.esdoc.json +10 -10
  2. package/.gitattributes +2 -2
  3. package/.prettierrc +7 -7
  4. package/.travis.yml +27 -27
  5. package/BREAKING_CHANGES.md +34 -34
  6. package/LICENSE +21 -21
  7. package/README.md +72 -72
  8. package/deploy.js +8 -8
  9. package/exports/browser/{client-Depp28gl.js → client-C0VVXIWm.js} +2 -2
  10. package/exports/browser/{index-DqPlTtAJ.js → index-CEwkDK9g.js} +5 -496
  11. package/exports/browser/{messages-RYLqPGkg.js → messages-BdevLRCA.js} +164 -164
  12. package/exports/browser/{peernet-B7TZP-Wg.js → peernet-DEIKLS2i.js} +185 -185
  13. package/exports/browser/peernet.js +1 -1
  14. package/exports/{messages-CRhtDipD.js → messages-BmpgEM4y.js} +163 -163
  15. package/exports/peernet.js +184 -184
  16. package/exports/src/prompts/password.js +3 -3
  17. package/index.html +19 -19
  18. package/package.json +71 -71
  19. package/rollup.config.js +63 -63
  20. package/src/dht/dht.ts +147 -147
  21. package/src/discovery/peer-discovery.js +75 -75
  22. package/src/errors/errors.js +12 -12
  23. package/src/handlers/data.js +15 -15
  24. package/src/handlers/message.js +34 -34
  25. package/src/identity.ts +104 -104
  26. package/src/messages/chat.js +13 -13
  27. package/src/messages/data-response.js +13 -13
  28. package/src/messages/data.js +17 -17
  29. package/src/messages/dht-response.js +13 -13
  30. package/src/messages/dht.js +21 -21
  31. package/src/messages/file-link.js +17 -17
  32. package/src/messages/file.js +17 -17
  33. package/src/messages/peer-response.js +13 -13
  34. package/src/messages/peer.js +13 -13
  35. package/src/messages/peernet.js +13 -13
  36. package/src/messages/ps.js +13 -13
  37. package/src/messages/request.js +13 -13
  38. package/src/messages/response.js +13 -13
  39. package/src/messages.js +13 -13
  40. package/src/peer-info.js +9 -9
  41. package/src/peernet.ts +817 -817
  42. package/src/prompts/password/browser.js +1 -1
  43. package/src/prompts/password/node.js +6 -6
  44. package/src/proto/chat-message.proto.js +6 -6
  45. package/src/proto/data-response.proto.js +4 -4
  46. package/src/proto/data.proto.js +4 -4
  47. package/src/proto/dht-response.proto.js +4 -4
  48. package/src/proto/dht.proto.js +4 -4
  49. package/src/proto/file-link.proto.js +5 -5
  50. package/src/proto/file.proto.js +5 -5
  51. package/src/proto/peer-response.proto.js +3 -3
  52. package/src/proto/peer.proto.js +3 -3
  53. package/src/proto/peernet.proto.js +7 -7
  54. package/src/proto/ps.proto.js +4 -4
  55. package/src/proto/request.proto.js +4 -4
  56. package/src/proto/response.proto.js +3 -3
  57. package/src/types.ts +25 -25
  58. package/src/utils/utils.js +77 -77
  59. package/test/client.js +14 -14
  60. package/test/codec.js +56 -56
  61. package/test/hash.js +13 -13
  62. package/test/index.js +3 -3
  63. package/test/lastBlock.js +7 -7
  64. package/test/messages.js +26 -26
  65. package/test/peernet.js +17 -17
  66. package/test/peernet.test.js +159 -159
  67. package/test.js +62 -62
  68. package/test2.js +13 -13
  69. package/test3.js +15 -15
  70. package/test4.js +7 -7
  71. package/tsconfig.json +11 -11
package/.esdoc.json CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "source": "./src",
3
- "destination": "./docs",
4
- "plugins": [{
5
- "name": "esdoc-standard-plugin"
6
- }, {
7
- "name": "esdoc-ecmascript-proposal-plugin",
8
- "option": {"all": true}
9
- }]
10
- }
1
+ {
2
+ "source": "./src",
3
+ "destination": "./docs",
4
+ "plugins": [{
5
+ "name": "esdoc-standard-plugin"
6
+ }, {
7
+ "name": "esdoc-ecmascript-proposal-plugin",
8
+ "option": {"all": true}
9
+ }]
10
+ }
package/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/.prettierrc CHANGED
@@ -1,7 +1,7 @@
1
- {
2
- "tabWidth": 2,
3
- "semi": false,
4
- "singleQuote": true,
5
- "printWidth": 120,
6
- "trailingComma": "none"
7
- }
1
+ {
2
+ "tabWidth": 2,
3
+ "semi": false,
4
+ "singleQuote": true,
5
+ "printWidth": 120,
6
+ "trailingComma": "none"
7
+ }
package/.travis.yml CHANGED
@@ -1,27 +1,27 @@
1
- os:
2
- - linux
3
- - windows
4
- - osx
5
-
6
- language: node_js
7
- node_js:
8
- - 14
9
- - 16
10
- - 19
11
-
12
- script:
13
- - npm run c
14
- - npm run doc
15
- - npm run test
16
-
17
- after_success:
18
- - npm run coverage
19
- - npm run coveralls
20
- - node deploy.js success $WEBHOOK_URL
21
-
22
- after_failure:
23
- - node deploy.js failure $WEBHOOK_URL
24
-
25
- branches:
26
- only:
27
- - main
1
+ os:
2
+ - linux
3
+ - windows
4
+ - osx
5
+
6
+ language: node_js
7
+ node_js:
8
+ - 14
9
+ - 16
10
+ - 19
11
+
12
+ script:
13
+ - npm run c
14
+ - npm run doc
15
+ - npm run test
16
+
17
+ after_success:
18
+ - npm run coverage
19
+ - npm run coveralls
20
+ - node deploy.js success $WEBHOOK_URL
21
+
22
+ after_failure:
23
+ - node deploy.js failure $WEBHOOK_URL
24
+
25
+ branches:
26
+ only:
27
+ - main
@@ -1,35 +1,35 @@
1
- # breaking changes
2
- ## 1.0.10
3
- ### start
4
- #### before
5
- ```js
6
- const node = await new Node()
7
- ```
8
-
9
- #### now
10
- ```js
11
- const node = await new Node()
12
- // gives time to setup things...
13
- await node.start()
14
- ```
15
-
16
- ## 1.1.0
17
- ### autoStart
18
- #### before
19
- ```js
20
- const node = await new Node()
21
- // gives time to setup things...
22
- await node.start()
23
- ```
24
-
25
- #### now
26
- ```js
27
- const node = await new Node()
28
- ```
29
- or
30
-
31
- ```js
32
- const node = await new Node({autoStart: false}) // defaults to true
33
- // gives time to setup things...
34
- await node.start()
1
+ # breaking changes
2
+ ## 1.0.10
3
+ ### start
4
+ #### before
5
+ ```js
6
+ const node = await new Node()
7
+ ```
8
+
9
+ #### now
10
+ ```js
11
+ const node = await new Node()
12
+ // gives time to setup things...
13
+ await node.start()
14
+ ```
15
+
16
+ ## 1.1.0
17
+ ### autoStart
18
+ #### before
19
+ ```js
20
+ const node = await new Node()
21
+ // gives time to setup things...
22
+ await node.start()
23
+ ```
24
+
25
+ #### now
26
+ ```js
27
+ const node = await new Node()
28
+ ```
29
+ or
30
+
31
+ ```js
32
+ const node = await new Node({autoStart: false}) // defaults to true
33
+ // gives time to setup things...
34
+ await node.start()
35
35
  ```
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 vandeurenglenn
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 vandeurenglenn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,72 +1,72 @@
1
- # peernet
2
-
3
- ## Usage
4
- ```js
5
- import Peernet from '@leofcoin/peernet'
6
-
7
-
8
- const config = {
9
- network: 'leofcoin:peach',
10
- networkVersion: 'peach',
11
- stars: ['wss://peach.leofcoin.org']
12
- }
13
-
14
- const node = await new Peernet(config)
15
- // ... setup some things
16
- await node.start()
17
-
18
- console.log(globalThis.peernet)
19
- ```
20
-
21
-
22
-
23
- ## API
24
- #### addRequestHandler
25
-
26
- examples
27
- ```js
28
- peernet.addRequestHandler('lastBlock', () => {
29
- let response;
30
- const height = await chainStore.get('localIndex')
31
- const hash = await chainStore.get('localBlock')
32
- response = JSON.stringify({ height: height.toString(), hash: hash.toString() })
33
- return new ResponseMessage({ response })
34
- // or
35
- return new peernet.protos['peernet-response']({ response })
36
- })
37
- ```
38
-
39
- ```js
40
- peernet.addRequestHandler('hello', () => {
41
- return new ResponseMessage({ response: 'hi' })
42
- // or
43
- return new peernet.protos['peernet-response']({ response: 'hi' })
44
- })
45
- ```
46
- #### add version to peer
47
- ```js
48
- peernet.addRequestHandler('version', () => {
49
- return new ResponseMessage({ response: {version: 1} })
50
- })
51
- ```
52
-
53
- ## Development
54
-
55
- `note: you need to install jsproject`
56
- ```sh
57
- npm i -g @vandeurenglenn/project
58
- ```
59
-
60
- ### watch
61
- ```sh
62
- npm run w
63
- ```
64
- ### compile
65
- ```sh
66
- npm run c
67
- ```
68
- ### serve html
69
- ```sh
70
- npm run demo
71
- ```
72
-
1
+ # peernet
2
+
3
+ ## Usage
4
+ ```js
5
+ import Peernet from '@leofcoin/peernet'
6
+
7
+
8
+ const config = {
9
+ network: 'leofcoin:peach',
10
+ networkVersion: 'peach',
11
+ stars: ['wss://peach.leofcoin.org']
12
+ }
13
+
14
+ const node = await new Peernet(config)
15
+ // ... setup some things
16
+ await node.start()
17
+
18
+ console.log(globalThis.peernet)
19
+ ```
20
+
21
+
22
+
23
+ ## API
24
+ #### addRequestHandler
25
+
26
+ examples
27
+ ```js
28
+ peernet.addRequestHandler('lastBlock', () => {
29
+ let response;
30
+ const height = await chainStore.get('localIndex')
31
+ const hash = await chainStore.get('localBlock')
32
+ response = JSON.stringify({ height: height.toString(), hash: hash.toString() })
33
+ return new ResponseMessage({ response })
34
+ // or
35
+ return new peernet.protos['peernet-response']({ response })
36
+ })
37
+ ```
38
+
39
+ ```js
40
+ peernet.addRequestHandler('hello', () => {
41
+ return new ResponseMessage({ response: 'hi' })
42
+ // or
43
+ return new peernet.protos['peernet-response']({ response: 'hi' })
44
+ })
45
+ ```
46
+ #### add version to peer
47
+ ```js
48
+ peernet.addRequestHandler('version', () => {
49
+ return new ResponseMessage({ response: {version: 1} })
50
+ })
51
+ ```
52
+
53
+ ## Development
54
+
55
+ `note: you need to install jsproject`
56
+ ```sh
57
+ npm i -g @vandeurenglenn/project
58
+ ```
59
+
60
+ ### watch
61
+ ```sh
62
+ npm run w
63
+ ```
64
+ ### compile
65
+ ```sh
66
+ npm run c
67
+ ```
68
+ ### serve html
69
+ ```sh
70
+ npm run demo
71
+ ```
72
+
package/deploy.js CHANGED
@@ -1,8 +1,8 @@
1
- const {execSync} = require('child_process');
2
- const status = process.argv[2]
3
-
4
- if (process.version.split('.')[0] === 'v19' && process.platform === 'linux') {
5
- execSync('wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh')
6
- execSync('chmod +x send.sh')
7
- execSync(`./send.sh ${status} ` + process.argv[3])
8
- }
1
+ const {execSync} = require('child_process');
2
+ const status = process.argv[2]
3
+
4
+ if (process.version.split('.')[0] === 'v19' && process.platform === 'linux') {
5
+ execSync('wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh')
6
+ execSync('chmod +x send.sh')
7
+ execSync(`./send.sh ${status} ` + process.argv[3])
8
+ }
@@ -1,4 +1,4 @@
1
- import { L as LittlePubSub } from './peernet-B7TZP-Wg.js';
1
+ import { L as LittlePubSub } from './peernet-DEIKLS2i.js';
2
2
  import './identity-CQ_ieRiz.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -314,7 +314,7 @@ const iceServers = [
314
314
  credential: 'openrelayproject'
315
315
  }
316
316
  ];
317
- const SimplePeer = (await import('./index-DqPlTtAJ.js').then(function (n) { return n.i; })).default;
317
+ const SimplePeer = (await import('./index-CEwkDK9g.js').then(function (n) { return n.i; })).default;
318
318
  class Peer extends SimplePeer {
319
319
  peerId;
320
320
  channelName;