mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-08-01 00:41:57 +00:00
chore: config types and dependencies update (#904)
BREAKING CHANGES: top level types were updated, multiaddr@9.0.0 is used, dialer and keychain internal property names changed and connectionManager minPeers is not supported anymore
This commit is contained in:
@@ -7,6 +7,7 @@ const log = Object.assign(debug('libp2p:pnet'), {
|
||||
})
|
||||
|
||||
const Errors = require('./errors')
|
||||
// @ts-ignore xsalsa20 has no types exported
|
||||
const xsalsa20 = require('xsalsa20')
|
||||
const KEY_LENGTH = require('./key-generator').KEY_LENGTH
|
||||
const uint8ArrayFromString = require('uint8arrays/from-string')
|
||||
@@ -21,7 +22,8 @@ const uint8ArrayToString = require('uint8arrays/to-string')
|
||||
*/
|
||||
module.exports.createBoxStream = (nonce, psk) => {
|
||||
const xor = xsalsa20(nonce, psk)
|
||||
return (source) => (async function * () {
|
||||
|
||||
return (/** @type {AsyncIterable<Uint8Array>} */ source) => (async function * () {
|
||||
for await (const chunk of source) {
|
||||
yield Uint8Array.from(xor.update(chunk.slice()))
|
||||
}
|
||||
@@ -36,7 +38,7 @@ module.exports.createBoxStream = (nonce, psk) => {
|
||||
* @returns {*} a through iterable
|
||||
*/
|
||||
module.exports.createUnboxStream = (nonce, psk) => {
|
||||
return (source) => (async function * () {
|
||||
return (/** @type {AsyncIterable<Uint8Array>} */ source) => (async function * () {
|
||||
const xor = xsalsa20(nonce, psk)
|
||||
log.trace('Decryption enabled')
|
||||
|
||||
@@ -51,7 +53,7 @@ module.exports.createUnboxStream = (nonce, psk) => {
|
||||
*
|
||||
* @param {Uint8Array} pskBuffer
|
||||
* @throws {INVALID_PSK}
|
||||
* @returns {Object} The PSK metadata (tag, codecName, psk)
|
||||
* @returns {{ tag?: string, codecName?: string, psk: Uint8Array }} The PSK metadata (tag, codecName, psk)
|
||||
*/
|
||||
module.exports.decodeV1PSK = (pskBuffer) => {
|
||||
try {
|
||||
|
@@ -6,6 +6,7 @@ const log = Object.assign(debug('libp2p:pnet'), {
|
||||
})
|
||||
const { pipe } = require('it-pipe')
|
||||
const errcode = require('err-code')
|
||||
// @ts-ignore it-pair has no types exported
|
||||
const duplexPair = require('it-pair/duplex')
|
||||
const crypto = require('libp2p-crypto')
|
||||
const Errors = require('./errors')
|
||||
@@ -17,6 +18,7 @@ const {
|
||||
createUnboxStream,
|
||||
decodeV1PSK
|
||||
} = require('./crypto')
|
||||
// @ts-ignore it-handshake has no types exported
|
||||
const handshake = require('it-handshake')
|
||||
const { NONCE_LENGTH } = require('./key-generator')
|
||||
|
||||
|
@@ -22,8 +22,12 @@ module.exports = generate
|
||||
module.exports.NONCE_LENGTH = 24
|
||||
module.exports.KEY_LENGTH = KEY_LENGTH
|
||||
|
||||
// @ts-ignore This condition will always return 'false' since the types 'Module | undefined'
|
||||
if (require.main === module) {
|
||||
// @ts-ignore
|
||||
generate(process.stdout)
|
||||
try {
|
||||
// @ts-ignore This condition will always return 'false' since the types 'Module | undefined'
|
||||
if (require.main === module) {
|
||||
// @ts-ignore
|
||||
generate(process.stdout)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user