@hive-p2p/browser 1.0.89 → 1.0.91
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/core/crypto-codex.mjs +6 -1
- package/core/gossip.mjs +5 -3
- package/core/node.mjs +24 -25
- package/core/topologist.mjs +5 -3
- package/core/unicast.mjs +9 -5
- package/hive-p2p.min.js +3 -3
- package/package.json +1 -1
- package/rendering/NetworkRenderer.mjs +7 -5
- package/rendering/visualizer.html +1 -0
- package/rendering/visualizer.mjs +6 -2
- package/services/cryptos.mjs +4 -1
package/package.json
CHANGED
|
@@ -283,7 +283,7 @@ export class NetworkRenderer {
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
displayDirectMessageRoute(relayerId, route = [], frameToIgnore = 30) {
|
|
286
|
-
const fto = Math.round(frameToIgnore * (this.
|
|
286
|
+
const fto = Math.round(frameToIgnore * (this.fps / 60));
|
|
287
287
|
const maxTraveledColorIndex = this.colors.traveledConnection.length - 1;
|
|
288
288
|
let traveledIndex = 0;
|
|
289
289
|
let isRelayerIdPassed = false;
|
|
@@ -295,8 +295,8 @@ export class NetworkRenderer {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
displayGossipMessageRoute(relayerId, senderId, topic = 'peer_connected', data, frameToIgnore = 25) {
|
|
298
|
-
const fto = Math.round(frameToIgnore * (this.
|
|
299
|
-
const fto2 = Math.round((frameToIgnore + 5) * (this.
|
|
298
|
+
const fto = Math.round(frameToIgnore * (this.fps / 60));
|
|
299
|
+
const fto2 = Math.round((frameToIgnore + 5) * (this.fps / 60));
|
|
300
300
|
this.connectionsStore.updateOrAssignLineColor(senderId, relayerId, this.colors.gossipOutgoingColor, .4, fto, true);
|
|
301
301
|
this.connectionsStore.updateOrAssignLineColor(relayerId, this.currentPeerId, this.colors.gossipIncomingColor, .8, fto2, true);
|
|
302
302
|
}
|
|
@@ -701,8 +701,9 @@ export class NetworkRenderer {
|
|
|
701
701
|
}
|
|
702
702
|
|
|
703
703
|
lastPhysicUpdate = 0;
|
|
704
|
-
frameCount = 60;
|
|
705
704
|
lastFpsUpdate = 0;
|
|
705
|
+
frameCount = 60;
|
|
706
|
+
fps = 60;
|
|
706
707
|
#animate() {
|
|
707
708
|
if (!this.isAnimating) return;
|
|
708
709
|
|
|
@@ -710,7 +711,8 @@ export class NetworkRenderer {
|
|
|
710
711
|
this.frameCount++;
|
|
711
712
|
if (currentTime - this.lastFpsUpdate >= 1000) {
|
|
712
713
|
if (this.frameCount < 60 * .98) this.updateBatchMax = Math.round(Math.max(100, this.updateBatchMax * .9));
|
|
713
|
-
this.
|
|
714
|
+
this.fps = 0 + this.frameCount;
|
|
715
|
+
this.fpsCountElement.textContent = this.fps;
|
|
714
716
|
this.frameCount = 0;
|
|
715
717
|
this.lastFpsUpdate = currentTime;
|
|
716
718
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<title>P2P Network Visualization - Three.js</title>
|
|
5
5
|
<link rel="stylesheet" href="./rendering/visualizer.css">
|
|
6
6
|
<script src="./libs/three-4.5.min.js"></script>
|
|
7
|
+
<script src="./packages/browser-min/hive-p2p.min.js" type="module"></script>
|
|
7
8
|
<script src="./rendering/visualizer.mjs" type="module"></script>
|
|
8
9
|
</head>
|
|
9
10
|
<body>
|
package/rendering/visualizer.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { NetworkRenderer } from './NetworkRenderer.mjs';
|
|
2
|
-
import { CryptoCodex } from '../core/crypto-codex.mjs';
|
|
2
|
+
//import { CryptoCodex } from '../core/crypto-codex.mjs';
|
|
3
|
+
//window.CryptoCodex = CryptoCodex; // Expose for debugging
|
|
4
|
+
|
|
5
|
+
// NOW WE USE THE MIN LIBRARY WHICH EXPOSES CRYPTOCODEX IN THE BROWSER BUILD
|
|
6
|
+
/** @type {import("../core/crypto-codex.mjs").CryptoCodex} */
|
|
7
|
+
const CryptoCodex = HiveP2P.CryptoCodex;
|
|
3
8
|
window.CryptoCodex = CryptoCodex; // Expose for debugging
|
|
4
9
|
|
|
5
10
|
class SimulationInterface {
|
|
@@ -10,7 +15,6 @@ class SimulationInterface {
|
|
|
10
15
|
onPeersIds;
|
|
11
16
|
onPeerInfo;
|
|
12
17
|
onPeerMessage;
|
|
13
|
-
|
|
14
18
|
responseReceivedByType = {};
|
|
15
19
|
|
|
16
20
|
/** @param {function} onSettings @param {function} onPeersIds @param {function} onPeerInfo */
|
package/services/cryptos.mjs
CHANGED
|
@@ -35,6 +35,7 @@ export class Argon2Unified {
|
|
|
35
35
|
|
|
36
36
|
return result;
|
|
37
37
|
}
|
|
38
|
+
/** This function tries to load an Argon2 library in a unified way for both browser and NodeJS environments. */
|
|
38
39
|
async getArgon2Lib() {
|
|
39
40
|
if (this.argon2) return this.argon2;
|
|
40
41
|
|
|
@@ -57,8 +58,9 @@ export class Argon2Unified {
|
|
|
57
58
|
this.argon2 = argon2ES6.default;
|
|
58
59
|
return this.argon2;
|
|
59
60
|
};
|
|
61
|
+
/** @param {string} pass @param {string | Uint8Array} salt @param {number} time @param {number} mem @param {number} parallelism @param {number} type @param {number} hashLen */
|
|
60
62
|
#createArgon2Params(pass = "averylongpassword123456", salt = "saltsaltsaltsaltsalt", time = 1, mem = 2**10, parallelism = 1, type = 2, hashLen = 32) {
|
|
61
|
-
const fixedSalt = salt.padEnd(
|
|
63
|
+
const fixedSalt = salt.padEnd(16, '0').substring(0, 16); // 32 bytes minimum
|
|
62
64
|
return {
|
|
63
65
|
type, pass, parallelism,
|
|
64
66
|
time, timeCost: time, // we preserve both for compatibility
|
|
@@ -67,6 +69,7 @@ export class Argon2Unified {
|
|
|
67
69
|
salt: IS_BROWSER ? fixedSalt : Buffer.from(fixedSalt),
|
|
68
70
|
};
|
|
69
71
|
}
|
|
72
|
+
/** @param {string} encoded - Argon2 encoded string (e.g. $argon2id$v=19$m=1048576,t=1,p=1$c2FsdHNhbHRzYWx0c2FsdHNhbHQ$UamPN/XTTX4quPewQNw4/s3y1JJeS22cRroh5l7OTMM) */
|
|
70
73
|
#standardizeArgon2FromEncoded(encoded = '$argon2id$v=19$m=1048576,t=1,p=1$c2FsdHNhbHRzYWx0c2FsdHNhbHQ$UamPN/XTTX4quPewQNw4/s3y1JJeS22cRroh5l7OTMM') {
|
|
71
74
|
const base64 = encoded.split('$').pop();
|
|
72
75
|
const hash = this.converter.base64toBytes(base64);
|