@leofcoin/peernet 1.0.2 → 1.0.5

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 (140) hide show
  1. package/.esdoc.json +10 -10
  2. package/.eslintrc.json +24 -24
  3. package/.travis.yml +27 -25
  4. package/LICENSE +21 -21
  5. package/README.md +64 -64
  6. package/deploy.js +8 -8
  7. package/exports/browser/browser-10ffabe1.js +56 -0
  8. package/exports/browser/{browser-2f0b2829.js → browser-e1cd4e67.js} +46 -38
  9. package/exports/browser/{client-95423644.js → client-d63a0806.js} +4 -3
  10. package/exports/browser/dht/dht.d.ts +30 -30
  11. package/exports/browser/discovery/peer-discovery.d.ts +7 -7
  12. package/exports/browser/errors/errors.d.ts +3 -3
  13. package/exports/browser/handlers/data.d.ts +2 -2
  14. package/exports/browser/handlers/message.d.ts +30 -30
  15. package/exports/browser/{index-3699fac4.js → index-ae8a0f11.js} +33 -29
  16. package/exports/browser/messages/chat.d.ts +6 -6
  17. package/exports/browser/messages/data-response.d.ts +6 -6
  18. package/exports/browser/messages/data.d.ts +10 -10
  19. package/exports/browser/messages/dht-response.d.ts +6 -6
  20. package/exports/browser/messages/dht.d.ts +14 -14
  21. package/exports/browser/messages/file-link.d.ts +10 -10
  22. package/exports/browser/messages/file.d.ts +10 -10
  23. package/exports/browser/messages/peer-response.d.ts +6 -6
  24. package/exports/browser/messages/peer.d.ts +6 -6
  25. package/exports/browser/messages/peernet.d.ts +6 -6
  26. package/exports/browser/messages/ps.d.ts +6 -6
  27. package/exports/browser/messages/request.d.ts +6 -6
  28. package/exports/browser/messages/response.d.ts +6 -6
  29. package/exports/browser/{messages-2214fcbb.js → messages-b724fbb6.js} +155 -154
  30. package/exports/browser/messages.d.ts +12 -12
  31. package/exports/browser/peer-info.d.ts +4 -4
  32. package/exports/browser/{peernet-e74b2091.js → peernet-76472a7f.js} +13594 -10531
  33. package/exports/browser/peernet.js +2 -1
  34. package/exports/browser/prompts/password/browser.d.ts +2 -2
  35. package/exports/browser/prompts/password/node.d.ts +2 -2
  36. package/exports/browser/proto/chat-message.proto.d.ts +7 -7
  37. package/exports/browser/proto/data-response.proto.d.ts +5 -5
  38. package/exports/browser/proto/data.proto.d.ts +5 -5
  39. package/exports/browser/proto/dht-response.proto.d.ts +5 -5
  40. package/exports/browser/proto/dht.proto.d.ts +5 -5
  41. package/exports/browser/proto/file-link.proto.d.ts +6 -6
  42. package/exports/browser/proto/file.proto.d.ts +6 -6
  43. package/exports/browser/proto/peer-response.proto.d.ts +4 -4
  44. package/exports/browser/proto/peer.proto.d.ts +4 -4
  45. package/exports/browser/proto/peernet.proto.d.ts +8 -8
  46. package/exports/browser/proto/ps.proto.d.ts +5 -5
  47. package/exports/browser/proto/request.proto.d.ts +4 -4
  48. package/exports/browser/proto/response.proto.d.ts +4 -4
  49. package/exports/browser/qr-scanner-worker.min-c002e984.js +100 -0
  50. package/exports/browser/utils/utils.d.ts +7 -7
  51. package/exports/dht/dht.d.ts +30 -30
  52. package/exports/discovery/peer-discovery.d.ts +7 -7
  53. package/exports/errors/errors.d.ts +3 -3
  54. package/exports/handlers/data.d.ts +2 -2
  55. package/exports/handlers/message.d.ts +30 -30
  56. package/exports/messages/chat.d.ts +6 -6
  57. package/exports/messages/data-response.d.ts +6 -6
  58. package/exports/messages/data.d.ts +10 -10
  59. package/exports/messages/dht-response.d.ts +6 -6
  60. package/exports/messages/dht.d.ts +14 -14
  61. package/exports/messages/file-link.d.ts +10 -10
  62. package/exports/messages/file.d.ts +10 -10
  63. package/exports/messages/peer-response.d.ts +6 -6
  64. package/exports/messages/peer.d.ts +6 -6
  65. package/exports/messages/peernet.d.ts +6 -6
  66. package/exports/messages/ps.d.ts +6 -6
  67. package/exports/messages/request.d.ts +6 -6
  68. package/exports/messages/response.d.ts +6 -6
  69. package/exports/{messages-75fe56a4.js → messages-65501ef9.js} +152 -152
  70. package/exports/messages.d.ts +12 -12
  71. package/exports/peer-info.d.ts +4 -4
  72. package/exports/peernet.js +972 -968
  73. package/exports/prompts/password/browser.d.ts +2 -2
  74. package/exports/prompts/password/node.d.ts +2 -2
  75. package/exports/proto/chat-message.proto.d.ts +7 -7
  76. package/exports/proto/data-response.proto.d.ts +5 -5
  77. package/exports/proto/data.proto.d.ts +5 -5
  78. package/exports/proto/dht-response.proto.d.ts +5 -5
  79. package/exports/proto/dht.proto.d.ts +5 -5
  80. package/exports/proto/file-link.proto.d.ts +6 -6
  81. package/exports/proto/file.proto.d.ts +6 -6
  82. package/exports/proto/peer-response.proto.d.ts +4 -4
  83. package/exports/proto/peer.proto.d.ts +4 -4
  84. package/exports/proto/peernet.proto.d.ts +8 -8
  85. package/exports/proto/ps.proto.d.ts +5 -5
  86. package/exports/proto/request.proto.d.ts +4 -4
  87. package/exports/proto/response.proto.d.ts +4 -4
  88. package/exports/src/prompts/password.js +3 -3
  89. package/exports/utils/utils.d.ts +7 -7
  90. package/index.html +19 -19
  91. package/package.json +59 -55
  92. package/rollup.config.js +53 -53
  93. package/src/dht/dht.js +119 -119
  94. package/src/discovery/peer-discovery.js +75 -75
  95. package/src/handlers/data.js +12 -12
  96. package/src/handlers/message.js +34 -34
  97. package/src/identity.ts +83 -80
  98. package/src/messages/chat.js +14 -14
  99. package/src/messages/data-response.js +14 -14
  100. package/src/messages/data.js +18 -18
  101. package/src/messages/dht-response.js +14 -14
  102. package/src/messages/dht.js +22 -22
  103. package/src/messages/file-link.js +18 -18
  104. package/src/messages/file.js +18 -18
  105. package/src/messages/peer-response.js +14 -14
  106. package/src/messages/peer.js +13 -13
  107. package/src/messages/peernet.js +14 -14
  108. package/src/messages/ps.js +13 -13
  109. package/src/messages/request.js +14 -14
  110. package/src/messages/response.js +14 -14
  111. package/src/messages.js +13 -13
  112. package/src/peer-info.js +9 -9
  113. package/src/peernet.ts +699 -699
  114. package/src/prompts/password/node.js +5 -5
  115. package/src/proto/chat-message.proto.js +6 -6
  116. package/src/utils/utils.js +78 -78
  117. package/test/client.js +6 -6
  118. package/test/codec.js +56 -56
  119. package/test/hash.js +13 -13
  120. package/test/index.js +3 -3
  121. package/test/lastBlock.js +7 -7
  122. package/test/messages.js +26 -26
  123. package/test/peernet.js +17 -17
  124. package/test.js +47 -47
  125. package/test2.js +9 -9
  126. package/test3.js +15 -15
  127. package/test4.js +7 -7
  128. package/tsconfig.json +12 -12
  129. package/coverage/lcov-report/base.css +0 -224
  130. package/coverage/lcov-report/block-navigation.js +0 -87
  131. package/coverage/lcov-report/codec-format-interface.js.html +0 -637
  132. package/coverage/lcov-report/dht-response.js.html +0 -193
  133. package/coverage/lcov-report/favicon.png +0 -0
  134. package/coverage/lcov-report/index.html +0 -131
  135. package/coverage/lcov-report/prettify.css +0 -1
  136. package/coverage/lcov-report/prettify.js +0 -2
  137. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  138. package/coverage/lcov-report/sorter.js +0 -196
  139. package/coverage/lcov.info +0 -199
  140. package/exports/browser/browser-3c1d0477.js +0 -73
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/.eslintrc.json CHANGED
@@ -1,24 +1,24 @@
1
- {
2
- "env": {
3
- "es2022": true
4
- },
5
- "parserOptions": {
6
- "ecmaVersion": "latest",
7
- "sourceType": "module"
8
- },
9
- "extends": "plugin:unicorn/recommended",
10
-
11
- "globals": {
12
- "globalThis": true,
13
- "accountStore": true,
14
- "walletStore": true,
15
- "blockStore": true,
16
- "pubsub": true,
17
- "peerMap": true,
18
- "connections": true,
19
- "recentConnections": true,
20
- "chainStore": true,
21
- "dataStore": true,
22
- "transactionStore": true
23
- }
24
- }
1
+ {
2
+ "env": {
3
+ "es2022": true
4
+ },
5
+ "parserOptions": {
6
+ "ecmaVersion": "latest",
7
+ "sourceType": "module"
8
+ },
9
+ "extends": "plugin:unicorn/recommended",
10
+
11
+ "globals": {
12
+ "globalThis": true,
13
+ "accountStore": true,
14
+ "walletStore": true,
15
+ "blockStore": true,
16
+ "pubsub": true,
17
+ "peerMap": true,
18
+ "connections": true,
19
+ "recentConnections": true,
20
+ "chainStore": true,
21
+ "dataStore": true,
22
+ "transactionStore": true
23
+ }
24
+ }
package/.travis.yml CHANGED
@@ -1,25 +1,27 @@
1
- os:
2
- - linux
3
- - windows
4
- - osx
5
-
6
- language: node_js
7
- node_js:
8
- - 14
9
-
10
- script:
11
- - npm run c
12
- - npm run doc
13
- - npm run test
14
-
15
- after_success:
16
- - npm run coverage
17
- - npm run coveralls
18
- - node deploy.js success $WEBHOOK_URL
19
-
20
- after_failure:
21
- - node deploy.js failure $WEBHOOK_URL
22
-
23
- branches:
24
- only:
25
- - master
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
+ - master
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,64 +1,64 @@
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
- await new Peernet(config)
15
-
16
- console.log(globalThis.peernet)
17
- ```
18
-
19
-
20
-
21
- ## API
22
- #### addRequestHandler
23
-
24
- examples
25
- ```js
26
- peernet.addRequestHandler('lastBlock', () => {
27
- let response;
28
- const height = await chainStore.get('localIndex')
29
- const hash = await chainStore.get('localBlock')
30
- response = JSON.stringify({ height: height.toString(), hash: hash.toString() })
31
- return new ResponseMessage({ response })
32
- // or
33
- return new peernet.protos['peernet-response']({ response })
34
- })
35
- ```
36
-
37
- ```js
38
- peernet.addRequestHandler('hello', () => {
39
- return new ResponseMessage({ response: 'hi' })
40
- // or
41
- return new peernet.protos['peernet-response']({ response: 'hi' })
42
- })
43
- ```
44
-
45
- ## Development
46
-
47
- `note: you need to install jsproject`
48
- ```sh
49
- npm i -g @vandeurenglenn/project
50
- ```
51
-
52
- ### watch
53
- ```sh
54
- npm run w
55
- ```
56
- ### compile
57
- ```sh
58
- npm run c
59
- ```
60
- ### serve html
61
- ```sh
62
- npm run demo
63
- ```
64
-
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
+ await new Peernet(config)
15
+
16
+ console.log(globalThis.peernet)
17
+ ```
18
+
19
+
20
+
21
+ ## API
22
+ #### addRequestHandler
23
+
24
+ examples
25
+ ```js
26
+ peernet.addRequestHandler('lastBlock', () => {
27
+ let response;
28
+ const height = await chainStore.get('localIndex')
29
+ const hash = await chainStore.get('localBlock')
30
+ response = JSON.stringify({ height: height.toString(), hash: hash.toString() })
31
+ return new ResponseMessage({ response })
32
+ // or
33
+ return new peernet.protos['peernet-response']({ response })
34
+ })
35
+ ```
36
+
37
+ ```js
38
+ peernet.addRequestHandler('hello', () => {
39
+ return new ResponseMessage({ response: 'hi' })
40
+ // or
41
+ return new peernet.protos['peernet-response']({ response: 'hi' })
42
+ })
43
+ ```
44
+
45
+ ## Development
46
+
47
+ `note: you need to install jsproject`
48
+ ```sh
49
+ npm i -g @vandeurenglenn/project
50
+ ```
51
+
52
+ ### watch
53
+ ```sh
54
+ npm run w
55
+ ```
56
+ ### compile
57
+ ```sh
58
+ npm run c
59
+ ```
60
+ ### serve html
61
+ ```sh
62
+ npm run demo
63
+ ```
64
+
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] === 'v14' && 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
+ }
@@ -0,0 +1,56 @@
1
+ function _mergeNamespaces(n, m) {
2
+ m.forEach(function (e) {
3
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
4
+ if (k !== 'default' && !(k in n)) {
5
+ var d = Object.getOwnPropertyDescriptor(e, k);
6
+ Object.defineProperty(n, k, d.get ? d : {
7
+ enumerable: true,
8
+ get: function () { return e[k]; }
9
+ });
10
+ }
11
+ });
12
+ });
13
+ return Object.freeze(n);
14
+ }
15
+
16
+ var browser$1 = {};
17
+
18
+ var MediaStream = browser$1.MediaStream = window.MediaStream;
19
+ var MediaStreamTrack = browser$1.MediaStreamTrack = window.MediaStreamTrack;
20
+ var RTCDataChannel = browser$1.RTCDataChannel = window.RTCDataChannel;
21
+ var RTCDataChannelEvent = browser$1.RTCDataChannelEvent = window.RTCDataChannelEvent;
22
+ var RTCDtlsTransport = browser$1.RTCDtlsTransport = window.RTCDtlsTransport;
23
+ var RTCIceCandidate = browser$1.RTCIceCandidate = window.RTCIceCandidate;
24
+ var RTCIceTransport = browser$1.RTCIceTransport = window.RTCIceTransport;
25
+ var RTCPeerConnection = browser$1.RTCPeerConnection = window.RTCPeerConnection;
26
+ var RTCPeerConnectionIceEvent = browser$1.RTCPeerConnectionIceEvent = window.RTCPeerConnectionIceEvent;
27
+ var RTCRtpReceiver = browser$1.RTCRtpReceiver = window.RTCRtpReceiver;
28
+ var RTCRtpSender = browser$1.RTCRtpSender = window.RTCRtpSender;
29
+ var RTCRtpTransceiver = browser$1.RTCRtpTransceiver = window.RTCRtpTransceiver;
30
+ var RTCSctpTransport = browser$1.RTCSctpTransport = window.RTCSctpTransport;
31
+ var RTCSessionDescription = browser$1.RTCSessionDescription = window.RTCSessionDescription;
32
+ var getUserMedia = browser$1.getUserMedia = window.getUserMedia;
33
+ var mediaDevices = browser$1.mediaDevices = navigator.mediaDevices;
34
+
35
+ var browser = /*#__PURE__*/_mergeNamespaces({
36
+ __proto__: null,
37
+ MediaStream: MediaStream,
38
+ MediaStreamTrack: MediaStreamTrack,
39
+ RTCDataChannel: RTCDataChannel,
40
+ RTCDataChannelEvent: RTCDataChannelEvent,
41
+ RTCDtlsTransport: RTCDtlsTransport,
42
+ RTCIceCandidate: RTCIceCandidate,
43
+ RTCIceTransport: RTCIceTransport,
44
+ RTCPeerConnection: RTCPeerConnection,
45
+ RTCPeerConnectionIceEvent: RTCPeerConnectionIceEvent,
46
+ RTCRtpReceiver: RTCRtpReceiver,
47
+ RTCRtpSender: RTCRtpSender,
48
+ RTCRtpTransceiver: RTCRtpTransceiver,
49
+ RTCSctpTransport: RTCSctpTransport,
50
+ RTCSessionDescription: RTCSessionDescription,
51
+ default: browser$1,
52
+ getUserMedia: getUserMedia,
53
+ mediaDevices: mediaDevices
54
+ }, [browser$1]);
55
+
56
+ export { browser as b };
@@ -13,41 +13,49 @@ function _mergeNamespaces(n, m) {
13
13
  return Object.freeze(n);
14
14
  }
