This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const STATUS = { | |
OPEN: 0, | |
CLOSED: 1, | |
CLOSING: 2, | |
} | |
const ROLE = { | |
INITIATOR: 0, | |
RESPONDER: 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ROLE = { | |
INITIATOR: 0, | |
RESPONDER: 1 | |
} | |
class Stream { | |
constructor(iterableDuplex, connection, isInitiator = true) { | |
/** | |
* Stream identifier | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promiseToCallback = require('promise-to-callback') | |
const toPull = require('async-iterator-to-pull-stream') | |
const encrypt = async (localId, conn, remoteId) => { | |
// TODO implementation | |
// ... | |
pull( | |
conn, | |
toPull.duplex(handshake(state, finish)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const assert = require('assert') | |
const debug = require('debug') | |
const EventEmitter = require('events') | |
const errcode = require('err-code') | |
const PeerInfo = require('peer-info') | |
const message = require('./message') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const node = await Libp2p.create({ | |
modules: { | |
// Your modules | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const WebSockets = require('libp2p-websockets') | |
const WebRtcStar = require('libp2p-webrtc-star') | |
const node = await Libp2p.create({ | |
modules: { | |
transport: [WebSockets, WebRtcStar] | |
// … | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const WebSockets = require('libp2p-websockets') | |
const WebRtcStar = require('libp2p-webrtc-star') | |
const { NOISE } = require('libp2p-noise') | |
const node = await Libp2p.create({ | |
modules: { | |
transport: [WebSockets, WebRtcStar], | |
connEncryption: [NOISE] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const WebSockets = require('libp2p-websockets') | |
const WebRtcStar = require('libp2p-webrtc-star') | |
const { NOISE } = require('libp2p-noise') | |
const MPLEX = require('libp2p-mplex') | |
const node = await Libp2p.create({ | |
modules: { | |
transport: [WebSockets, WebRtcStar], | |
connEncryption: [NOISE], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const WebSockets = require('libp2p-websockets') | |
const WebRtcStar = require('libp2p-webrtc-star') | |
const { NOISE } = require('libp2p-noise') | |
const MPLEX = require('libp2p-mplex') | |
const node = await Libp2p.create({ | |
modules: { | |
transport: [WebSockets, WebRtcStar], | |
connEncryption: [NOISE], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const WebSockets = require('libp2p-websockets') | |
const WebRtcStar = require('libp2p-webrtc-star') | |
const Bootstrap = require('libp2p-bootstrap') | |
const Mdns = require('libp2p-mdns') | |
// Known peers addresses | |
const bootstrapMultiaddrs = [ | |
'/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', | |
'/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3' |
OlderNewer