mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-06-16 15:41:28 +00:00
Fix eslint
This commit is contained in:
10
src/@types/it-pb-rpc/index.d.ts
vendored
10
src/@types/it-pb-rpc/index.d.ts
vendored
@ -2,11 +2,11 @@ declare module "it-pb-rpc" {
|
|||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
import { Duplex } from "it-pair";
|
import { Duplex } from "it-pair";
|
||||||
type WrappedDuplex = {
|
type WrappedDuplex = {
|
||||||
read(bytes?: number): Promise<Buffer>,
|
read(bytes?: number): Promise<Buffer>;
|
||||||
readLP(): Promise<Buffer>,
|
readLP(): Promise<Buffer>;
|
||||||
write(input: Buffer): void,
|
write(input: Buffer): void;
|
||||||
writeLP(input: Buffer): void,
|
writeLP(input: Buffer): void;
|
||||||
unwrap(): Duplex
|
unwrap(): Duplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Wrap (duplex: any): WrappedDuplex;
|
function Wrap (duplex: any): WrappedDuplex;
|
||||||
|
@ -2,28 +2,28 @@ import { bytes, bytes32 } from "./basic";
|
|||||||
import { Duplex } from "it-pair";
|
import { Duplex } from "it-pair";
|
||||||
|
|
||||||
export interface KeyPair {
|
export interface KeyPair {
|
||||||
publicKey: bytes32,
|
publicKey: bytes32;
|
||||||
privateKey: bytes32,
|
privateKey: bytes32;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PeerId = {
|
export type PeerId = {
|
||||||
id: bytes,
|
id: bytes;
|
||||||
privKey: {
|
privKey: {
|
||||||
marshal(): bytes,
|
marshal(): bytes;
|
||||||
},
|
};
|
||||||
pubKey: {
|
pubKey: {
|
||||||
marshal(): bytes,
|
marshal(): bytes;
|
||||||
},
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface NoiseConnection {
|
export interface NoiseConnection {
|
||||||
remoteEarlyData?(): bytes,
|
remoteEarlyData?(): bytes;
|
||||||
secureOutbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>,
|
secureOutbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>;
|
||||||
secureInbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>,
|
secureInbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SecureOutbound = {
|
export type SecureOutbound = {
|
||||||
conn: Duplex,
|
conn: Duplex;
|
||||||
remotePeer: PeerId,
|
remotePeer: PeerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ import { Duplex } from "it-pair";
|
|||||||
import { NoiseSession } from "./xx";
|
import { NoiseSession } from "./xx";
|
||||||
import { Handshake } from "./handshake";
|
import { Handshake } from "./handshake";
|
||||||
|
|
||||||
interface IReturnEncryptionWrapper {
|
interface ReturnEncryptionWrapper {
|
||||||
(source: any): any;
|
(source: any): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns generator that encrypts payload from the user
|
// Returns generator that encrypts payload from the user
|
||||||
export function encryptStream(handshake: Handshake, session: NoiseSession) : IReturnEncryptionWrapper {
|
export function encryptStream(handshake: Handshake, session: NoiseSession): 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, session);
|
||||||
@ -18,7 +18,7 @@ export function encryptStream(handshake: Handshake, session: NoiseSession) : IRe
|
|||||||
|
|
||||||
|
|
||||||
// Decrypt received payload to the user
|
// Decrypt received payload to the user
|
||||||
export function decryptStream(handshake: Handshake, session: NoiseSession) : IReturnEncryptionWrapper {
|
export function decryptStream(handshake: Handshake, session: NoiseSession): 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, session);
|
||||||
|
Reference in New Issue
Block a user