15
15
 
16
- var naiveFallback = function () {
17
- if (typeof self === "object" && self) return self;
18
- if (typeof window === "object" && window) return window;
19
- throw new Error("Unable to resolve global `this`");
20
- };
21
-
22
- var global = (function () {
23
- if (this) return this;
24
-
25
- // Unexpected strict mode (may happen if e.g. bundled into ESM module)
26
-
27
- // Fallback to standard globalThis if available
28
- if (typeof globalThis === "object" && globalThis) return globalThis;
29
-
30
- // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
31
- // In all ES5+ engines global object inherits from Object.prototype
32
- // (if you approached one that doesn't please report)
33
- try {
34
- Object.defineProperty(Object.prototype, "__global__", {
35
- get: function () { return this; },
36
- configurable: true
37
- });
38
- } catch (error) {
39
- // Unfortunate case of updates to Object.prototype being restricted
40
- // via preventExtensions, seal or freeze
41
- return naiveFallback();
42
- }
43
- try {
44
- // Safari case (window.__global__ works, but __global__ does not)
45
- if (!__global__) return naiveFallback();
46
- return __global__;
47
- } finally {
48
- delete Object.prototype.__global__;
49
- }
50
- })();
16
+ var global;
17
+ var hasRequiredGlobal;
18
+
19
+ function requireGlobal () {
20
+ if (hasRequiredGlobal) return global;
21
+ hasRequiredGlobal = 1;
22
+ var naiveFallback = function () {
23
+ if (typeof self === "object" && self) return self;
24
+ if (typeof window === "object" && window) return window;
25
+ throw new Error("Unable to resolve global `this`");
26
+ };
27
+
28
+ global = (function () {
29
+ if (this) return this;
30
+
31
+ // Unexpected strict mode (may happen if e.g. bundled into ESM module)
32
+
33
+ // Fallback to standard globalThis if available
34
+ if (typeof globalThis === "object" && globalThis) return globalThis;
35
+
36
+ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
37
+ // In all ES5+ engines global object inherits from Object.prototype
38
+ // (if you approached one that doesn't please report)
39
+ try {
40
+ Object.defineProperty(Object.prototype, "__global__", {
41
+ get: function () { return this; },
42
+ configurable: true
43
+ });
44
+ } catch (error) {
45
+ // Unfortunate case of updates to Object.prototype being restricted
46
+ // via preventExtensions, seal or freeze
47
+ return naiveFallback();
48
+ }
49
+ try {
50
+ // Safari case (window.__global__ works, but __global__ does not)
51
+ if (!__global__) return naiveFallback();
52
+ return __global__;
53
+ } finally {
54
+ delete Object.prototype.__global__;
55
+ }
56
+ })();
57
+ return global;
58
+ }
51
59
 
