From 6ee527e621089945c89636c9bd8fb2c31c7ef10b Mon Sep 17 00:00:00 2001 From: morrigan Date: Fri, 29 Nov 2019 16:23:24 +0100 Subject: [PATCH] Remove unused --- src/crypto.ts | 9 ++++----- src/noise.ts | 5 ++--- test/handshake.test.ts | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/crypto.ts b/src/crypto.ts index 590ac11..c27d056 100644 --- a/src/crypto.ts +++ b/src/crypto.ts @@ -1,5 +1,4 @@ import { Duplex } from "it-pair"; -import { NoiseSession } from "./xx"; import { Handshake } from "./handshake"; interface ReturnEncryptionWrapper { @@ -7,10 +6,10 @@ interface ReturnEncryptionWrapper { } // Returns generator that encrypts payload from the user -export function encryptStream(handshake: Handshake, session: NoiseSession): ReturnEncryptionWrapper { +export function encryptStream(handshake: Handshake): ReturnEncryptionWrapper { return async function * (source) { for await (const chunk of source) { - const data = await handshake.encrypt(chunk, session); + const data = await handshake.encrypt(chunk, handshake.session); yield data; } } @@ -18,10 +17,10 @@ export function encryptStream(handshake: Handshake, session: NoiseSession): Retu // Decrypt received payload to the user -export function decryptStream(handshake: Handshake, session: NoiseSession): ReturnEncryptionWrapper { +export function decryptStream(handshake: Handshake): ReturnEncryptionWrapper { return async function * (source) { for await (const chunk of source) { - const decrypted = await handshake.decrypt(chunk, session); + const decrypted = await handshake.decrypt(chunk, handshake.session); yield decrypted } } diff --git a/src/noise.ts b/src/noise.ts index 9d09b41..fe33aed 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -12,7 +12,6 @@ import { decryptStream, encryptStream } from "./crypto"; import { bytes } from "./@types/basic"; import { NoiseConnection, PeerId, KeyPair, SecureOutbound } from "./@types/libp2p"; import { Duplex } from "./@types/it-pair"; -import {NoiseSession} from "./xx"; export type WrappedConnection = ReturnType; @@ -102,12 +101,12 @@ export class Noise implements NoiseConnection { pipe( secure, // write to wrapper ensureBuffer, // ensure any type of data is converted to buffer - encryptStream(handshake, handshake.session), // data is encrypted + encryptStream(handshake), // data is encrypted lp.encode({ lengthEncoder: int16BEEncode }), // prefix with message length network, // send to the remote peer lp.decode({ lengthDecoder: int16BEDecode }), // read message length prefix ensureBuffer, // ensure any type of data is converted to buffer - decryptStream(handshake, handshake.session), // decrypt the incoming data + decryptStream(handshake), // decrypt the incoming data secure // pipe to the wrapper ); diff --git a/test/handshake.test.ts b/test/handshake.test.ts index 033d392..7166f49 100644 --- a/test/handshake.test.ts +++ b/test/handshake.test.ts @@ -5,7 +5,7 @@ import Wrap from "it-pb-rpc"; import {Handshake} from "../src/handshake"; import {generateKeypair} from "../src/utils"; -import {createPeerIds, createPeerIdsFromFixtures} from "./fixtures/peer"; +import {createPeerIds} from "./fixtures/peer"; describe("Handshake", () => {