Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function createModules (envType: EnvType, peerInfo: PeerInfo, { bootNodes, discoverBoot, discoverStar, nodes, wrtc }: Config): LibP2p.OptionsModules {
const isCli = envType !== 'browser';
const starTransports = discoverStar
? [new WebRTClient({ wrtc })]
: [];
const transport = isCli
? [WS, TCP]
: [WS];
const peerDiscovery = isCli
? [new Bootstrap({ list: (discoverBoot ? bootNodes : []).concat(nodes) })]
: [];
return {
connEncryption: [
secio
],
streamMuxer: [
mplex,
spdy
],
dht,
peerDiscovery: peerDiscovery.concat(
starTransports.map(({ discovery }): any => discovery)
) as any[],
transport: transport.concat(starTransports as any[])
};