mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-03 16:21:04 +00:00
25 lines
514 B
JavaScript
25 lines
514 B
JavaScript
|
'use strict'
|
||
|
|
||
|
const PeerId = require('peer-id')
|
||
|
const Peers = require('../fixtures/peers')
|
||
|
|
||
|
module.exports = {
|
||
|
tag: '/insecure',
|
||
|
secureInbound: (localPeer, stream) => {
|
||
|
return {
|
||
|
conn: stream,
|
||
|
remotePeer: localPeer
|
||
|
}
|
||
|
},
|
||
|
secureOutbound: async (localPeer, stream, remotePeer) => {
|
||
|
// Crypto should always return a remotePeer
|
||
|
if (!remotePeer) {
|
||
|
remotePeer = await PeerId.createFromJSON(Peers[0])
|
||
|
}
|
||
|
return {
|
||
|
conn: stream,
|
||
|
remotePeer: remotePeer
|
||
|
}
|
||
|
}
|
||
|
}
|