@hive-p2p/server 1.0.32 → 1.0.34
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 +3 -1
- package/core/peer-store.mjs +2 -1
- package/core/topologist.mjs +2 -1
- package/index.mjs +14 -2
- 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';
|
|
@@ -139,6 +140,7 @@ export class Node {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
// PUBLIC API
|
|
143
|
+
/** @returns {string | undefined} */
|
|
142
144
|
get publicUrl() { return this.services?.publicUrl; }
|
|
143
145
|
|
|
144
146
|
onMessageData(callback) { this.messager.on('message', callback); }
|
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,7 +1,19 @@
|
|
|
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
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} HiveP2PNamespace
|
|
8
|
+
* @property {typeof CLOCK} CLOCK
|
|
9
|
+
* @property {typeof CONFIG} CONFIG
|
|
10
|
+
* @property {typeof Node} Node
|
|
11
|
+
* @property {typeof createNode} createNode
|
|
12
|
+
* @property {typeof CryptoCodex} CryptoCodex
|
|
13
|
+
* @property {typeof createPublicNode} createPublicNode
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** @type {HiveP2PNamespace} */
|
|
17
|
+
const HiveP2P = { CLOCK, CONFIG, Node, createNode, createPublicNode, CryptoCodex };
|
|
18
|
+
export { CLOCK, CONFIG, Node, createNode, createPublicNode, CryptoCodex };
|
|
7
19
|
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();
|