mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 12:02:32 +00:00
Fix eslint
This commit is contained in:
parent
1b89efd288
commit
dd94793e23
@ -3,7 +3,7 @@ import {KeyPair} from "./libp2p";
|
||||
|
||||
export type Hkdf = [bytes, bytes, bytes];
|
||||
|
||||
export interface MessageBuffer {
|
||||
export type MessageBuffer = {
|
||||
ne: bytes32;
|
||||
ns: bytes;
|
||||
ciphertext: bytes;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { bytes, bytes32 } from "./basic";
|
||||
import { Duplex } from "it-pair";
|
||||
|
||||
export interface KeyPair {
|
||||
export type KeyPair = {
|
||||
publicKey: bytes32;
|
||||
privateKey: bytes32;
|
||||
}
|
||||
@ -18,7 +18,7 @@ export type PeerId = {
|
||||
marshalPrivKey(): bytes;
|
||||
};
|
||||
|
||||
export interface NoiseConnection {
|
||||
export interface INoiseConnection {
|
||||
remoteEarlyData?(): bytes;
|
||||
secureOutbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>;
|
||||
secureInbound(localPeer: PeerId, insecure: any, remotePeer: PeerId): Promise<SecureOutbound>;
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { Buffer } from "buffer";
|
||||
import {IHandshake} from "./@types/handshake-interface";
|
||||
|
||||
interface ReturnEncryptionWrapper {
|
||||
interface IReturnEncryptionWrapper {
|
||||
(source: Iterable<Uint8Array>): AsyncIterableIterator<Uint8Array>;
|
||||
}
|
||||
|
||||
const maxPlaintextLength = 65519;
|
||||
|
||||
// Returns generator that encrypts payload from the user
|
||||
export function encryptStream(handshake: IHandshake): ReturnEncryptionWrapper {
|
||||
export function encryptStream(handshake: IHandshake): IReturnEncryptionWrapper {
|
||||
return async function * (source) {
|
||||
for await (const chunk of source) {
|
||||
const chunkBuffer = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.length);
|
||||
@ -28,7 +28,7 @@ export function encryptStream(handshake: IHandshake): ReturnEncryptionWrapper {
|
||||
|
||||
|
||||
// Decrypt received payload to the user
|
||||
export function decryptStream(handshake: IHandshake): ReturnEncryptionWrapper {
|
||||
export function decryptStream(handshake: IHandshake): IReturnEncryptionWrapper {
|
||||
return async function * (source) {
|
||||
for await (const chunk of source) {
|
||||
const chunkBuffer = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.length);
|
||||
|
@ -5,10 +5,6 @@ import { XX } from "./handshakes/xx";
|
||||
import { KeyPair, PeerId } from "./@types/libp2p";
|
||||
import { bytes, bytes32 } from "./@types/basic";
|
||||
import {
|
||||
createHandshakePayload,
|
||||
getHandshakePayload,
|
||||
signEarlyDataPayload,
|
||||
signPayload,
|
||||
verifySignedPayload,
|
||||
} from "./utils";
|
||||
import { logger } from "./logger";
|
||||
|
@ -13,7 +13,7 @@ import { generateKeypair, getPayload } from "./utils";
|
||||
import { uint16BEDecode, uint16BEEncode } from "./encoder";
|
||||
import { decryptStream, encryptStream } from "./crypto";
|
||||
import { bytes } from "./@types/basic";
|
||||
import { NoiseConnection, PeerId, KeyPair, SecureOutbound } from "./@types/libp2p";
|
||||
import { INoiseConnection, PeerId, KeyPair, SecureOutbound } from "./@types/libp2p";
|
||||
import { Duplex } from "./@types/it-pair";
|
||||
import {IHandshake} from "./@types/handshake-interface";
|
||||
|
||||
@ -26,7 +26,7 @@ type HandshakeParams = {
|
||||
remotePeer: PeerId;
|
||||
};
|
||||
|
||||
export class Noise implements NoiseConnection {
|
||||
export class Noise implements INoiseConnection {
|
||||
public protocol = "/noise";
|
||||
|
||||
private readonly prologue = Buffer.from(this.protocol);
|
||||
@ -163,7 +163,7 @@ export class Noise implements NoiseConnection {
|
||||
params: HandshakeParams,
|
||||
payload: bytes,
|
||||
): Promise<IKHandshake> {
|
||||
const { isInitiator, localPeer, remotePeer, connection } = params;
|
||||
const { isInitiator, remotePeer, connection } = params;
|
||||
const handshake = new IKHandshake(isInitiator, payload, this.prologue, this.staticKeys, connection, remotePeer);
|
||||
|
||||
// TODO
|
||||
|
Loading…
x
Reference in New Issue
Block a user