mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 15:12:32 +00:00
Remove unused
This commit is contained in:
parent
6dc8e8288d
commit
6ee527e621
@ -1,5 +1,4 @@
|
|||||||
import { Duplex } from "it-pair";
|
import { Duplex } from "it-pair";
|
||||||
import { NoiseSession } from "./xx";
|
|
||||||
import { Handshake } from "./handshake";
|
import { Handshake } from "./handshake";
|
||||||
|
|
||||||
interface ReturnEncryptionWrapper {
|
interface ReturnEncryptionWrapper {
|
||||||
@ -7,10 +6,10 @@ interface ReturnEncryptionWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns generator that encrypts payload from the user
|
// 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) {
|
return async function * (source) {
|
||||||
for await (const chunk of source) {
|
for await (const chunk of source) {
|
||||||
const data = await handshake.encrypt(chunk, session);
|
const data = await handshake.encrypt(chunk, handshake.session);
|
||||||
yield data;
|
yield data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,10 +17,10 @@ export function encryptStream(handshake: Handshake, session: NoiseSession): Retu
|
|||||||
|
|
||||||
|
|
||||||
// Decrypt received payload to the user
|
// Decrypt received payload to the user
|
||||||
export function decryptStream(handshake: Handshake, session: NoiseSession): ReturnEncryptionWrapper {
|
export function decryptStream(handshake: Handshake): ReturnEncryptionWrapper {
|
||||||
return async function * (source) {
|
return async function * (source) {
|
||||||
for await (const chunk of source) {
|
for await (const chunk of source) {
|
||||||
const decrypted = await handshake.decrypt(chunk, session);
|
const decrypted = await handshake.decrypt(chunk, handshake.session);
|
||||||
yield decrypted
|
yield decrypted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import { decryptStream, encryptStream } from "./crypto";
|
|||||||
import { bytes } from "./@types/basic";
|
import { bytes } from "./@types/basic";
|
||||||
import { NoiseConnection, PeerId, KeyPair, SecureOutbound } from "./@types/libp2p";
|
import { NoiseConnection, PeerId, KeyPair, SecureOutbound } from "./@types/libp2p";
|
||||||
import { Duplex } from "./@types/it-pair";
|
import { Duplex } from "./@types/it-pair";
|
||||||
import {NoiseSession} from "./xx";
|
|
||||||
|
|
||||||
export type WrappedConnection = ReturnType<typeof Wrap>;
|
export type WrappedConnection = ReturnType<typeof Wrap>;
|
||||||
|
|
||||||
@ -102,12 +101,12 @@ export class Noise implements NoiseConnection {
|
|||||||
pipe(
|
pipe(
|
||||||
secure, // write to wrapper
|
secure, // write to wrapper
|
||||||
ensureBuffer, // ensure any type of data is converted to buffer
|
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
|
lp.encode({ lengthEncoder: int16BEEncode }), // prefix with message length
|
||||||
network, // send to the remote peer
|
network, // send to the remote peer
|
||||||
lp.decode({ lengthDecoder: int16BEDecode }), // read message length prefix
|
lp.decode({ lengthDecoder: int16BEDecode }), // read message length prefix
|
||||||
ensureBuffer, // ensure any type of data is converted to buffer
|
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
|
secure // pipe to the wrapper
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import Wrap from "it-pb-rpc";
|
|||||||
|
|
||||||
import {Handshake} from "../src/handshake";
|
import {Handshake} from "../src/handshake";
|
||||||
import {generateKeypair} from "../src/utils";
|
import {generateKeypair} from "../src/utils";
|
||||||
import {createPeerIds, createPeerIdsFromFixtures} from "./fixtures/peer";
|
import {createPeerIds} from "./fixtures/peer";
|
||||||
|
|
||||||
|
|
||||||
describe("Handshake", () => {
|
describe("Handshake", () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user