From 489fcf2b60f7d0198f47bc42724e8a2260779a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Fri, 3 Apr 2020 13:19:43 +0200 Subject: [PATCH 1/3] change bn typings --- package.json | 2 +- src/@types/basic.ts | 2 +- src/handshakes/ik.ts | 2 +- src/handshakes/xx.ts | 2 +- tsconfig.json | 4 +--- yarn.lock | 19 +++++++------------ 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 66ff8ae..599e46d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "@types/mocha": "^5.2.7", "@typescript-eslint/eslint-plugin": "^2.6.0", "@typescript-eslint/parser": "^2.6.0", - "bn.js-typings": "^1.0.1", "chai": "^4.2.0", "eslint": "^6.6.0", "karma": "^4.4.1", @@ -64,6 +63,7 @@ "webpack": "^4.41.5" }, "dependencies": { + "@types/bn.js": "^4.11.6", "bcrypto": "5.0.3", "bn.js": "^5.0.0", "buffer": "^5.4.3", diff --git a/src/@types/basic.ts b/src/@types/basic.ts index 8e3ad53..0e9ba27 100644 --- a/src/@types/basic.ts +++ b/src/@types/basic.ts @@ -1,4 +1,4 @@ -import { BN } from 'bn.js'; +import BN from 'bn.js'; import { Buffer } from 'buffer'; export type bytes = Buffer; diff --git a/src/handshakes/ik.ts b/src/handshakes/ik.ts index a88c38e..b94f7a2 100644 --- a/src/handshakes/ik.ts +++ b/src/handshakes/ik.ts @@ -1,5 +1,5 @@ import {Buffer} from "buffer"; -import {BN} from "bn.js"; +import BN from "bn.js"; import {CipherState, HandshakeState, MessageBuffer, NoiseSession} from "../@types/handshake"; import {bytes, bytes32} from "../@types/basic"; diff --git a/src/handshakes/xx.ts b/src/handshakes/xx.ts index 94f9f83..0caf6bc 100644 --- a/src/handshakes/xx.ts +++ b/src/handshakes/xx.ts @@ -1,5 +1,5 @@ import { Buffer } from 'buffer'; -import { BN } from 'bn.js'; +import BN from 'bn.js'; import { bytes32, bytes } from '../@types/basic' import { KeyPair } from '../@types/libp2p' diff --git a/tsconfig.json b/tsconfig.json index 075738e..001f7ed 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ "noImplicitAny": false, "typeRoots": [ "./node_modules/@types", - "./node_modules/bn.js-typings/index.d.ts", "./src/@types" ] }, @@ -16,7 +15,6 @@ "**/src/**/*.ts" ], "exclude": [ - "node_modules", - "./src/@types" + "node_modules" ] } diff --git a/yarn.lock b/yarn.lock index 7f4c6dc..b1af7f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1056,6 +1056,13 @@ dependencies: "@types/node" "*" +"@types/bn.js@^4.11.6": + version "4.11.6" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" + integrity sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg== + dependencies: + "@types/node" "*" + "@types/chai@^4.2.4": version "4.2.4" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.4.tgz#8936cffad3c96ec470a2dc26a38c3ba8b9b6f619" @@ -1091,11 +1098,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.3.tgz#65a8d9a6a0f6af55595a2d0020617959130d6495" integrity sha512-QZ9CjUB3QoA3f2afw3utKlfRPhpmufB7jC2+oDhLWnXqoyx333fhKSQDLQu2EK7OE0a15X67eYiRAaJsHXrpMA== -"@types/node@^10.12.12": - version "10.17.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.2.tgz#41b5afbcde1a5a805302a4da3cf399499f1bbf64" - integrity sha512-sAh60KDol+MpwOr1RTK0+HgBEYejKsxdpmrOS1Wts5bI03dLzq8F7T0sRXDKeaEK8iWDlGfdzxrzg6vx/c5pNA== - "@typescript-eslint/eslint-plugin@^2.6.0": version "2.6.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.6.0.tgz#e82ed43fc4527b21bfe35c20a2d6e4ed49fc7957" @@ -1650,13 +1652,6 @@ bluebird@^3.3.0, bluebird@^3.5.5: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== -bn.js-typings@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/bn.js-typings/-/bn.js-typings-1.0.1.tgz#00faef56401850b763cee041c0728a9aaf091e7e" - integrity sha512-PdV3AEpI5A8mHCt3KgBobIJ+3rhoxxkRl8b0dCGDgGtJNYmN4KTPLHYq7xOSmKF1Kv06aZ5k8QhXbyG73IyhdQ== - dependencies: - "@types/node" "^10.12.12" - bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.11.8, bn.js@^4.4.0: version "4.11.8" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" From ba7182685a47528f33d4c5c1c39a109b5fbb4c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Fri, 3 Apr 2020 13:20:15 +0200 Subject: [PATCH 2/3] fix interfaces to be compatible with libp2p-ts --- src/@types/it-pair/index.d.ts | 10 ++++++---- src/@types/libp2p.ts | 3 +-- src/noise.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/@types/it-pair/index.d.ts b/src/@types/it-pair/index.d.ts index b325693..1f05d9b 100644 --- a/src/@types/it-pair/index.d.ts +++ b/src/@types/it-pair/index.d.ts @@ -1,6 +1,8 @@ -export type Duplex = [Stream, Stream]; +declare module 'it-pair' { + export type Duplex = [Stream, Stream]; -type Stream = { - sink(source: Iterable); - source: Record; + type Stream = { + sink(source: Iterable): void; + source: Record; + } } diff --git a/src/@types/libp2p.ts b/src/@types/libp2p.ts index e31acaa..151d0ca 100644 --- a/src/@types/libp2p.ts +++ b/src/@types/libp2p.ts @@ -1,5 +1,4 @@ import { bytes, bytes32 } from "./basic"; -import { Duplex } from "it-pair"; import PeerId from "peer-id"; export type KeyPair = { @@ -14,7 +13,7 @@ export interface INoiseConnection { } export type SecureOutbound = { - conn: Duplex; + conn: any; remotePeer: PeerId; } diff --git a/src/noise.ts b/src/noise.ts index 8372197..404d9a7 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -14,7 +14,7 @@ import {uint16BEDecode, uint16BEEncode} from "./encoder"; import {decryptStream, encryptStream} from "./crypto"; import {bytes} from "./@types/basic"; import {INoiseConnection, KeyPair, SecureOutbound} from "./@types/libp2p"; -import {Duplex} from "./@types/it-pair"; +import {Duplex} from "it-pair"; import {IHandshake} from "./@types/handshake-interface"; import {KeyCache} from "./keycache"; import {logger} from "./logger"; From 35941a441c39bc26c3a0f12eb9aab88729c8eaa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Fri, 3 Apr 2020 13:21:03 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f3fc2c..852a673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Bugfixes +- fix types to be compatible with rest of libp2p typescript projects + ## [1.0.0-rc.9] - 2019-03-11 ### Bugfixes