mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 14:42:29 +00:00
Fix eslint
This commit is contained in:
parent
9c898043b8
commit
79d81c3117
4
src/@types/it-pair/index.d.ts
vendored
4
src/@types/it-pair/index.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
export type Duplex = [Stream, Stream];
|
||||
|
||||
type Stream = {
|
||||
sink(source: Iterable<any>),
|
||||
source: Object,
|
||||
sink(source: Iterable<any>);
|
||||
source: Record<string, any>;
|
||||
}
|
||||
|
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 { Duplex } from "it-pair";
|
||||
type WrappedDuplex = {
|
||||
read(bytes: number): Buffer,
|
||||
readLP(): Buffer,
|
||||
write(input: Buffer): void,
|
||||
writeLP(input: Buffer): void,
|
||||
unwrap(): Duplex
|
||||
read(bytes: number): Buffer;
|
||||
readLP(): Buffer;
|
||||
write(input: Buffer): void;
|
||||
writeLP(input: Buffer): void;
|
||||
unwrap(): Duplex;
|
||||
}
|
||||
|
||||
function Wrap (duplex: any): WrappedDuplex;
|
||||
|
@ -2,24 +2,24 @@ import { bytes, bytes32 } from "./basic";
|
||||
import { Duplex } from "it-pair";
|
||||
|
||||
export interface KeyPair {
|
||||
publicKey: bytes32,
|
||||
privateKey: bytes32,
|
||||
publicKey: bytes32;
|
||||
privateKey: bytes32;
|
||||
}
|
||||
|
||||
export type PeerId = {
|
||||
id: string,
|
||||
privKey: string,
|
||||
pubKey: string,
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
};
|
||||
|
||||
export interface NoiseConnection {
|
||||
remoteEarlyData?(): bytes,
|
||||
secureOutbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>,
|
||||
secureInbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>,
|
||||
remoteEarlyData?(): bytes;
|
||||
secureOutbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>;
|
||||
secureInbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>;
|
||||
}
|
||||
|
||||
export type SecureOutbound = {
|
||||
conn: Duplex,
|
||||
remotePeer: PeerId,
|
||||
conn: Duplex;
|
||||
remotePeer: PeerId;
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,13 @@ import { NoiseSession } from "./xx";
|
||||
|
||||
// Send encrypted payload from the user to stream
|
||||
export async function encryptStreams(streams: Duplex, session: NoiseSession): Promise<Duplex> {
|
||||
|
||||
// TODO: implement
|
||||
return streams;
|
||||
}
|
||||
|
||||
|
||||
// Decrypt received payload from the stream and pipe to user
|
||||
export async function decryptStreams(streams: Duplex, session: NoiseSession): Promise<Duplex> {
|
||||
|
||||
// TODO: implement
|
||||
return streams;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export const getHandshakePayload = (publicKey: bytes ) => Buffer.concat([Buffer.
|
||||
|
||||
export const getEarlyDataPayload = (earlyData: bytes) => Buffer.concat([Buffer.from("noise-libp2p-early-data:"), earlyData]);
|
||||
|
||||
function resolveEarlyDataPayload(privateKey?: bytes, earlyData?: bytes) : Object {
|
||||
function resolveEarlyDataPayload(privateKey?: bytes, earlyData?: bytes): Record<string, any> {
|
||||
if (!earlyData || !privateKey) {
|
||||
return {};
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ export class XXHandshake {
|
||||
return { cs, ck, h };
|
||||
}
|
||||
|
||||
private mixKey(ss: SymmetricState, ikm: bytes32) {
|
||||
private mixKey(ss: SymmetricState, ikm: bytes32): void {
|
||||
const [ ck, tempK ] = this.getHkdf(ss.ck, ikm);
|
||||
ss.cs = this.initializeKey(tempK) as CipherState;
|
||||
ss.ck = ck;
|
||||
@ -183,7 +183,7 @@ export class XXHandshake {
|
||||
return [ k1, k2, k3 ];
|
||||
}
|
||||
|
||||
private mixHash(ss: SymmetricState, data: bytes) {
|
||||
private mixHash(ss: SymmetricState, data: bytes): void {
|
||||
ss.h = this.getHash(ss.h, data);
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ export class XXHandshake {
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
private split (ss: SymmetricState) {
|
||||
private split (ss: SymmetricState): void {
|
||||
const [ tempk1, tempk2 ] = this.getHkdf(ss.ck, Buffer.alloc(0));
|
||||
const cs1 = this.initializeKey(tempk1);
|
||||
const cs2 = this.initializeKey(tempk2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user