@hive-p2p/server 1.0.33 → 1.0.35
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/arbiter.mjs +2 -1
- package/core/config.mjs +1 -7
- package/core/crypto-codex.mjs +2 -1
- package/core/gossip.mjs +2 -1
- package/core/ice-offer-manager.mjs +2 -1
- package/core/node.mjs +2 -1
- package/core/peer-store.mjs +2 -1
- package/core/topologist.mjs +2 -1
- package/index.mjs +14 -3
- package/package.json +1 -1
- package/services/clock.mjs +1 -1
package/core/arbiter.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CLOCK
|
|
1
|
+
import { CLOCK } from '../services/clock.mjs';
|
|
2
|
+
import { GOSSIP, UNICAST, LOG_CSS } from './config.mjs';
|
|
2
3
|
|
|
3
4
|
// TRUST_BALANCE = seconds of ban if negative - never exceed MAX_TRUST if positive
|
|
4
5
|
// Growing each second by 1000ms until 0
|
package/core/config.mjs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
const isNode = (typeof window === 'undefined');
|
|
2
2
|
if (!isNode) (await import('../libs/simplepeer-9.11.1.min.js')).default;
|
|
3
|
-
import { Clock } from '../services/clock.mjs';
|
|
4
3
|
|
|
5
4
|
// HOLD: GLOBAL CONFIG FOR THE LIBRARY
|
|
6
5
|
// AVOID: CIRCULAR DEPENDENCIES AND TOO MANY FUNCTION/CONSTRUCTOR CONFIG
|
|
7
6
|
// SIMPLIFY: IMPORTS, SIMULATOR AND BROWSER SUPPORT
|
|
8
7
|
|
|
9
|
-
/** Synchronized clock that can be used outside the library */
|
|
10
|
-
export const CLOCK = Clock.instance;
|
|
11
|
-
|
|
12
8
|
export const SIMULATION = {
|
|
13
9
|
/** Specify setInterval() avoidance for faster simulation (true = avoid intervals) | Default: true */
|
|
14
10
|
AVOID_INTERVALS: false,
|
|
@@ -223,6 +219,4 @@ export const LOG_CSS = {
|
|
|
223
219
|
PUNISHER: { BAN: 'color: red; font-weight: bold;', KICK: 'color: darkorange; font-weight: bold;' },
|
|
224
220
|
}
|
|
225
221
|
|
|
226
|
-
export default {
|
|
227
|
-
CLOCK, SIMULATION, NODE, TRANSPORTS, DISCOVERY, IDENTITY, UNICAST, GOSSIP, LOG_CSS
|
|
228
|
-
};
|
|
222
|
+
export default { SIMULATION, NODE, TRANSPORTS, DISCOVERY, IDENTITY, UNICAST, GOSSIP, LOG_CSS };
|
package/core/crypto-codex.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CLOCK
|
|
1
|
+
import { CLOCK } from '../services/clock.mjs';
|
|
2
|
+
import { SIMULATION, NODE, IDENTITY, GOSSIP, UNICAST, LOG_CSS } from './config.mjs';
|
|
2
3
|
import { GossipMessage } from './gossip.mjs';
|
|
3
4
|
import { DirectMessage, ReroutedDirectMessage } from './unicast.mjs';
|
|
4
5
|
import { Converter } from '../services/converter.mjs';
|
package/core/gossip.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CLOCK
|
|
1
|
+
import { CLOCK } from '../services/clock.mjs';
|
|
2
|
+
import { NODE, TRANSPORTS, LOG_CSS } from './config.mjs';
|
|
2
3
|
import { xxHash32 } from '../libs/xxhash32.mjs';
|
|
3
4
|
async function getWrtc() {
|
|
4
5
|
if (typeof globalThis.RTCPeerConnection !== 'undefined') return undefined;
|
package/core/node.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CLOCK
|
|
1
|
+
import { CLOCK } from '../services/clock.mjs';
|
|
2
|
+
import { SIMULATION, NODE, SERVICE, DISCOVERY } from './config.mjs';
|
|
2
3
|
import { Arbiter } from './arbiter.mjs';
|
|
3
4
|
import { OfferManager } from './ice-offer-manager.mjs';
|
|
4
5
|
import { PeerStore } from './peer-store.mjs';
|
package/core/peer-store.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CLOCK
|
|
1
|
+
import { CLOCK } from '../services/clock.mjs';
|
|
2
|
+
import { SIMULATION, NODE, DISCOVERY, LOG_CSS } from './config.mjs';
|
|
2
3
|
const { SANDBOX, ICE_CANDIDATE_EMITTER, TEST_WS_EVENT_MANAGER } = SIMULATION.ENABLED ? await import('../simulation/test-transports.mjs') : {};
|
|
3
4
|
|
|
4
5
|
export class KnownPeer { // known peer, not necessarily connected
|
package/core/topologist.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CLOCK
|
|
1
|
+
import { CLOCK } from '../services/clock.mjs';
|
|
2
|
+
import { SIMULATION, TRANSPORTS, NODE, DISCOVERY, GOSSIP } from './config.mjs';
|
|
2
3
|
import { PeerConnection } from './peer-store.mjs';
|
|
3
4
|
const { SANDBOX, ICE_CANDIDATE_EMITTER, TEST_WS_EVENT_MANAGER } = SIMULATION.ENABLED ? await import('../simulation/test-transports.mjs') : {};
|
|
4
5
|
|
package/index.mjs
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import { Node, createNode, createPublicNode } from "./core/node.mjs";
|
|
2
2
|
import { CryptoCodex } from "./core/crypto-codex.mjs";
|
|
3
|
+
import { CLOCK } from "./services/clock.mjs';
|
|
3
4
|
import CONFIG from "./core/config.mjs";
|
|
4
5
|
|
|
6
|
+
function mergeHiveConfig(target, source) {
|
|
7
|
+
for (const key in source)
|
|
8
|
+
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
9
|
+
target[key] = target[key] || {};
|
|
10
|
+
mergeHiveConfig(target[key], source[key]);
|
|
11
|
+
} else target[key] = source[key];
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
/**
|
|
6
15
|
* @typedef {Object} HiveP2PNamespace
|
|
16
|
+
* @property {typeof CLOCK} CLOCK
|
|
17
|
+
* @property {typeof CONFIG} CONFIG
|
|
18
|
+
* @property {typeof mergeHiveConfig} mergeHiveConfig
|
|
7
19
|
* @property {typeof Node} Node
|
|
8
20
|
* @property {typeof createNode} createNode
|
|
9
21
|
* @property {typeof CryptoCodex} CryptoCodex
|
|
10
22
|
* @property {typeof createPublicNode} createPublicNode
|
|
11
|
-
* @property {typeof CONFIG} CONFIG
|
|
12
23
|
*/
|
|
13
24
|
|
|
14
25
|
/** @type {HiveP2PNamespace} */
|
|
15
|
-
const HiveP2P = { Node, createNode, createPublicNode, CryptoCodex
|
|
16
|
-
export { Node, createNode, createPublicNode, CryptoCodex
|
|
26
|
+
const HiveP2P = { CLOCK, CONFIG, mergeHiveConfig, Node, createNode, createPublicNode, CryptoCodex };
|
|
27
|
+
export { CLOCK, CONFIG, mergeHiveConfig, Node, createNode, createPublicNode, CryptoCodex };
|
|
17
28
|
export default HiveP2P;
|
package/package.json
CHANGED
package/services/clock.mjs
CHANGED
|
@@ -126,7 +126,7 @@ export class Clock {
|
|
|
126
126
|
} catch (error) { if (this.verbose) console.warn('[Clock] Background refine failed:', error); }
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
export const CLOCK = Clock.instance; // Singleton instance
|
|
130
130
|
|
|
131
131
|
export async function CLOCK_TEST() { // DEBUG TEST WHILE RUNNING AS STANDALONE
|
|
132
132
|
const startTime = Date.now();
|