52
60
  var name = "websocket";
53
61
  var description = "Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.";
@@ -132,7 +140,7 @@ if (typeof globalThis === 'object') {
132
140
  _globalThis = globalThis;
133
141
  } else {
134
142
  try {
135
- _globalThis = global;
143
+ _globalThis = requireGlobal();
136
144
  } catch (error) {
137
145
  } finally {
138
146
  if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; }
@@ -141,7 +149,7 @@ if (typeof globalThis === 'object') {
141
149
  }
142
150
 
143
151
  var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;
144
-
152
+ var websocket_version = version;
145
153
 
146
154
 
147
155
  /**
@@ -179,7 +187,7 @@ if (NativeWebSocket) {
179
187
  */
180
188
  var browser = {
181
189
  'w3cwebsocket' : NativeWebSocket ? W3CWebSocket : null,
182
- 'version' : version
190
+ 'version' : websocket_version
183
191
  };
184
192
 
185
193
  var browser$1 = /*#__PURE__*/_mergeNamespaces({
@@ -1,5 +1,6 @@
1
- import { L as LittlePubSub } from './peernet-e74b2091.js';
1
+ import { L as LittlePubSub } from './peernet-76472a7f.js';
2
2
  import './value-157ab062.js';
3
+ import 'fs/promises';
3
4
 
4
5
  var clientApi = _pubsub => {
5
6
 
@@ -190,7 +191,7 @@ const socketRequestClient = (url, protocols = 'echo-protocol', options = { retry
190
191
  const init = async () => {
191
192
  let ws;
192
193
  if (typeof process === 'object' && !globalThis.WebSocket) {
193
- ws = (await import('./browser-2f0b2829.js').then(function (n) { return n.b; })).default;
194
+ ws = (await import('./browser-e1cd4e67.js').then(function (n) { return n.b; })).default;
194
195
  ws = ws.w3cwebsocket;
195
196
  } else {
196
197
  ws = WebSocket;
@@ -520,7 +521,7 @@ class Client {
520
521
  this.starsConfig = stars;
521
522
  // reconnectJob()
522
523
  if (!globalThis.RTCPeerConnection)
523
- globalThis.wrtc = (await import('./browser-3c1d0477.js').then(function (n) { return n.b; })).default;
524
+ globalThis.wrtc = (await import('./browser-10ffabe1.js').then(function (n) { return n.b; })).default;
524
525
  else
525
526
  globalThis.wrtc = {
526
527
  RTCPeerConnection,
@@ -1,30 +1,30 @@
1
- export default class DhtEarth {
2
- providerMap: Map<any, any>;
3
- /**
4
- * @param {Object} address
5
- * @return {Object} {latitude: lat, longitude: lon}
6
- */
7
- getCoordinates(address: any): any;
8
- /**
9
- * @param {Object} peer
10
- * @param {Object} provider
11
- * @return {Object} {provider, distance}
12
- */
13
- getDistance(peer: any, provider: any): any;
14
- /**
15
- * @param {Array} providers
16
- * @return {Object} closestPeer
17
- */
18
- closestPeer(providers: any[]): any;
19
- /**
20
- * @param {String} hash
21
- * @return {Array} providers
22
- */
23
- providersFor(hash: string): any[];
24
- /**
25
- * @param {String} address
26
- * @param {String} hash
27
- * @return {Array} providers
28
- */
29
- addProvider(address: string, hash: string): any[];
30
- }
1
+ export default class DhtEarth {
2
+ providerMap: Map<any, any>;
3
+ /**
4
+ * @param {Object} address
5
+ * @return {Object} {latitude: lat, longitude: lon}
6
+ */
7
+ getCoordinates(address: any): any;
8
+ /**
9
+ * @param {Object} peer
10
+ * @param {Object} provider
11
+ * @return {Object} {provider, distance}
12
+ */
13
+ getDistance(peer: any, provider: any): any;
14
+ /**
15
+ * @param {Array} providers
16
+ * @return {Object} closestPeer
17
+ */
18
+ closestPeer(providers: any[]): any;
19
+ /**
20
+ * @param {String} hash
21
+ * @return {Array} providers
22
+ */
23
+ providersFor(hash: string): any[];
24
+ /**
25
+ * @param {String} address
26
+ * @param {String} hash
27
+ * @return {Array} providers
28
+ */
29
+ addProvider(address: string, hash: string): any[];
30
+ }
@@ -1,7 +1,7 @@
1
- export default class PeerDiscovery {
2
- constructor(id: any);
3
- id: any;
4
- _getPeerId(id: any): any;
5
- discover(peer: any): Promise<any>;
6
- discoverHandler(message: any, peer: any): Promise<void>;
7
- }
1
+ export default class PeerDiscovery {
2
+ constructor(id: any);
3
+ id: any;
4
+ _getPeerId(id: any): any;
5
+ discover(peer: any): Promise<any>;
6
+ discoverHandler(message: any, peer: any): Promise<void>;
7
+ }
@@ -1,3 +1,3 @@
1
- export function encapsulatedError(): Error;
2
- export function dhtError(proto: any): Error;
3
- export function nothingFoundError(hash: any): Error;
1
+ export function encapsulatedError(): Error;
2
+ export function dhtError(proto: any): Error;
3
+ export function nothingFoundError(hash: any): Error;
@@ -1,2 +1,2 @@
1
- export default dataHandler;
2
- declare function dataHandler(message: any): Promise<void>;
1
+ export default dataHandler;
2
+ declare function dataHandler(message: any): Promise<void>;
@@ -1,30 +1,30 @@
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
+ 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
+ }