From 09f98fcc123752082f42204e5868aeef3548adc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Fri, 7 Feb 2020 13:06:42 +0100 Subject: [PATCH] update docs --- README.md | 7 +++++-- package.json | 2 +- src/index.ts | 6 ++++++ src/noise.ts | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 55d728f..cfebb52 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,12 @@ This repository contains TypeScript implementation of noise protocol, an encrypt When published, package should be imported as: `import { Noise } from 'libp2p-noise'`. -Example of instantiating noise and passing it to the libp2p config: +Example of using default noise configuration and passing it to the libp2p config: ``` -const NOISE = new Noise(privateKey); +import {NOISE, Noise} from "@nodefactory/js-libp2p-noise" + +//custom noise configuration, pass it instead of NOISE object +const noise = new Noise(privateKey, Buffer.alloc(), false); const libp2p = new Libp2p({ modules: { diff --git a/package.json b/package.json index 272db3a..69bca3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-libp2p-noise", - "version": "1.0.0", + "version": "1.0.0-beta", "main": "dist/index.js", "module": "lib/index.js", "files": [ diff --git a/src/index.ts b/src/index.ts index e481514..2c1d8b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,7 @@ +import {Noise} from "./noise"; export * from "./noise"; + +/** + * Default configuration, it will generate new noise static key and enable noise pipes (IK handshake). + */ +export const NOISE = new Noise(); diff --git a/src/noise.ts b/src/noise.ts index 291bd02..e089465 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -39,9 +39,9 @@ export class Noise implements INoiseConnection { /** * - * @param staticNoiseKey + * @param staticNoiseKey x25519 private key, reuse for faster handshakes * @param earlyData - * @param useNoisePipes + * @param useNoisePipes enable IK handshake if initiator static key is known */ constructor(staticNoiseKey?: bytes, earlyData?: bytes, useNoisePipes = true) { this.earlyData = earlyData || Buffer.alloc(0);