From 37c1e6b968beda18ec891e2e142938e6c8f42482 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Mon, 31 Oct 2022 14:32:39 +1100 Subject: [PATCH 01/23] chore: new @waku/create package --- package-lock.json | 70 ++++++- packages/core/package.json | 4 - packages/core/rollup.config.js | 1 - packages/core/typedoc.json | 1 - packages/create/.eslintrc.cjs | 6 + packages/create/.prettierignore | 4 + packages/create/package.json | 186 ++++++++++++++++++ packages/create/rollup.config.js | 21 ++ .../create_waku.ts => create/src/index.ts} | 0 packages/create/tsconfig.dev.json | 8 + packages/create/tsconfig.json | 54 +++++ packages/create/typedoc.json | 10 + 12 files changed, 358 insertions(+), 7 deletions(-) create mode 100644 packages/create/.eslintrc.cjs create mode 100644 packages/create/.prettierignore create mode 100644 packages/create/package.json create mode 100644 packages/create/rollup.config.js rename packages/{core/src/lib/create_waku.ts => create/src/index.ts} (100%) create mode 100644 packages/create/tsconfig.dev.json create mode 100644 packages/create/tsconfig.json create mode 100644 packages/create/typedoc.json diff --git a/package-lock.json b/package-lock.json index d42cd04e84..bd89346aa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5275,6 +5275,10 @@ "resolved": "packages/core", "link": true }, + "node_modules/@waku/create": { + "resolved": "packages/create", + "link": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", @@ -22464,6 +22468,40 @@ "node": ">=16.0.0", "npm": ">=7.0.0" } + }, + "packages/create": { + "version": "0.0.1", + "license": "MIT OR Apache-2.0", + "devDependencies": { + "@rollup/plugin-commonjs": "^22.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.3.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^8.0.6", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "rollup": "^2.75.0", + "semantic-release": "^19.0.5", + "semantic-release-monorepo": "^7.0.5", + "typedoc": "^0.23.10", + "typescript": "^4.6.3" + }, + "engines": { + "node": ">=16" + } } }, "dependencies": { @@ -26742,7 +26780,7 @@ "puppeteer": "^13.0.1", "rollup": "^2.75.0", "semantic-release": "^19.0.5", - "semantic-release-monorepo": "*", + "semantic-release-monorepo": "^7.0.5", "tail": "^2.2.0", "ts-loader": "^9.3.1", "ts-node": "^10.9.1", @@ -26783,6 +26821,36 @@ } } }, + "@waku/create": { + "version": "file:packages/create", + "requires": { + "@rollup/plugin-commonjs": "^22.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.3.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^8.0.6", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "rollup": "^2.75.0", + "semantic-release": "^19.0.5", + "semantic-release-monorepo": "^7.0.5", + "typedoc": "^0.23.10", + "typescript": "^4.6.3" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", diff --git a/packages/core/package.json b/packages/core/package.json index fbe8d1676d..c7b207f89a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,10 +9,6 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js" }, - "./lib/create_waku": { - "types": "./dist/lib/create_waku.d.ts", - "import": "./dist/lib/create_waku.js" - }, "./lib/interfaces": { "types": "./dist/lib/interfaces.d.ts" }, diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.js index c4867c7c61..79fd67420e 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.js @@ -5,7 +5,6 @@ import json from "@rollup/plugin-json"; export default { input: { index: "dist/index.js", - "lib/create_waku": "dist/lib/create_waku.js", "lib/peer_discovery_dns": "dist/lib/peer_discovery_dns/index.js", "lib/peer_discovery_static_list": "dist/lib/peer_discovery_static_list.js", "lib/predefined_bootstrap_nodes": "dist/lib/predefined_bootstrap_nodes.js", diff --git a/packages/core/typedoc.json b/packages/core/typedoc.json index 31019f4fff..652c71ed24 100644 --- a/packages/core/typedoc.json +++ b/packages/core/typedoc.json @@ -1,7 +1,6 @@ { "entryPoints": [ "./src/index.ts", - "./src/lib/create_waku.ts", "./src/lib/interfaces.ts", "./src/lib/peer_discovery_dns.ts", "./src/lib/peer_discovery_static_list.ts", diff --git a/packages/create/.eslintrc.cjs b/packages/create/.eslintrc.cjs new file mode 100644 index 0000000000..324f1f526d --- /dev/null +++ b/packages/create/.eslintrc.cjs @@ -0,0 +1,6 @@ +module.exports = { + parserOptions: { + tsconfigRootDir: __dirname, + project: "./tsconfig.dev.json", + }, +}; diff --git a/packages/create/.prettierignore b/packages/create/.prettierignore new file mode 100644 index 0000000000..fecb37a393 --- /dev/null +++ b/packages/create/.prettierignore @@ -0,0 +1,4 @@ +build +bundle +dist +node_modules diff --git a/packages/create/package.json b/packages/create/package.json new file mode 100644 index 0000000000..c103f00ea2 --- /dev/null +++ b/packages/create/package.json @@ -0,0 +1,186 @@ +{ + "name": "@waku/create", + "version": "0.0.1", + "description": "Easily create a Waku node", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "typesVersions": { + "*": { + "lib/*": [ + "dist/lib/*" + ] + } + }, + "type": "module", + "author": "Waku Team", + "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/create#readme", + "repository": { + "type": "git", + "url": "https://github.com/waku-org/js-waku.git" + }, + "bugs": { + "url": "https://github.com/waku-org/js-waku/issues" + }, + "license": "MIT OR Apache-2.0", + "keywords": [ + "waku", + "decentralized", + "secure", + "communication", + "web3", + "ethereum", + "dapps", + "privacy" + ], + "scripts": { + "build": "run-s build:**", + "build:esm": "tsc", + "build:bundle": "rollup --config rollup.config.js", + "fix": "run-s fix:*", + "fix:prettier": "prettier . --write", + "fix:lint": "eslint src --ext .ts --ext .cjs --fix", + "check": "run-s check:*", + "check:lint": "eslint src --ext .ts", + "check:prettier": "prettier . --list-different", + "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", + "check:tsc": "tsc -p tsconfig.dev.json", + "test": "exit 0 # Tested in @waku/core", + "proto": "exit 0 # no proto", + "doc": "run-s doc:*", + "doc:html": "typedoc --treatWarningsAsErrors", + "prepublish": "npm run build", + "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", + "release": "semantic-release" + }, + "engines": { + "node": ">=16" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "^22.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.3.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^8.0.6", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "rollup": "^2.75.0", + "semantic-release": "^19.0.5", + "semantic-release-monorepo": "^7.0.5", + "typedoc": "^0.23.10", + "typescript": "^4.6.3" + }, + "release": { + "branches": [ + "master" + ], + "extends": "semantic-release-monorepo", + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "doc", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "scope": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "doc", + "section": "Documentation" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, + "files": [ + "dist", + "bundle", + "src/*.ts", + "src/lib/**/*.ts", + "src/proto/**/*.ts", + "!**/*.spec.*", + "!**/*.json", + "CHANGELOG.md", + "LICENSE", + "README.md" + ] +} diff --git a/packages/create/rollup.config.js b/packages/create/rollup.config.js new file mode 100644 index 0000000000..a03dc334f0 --- /dev/null +++ b/packages/create/rollup.config.js @@ -0,0 +1,21 @@ +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import commonjs from "@rollup/plugin-commonjs"; +import json from "@rollup/plugin-json"; + +export default { + input: { + index: "dist/index.js", + }, + output: { + dir: "bundle", + format: "esm", + }, + plugins: [ + commonjs(), + json(), + nodeResolve({ + browser: true, + preferBuiltins: false, + }), + ], +}; diff --git a/packages/core/src/lib/create_waku.ts b/packages/create/src/index.ts similarity index 100% rename from packages/core/src/lib/create_waku.ts rename to packages/create/src/index.ts diff --git a/packages/create/tsconfig.dev.json b/packages/create/tsconfig.dev.json new file mode 100644 index 0000000000..ffc27ef6ba --- /dev/null +++ b/packages/create/tsconfig.dev.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "module": "esnext", + "noEmit": true + }, + "exclude": [] +} diff --git a/packages/create/tsconfig.json b/packages/create/tsconfig.json new file mode 100644 index 0000000000..7b01b30897 --- /dev/null +++ b/packages/create/tsconfig.json @@ -0,0 +1,54 @@ +{ + "compilerOptions": { + "incremental": true, + "target": "es2020", + "outDir": "dist/", + "rootDir": "src", + "moduleResolution": "node", + "module": "es2020", + "declaration": true, + "sourceMap": true, + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "resolveJsonModule": true /* Include modules imported with .json extension. */, + "tsBuildInfoFile": "dist/.tsbuildinfo", + "strict": true /* Enable all strict type-checking options. */, + + /* Strict Type-Checking Options */ + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + "strictNullChecks": true /* Enable strict null checks. */, + "strictFunctionTypes": true /* Enable strict checking of function types. */, + "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, + "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, + "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */, + "noUnusedParameters": true /* Report errors on unused parameters. */, + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "forceConsistentCasingInFileNames": true, + + /* Debugging Options */ + "traceResolution": false /* Report module resolution log messages. */, + "listEmittedFiles": false /* Print names of generated files part of the compilation. */, + "listFiles": false /* Print names of files part of the compilation. */, + "pretty": true /* Stylize errors and messages using color and context. */, + + // Due to broken types in indirect dependencies + "skipLibCheck": true, + + /* Experimental Options */ + // "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, + // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, + + "lib": ["es2020", "dom"], + "types": ["node", "mocha"], + "typeRoots": ["node_modules/@types", "src/types"] + }, + "include": ["src"], + "exclude": ["src/**/*.spec.ts", "src/test_utils"], + "compileOnSave": false, + "ts-node": { + "files": true + } +} diff --git a/packages/create/typedoc.json b/packages/create/typedoc.json new file mode 100644 index 0000000000..1b4aa6af86 --- /dev/null +++ b/packages/create/typedoc.json @@ -0,0 +1,10 @@ +{ + "entryPoints": ["./src/index.ts"], + "out": "build/docs", + "exclude": ["**/*.spec.ts"], + "excludeInternal": true, + "validation": { + "invalidLink": true, + "notExported": true + } +} From 80d16346e0dbcf5262ab99f6a860965fa1397fae Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Mon, 31 Oct 2022 14:49:39 +1100 Subject: [PATCH 02/23] fixup! chore: new @waku/create package --- package-lock.json | 5 +++++ packages/create/package.json | 3 +++ packages/create/src/index.ts | 27 +++++++++++++++++---------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd89346aa9..4e7ba9968b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22470,8 +22470,12 @@ } }, "packages/create": { + "name": "@waku/create", "version": "0.0.1", "license": "MIT OR Apache-2.0", + "dependencies": { + "@waku/core": "*" + }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", @@ -26835,6 +26839,7 @@ "@semantic-release/release-notes-generator": "^10.0.3", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", + "@waku/core": "*", "cspell": "^5.14.0", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", diff --git a/packages/create/package.json b/packages/create/package.json index c103f00ea2..28bab12f57 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -62,6 +62,9 @@ "engines": { "node": ">=16" }, + "dependencies": { + "@waku/core": "*" + }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", diff --git a/packages/create/src/index.ts b/packages/create/src/index.ts index f0c1d2c8ee..e4fb27b5c5 100644 --- a/packages/create/src/index.ts +++ b/packages/create/src/index.ts @@ -3,17 +3,24 @@ import type { PeerDiscovery } from "@libp2p/interface-peer-discovery"; import { Mplex } from "@libp2p/mplex"; import { WebSockets } from "@libp2p/websockets"; import { all as filterAll } from "@libp2p/websockets/filters"; -import { createLibp2p, Libp2pOptions } from "libp2p"; +import type { + Waku, + WakuFull, + WakuLight, + WakuPrivacy, +} from "@waku/core/lib/interfaces"; +import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list"; +import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap_nodes"; +import { WakuNode, WakuOptions } from "@waku/core/lib/waku.js"; +import { WakuFilter } from "@waku/core/lib/waku_filter"; +import { WakuLightPush } from "@waku/core/lib/waku_light_push"; +import { + CreateOptions as RelayCreateOptions, + WakuRelay, +} from "@waku/core/lib/waku_relay"; +import { WakuStore } from "@waku/core/lib/waku_store"; import type { Libp2p } from "libp2p"; - -import type { Waku, WakuFull, WakuLight, WakuPrivacy } from "./interfaces"; -import { PeerDiscoveryStaticPeers } from "./peer_discovery_static_list"; -import { getPredefinedBootstrapNodes } from "./predefined_bootstrap_nodes"; -import { WakuNode, WakuOptions } from "./waku"; -import { WakuFilter } from "./waku_filter"; -import { WakuLightPush } from "./waku_light_push"; -import { CreateOptions as RelayCreateOptions, WakuRelay } from "./waku_relay"; -import { WakuStore } from "./waku_store"; +import { createLibp2p, Libp2pOptions } from "libp2p"; export interface CreateOptions { /** From 8a84cd07b318e04f4160a54d599fa96a99c1b774 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Mon, 31 Oct 2022 14:56:29 +1100 Subject: [PATCH 03/23] fixup! chore: new @waku/create package --- packages/create/src/index.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/create/src/index.ts b/packages/create/src/index.ts index e4fb27b5c5..49734a9b3d 100644 --- a/packages/create/src/index.ts +++ b/packages/create/src/index.ts @@ -3,6 +3,15 @@ import type { PeerDiscovery } from "@libp2p/interface-peer-discovery"; import { Mplex } from "@libp2p/mplex"; import { WebSockets } from "@libp2p/websockets"; import { all as filterAll } from "@libp2p/websockets/filters"; +import { + waku, + waku_relay, + WakuFilter, + WakuLightPush, + WakuNode, + WakuRelay, + WakuStore, +} from "@waku/core"; import type { Waku, WakuFull, @@ -11,17 +20,12 @@ import type { } from "@waku/core/lib/interfaces"; import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list"; import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap_nodes"; -import { WakuNode, WakuOptions } from "@waku/core/lib/waku.js"; -import { WakuFilter } from "@waku/core/lib/waku_filter"; -import { WakuLightPush } from "@waku/core/lib/waku_light_push"; -import { - CreateOptions as RelayCreateOptions, - WakuRelay, -} from "@waku/core/lib/waku_relay"; -import { WakuStore } from "@waku/core/lib/waku_store"; import type { Libp2p } from "libp2p"; import { createLibp2p, Libp2pOptions } from "libp2p"; +type WakuOptions = waku.WakuOptions; +type RelayCreateOptions = waku_relay.CreateOptions; + export interface CreateOptions { /** * The PubSub Topic to use. From 16eaa911a9b794bbfbdc868146b8780151ce90fc Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 14:48:52 +1100 Subject: [PATCH 04/23] chore: new @waku/interfaces package --- package-lock.json | 65 +++++++ packages/core/package.json | 2 + packages/core/src/lib/enr/enr.node.spec.ts | 10 +- .../src/lib/wait_for_remote_peer.node.spec.ts | 2 +- packages/core/src/lib/waku.node.spec.ts | 2 +- packages/core/src/lib/waku.spec.ts | 2 +- packages/create/package.json | 1 + packages/create/src/index.ts | 36 +--- packages/interfaces/.eslintrc.cjs | 6 + packages/interfaces/.prettierignore | 4 + packages/interfaces/package.json | 170 ++++++++++++++++++ .../src/index.d.ts} | 0 packages/interfaces/tsconfig.dev.json | 8 + packages/interfaces/tsconfig.json | 54 ++++++ packages/interfaces/typedoc.json | 10 ++ 15 files changed, 329 insertions(+), 43 deletions(-) create mode 100644 packages/interfaces/.eslintrc.cjs create mode 100644 packages/interfaces/.prettierignore create mode 100644 packages/interfaces/package.json rename packages/{core/src/lib/interfaces.ts => interfaces/src/index.d.ts} (100%) create mode 100644 packages/interfaces/tsconfig.dev.json create mode 100644 packages/interfaces/tsconfig.json create mode 100644 packages/interfaces/typedoc.json diff --git a/package-lock.json b/package-lock.json index 4e7ba9968b..f84f11e353 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5279,6 +5279,10 @@ "resolved": "packages/create", "link": true }, + "node_modules/@waku/interfaces": { + "resolved": "packages/interfaces", + "link": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", @@ -22391,6 +22395,7 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", + "@waku/create": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", @@ -22488,6 +22493,7 @@ "@semantic-release/release-notes-generator": "^10.0.3", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", + "@waku/interfaces": "*", "cspell": "^5.14.0", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", @@ -22506,6 +22512,37 @@ "engines": { "node": ">=16" } + }, + "packages/interfaces": { + "name": "@waku/interfaces", + "version": "0.0.1", + "license": "MIT OR Apache-2.0", + "devDependencies": { + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^8.0.6", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "semantic-release": "^19.0.5", + "semantic-release-monorepo": "^7.0.5", + "typedoc": "^0.23.10", + "typescript": "^4.6.3" + }, + "engines": { + "node": ">=16" + } } }, "dependencies": { @@ -26745,6 +26782,7 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", + "@waku/create": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", @@ -26840,6 +26878,7 @@ "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", "@waku/core": "*", + "@waku/interfaces": "*", "cspell": "^5.14.0", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", @@ -26856,6 +26895,32 @@ "typescript": "^4.6.3" } }, + "@waku/interfaces": { + "version": "file:packages/interfaces", + "requires": { + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^8.0.6", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "semantic-release": "^19.0.5", + "semantic-release-monorepo": "^7.0.5", + "typedoc": "^0.23.10", + "typescript": "^4.6.3" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", diff --git a/packages/core/package.json b/packages/core/package.json index c7b207f89a..35a156b0a2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -135,6 +135,8 @@ "uuid": "^8.3.2" }, "devDependencies": { + "@waku/create": "*", + "@waku/interfaces": "*", "@libp2p/peer-id-factory": "^1.0.15", "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", diff --git a/packages/core/src/lib/enr/enr.node.spec.ts b/packages/core/src/lib/enr/enr.node.spec.ts index f8daa69747..3753582875 100644 --- a/packages/core/src/lib/enr/enr.node.spec.ts +++ b/packages/core/src/lib/enr/enr.node.spec.ts @@ -1,15 +1,15 @@ +import { createLightNode } from "@waku/create"; import { expect } from "chai"; import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; -import { createWaku } from "../create_waku"; -import type { Waku } from "../interfaces"; +import type { WakuLight } from "../interfaces"; import { waitForRemotePeer } from "../wait_for_remote_peer"; import { Protocols } from "../waku"; import { ENR } from "./enr"; describe("ENR Interop: nwaku", function () { - let waku: Waku; + let waku: WakuLight; let nwaku: Nwaku; afterEach(async function () { @@ -28,7 +28,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createWaku({ + waku = await createLightNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); @@ -60,7 +60,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createWaku({ + waku = await createLightNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); diff --git a/packages/core/src/lib/wait_for_remote_peer.node.spec.ts b/packages/core/src/lib/wait_for_remote_peer.node.spec.ts index 67793a890b..7c22b27d02 100644 --- a/packages/core/src/lib/wait_for_remote_peer.node.spec.ts +++ b/packages/core/src/lib/wait_for_remote_peer.node.spec.ts @@ -1,9 +1,9 @@ +import { createLightNode, createPrivacyNode } from "@waku/create"; import { expect } from "chai"; import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../test_utils"; import { delay } from "../test_utils/delay"; -import { createLightNode, createPrivacyNode } from "./create_waku"; import type { WakuLight, WakuPrivacy } from "./interfaces"; import { waitForRemotePeer } from "./wait_for_remote_peer"; import { Protocols } from "./waku"; diff --git a/packages/core/src/lib/waku.node.spec.ts b/packages/core/src/lib/waku.node.spec.ts index 3418c80281..f1de32548d 100644 --- a/packages/core/src/lib/waku.node.spec.ts +++ b/packages/core/src/lib/waku.node.spec.ts @@ -1,4 +1,5 @@ import type { PeerId } from "@libp2p/interface-peer-id"; +import { createLightNode, createPrivacyNode } from "@waku/create"; import { expect } from "chai"; import { @@ -8,7 +9,6 @@ import { Nwaku, } from "../test_utils/"; -import { createLightNode, createPrivacyNode } from "./create_waku"; import { generateSymmetricKey } from "./crypto"; import type { Message, Waku, WakuLight, WakuPrivacy } from "./interfaces"; import { PeerDiscoveryStaticPeers } from "./peer_discovery_static_list"; diff --git a/packages/core/src/lib/waku.spec.ts b/packages/core/src/lib/waku.spec.ts index efde19c331..cd670ee90d 100644 --- a/packages/core/src/lib/waku.spec.ts +++ b/packages/core/src/lib/waku.spec.ts @@ -1,7 +1,7 @@ import type { PeerId } from "@libp2p/interface-peer-id"; +import { createWaku } from "@waku/create"; import { expect } from "chai"; -import { createWaku } from "./create_waku"; import type { Waku } from "./interfaces"; describe("Waku Dial", function () { diff --git a/packages/create/package.json b/packages/create/package.json index 28bab12f57..b094e5ea30 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -66,6 +66,7 @@ "@waku/core": "*" }, "devDependencies": { + "@waku/interfaces": "*", "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.3.0", diff --git a/packages/create/src/index.ts b/packages/create/src/index.ts index 49734a9b3d..76fb399a89 100644 --- a/packages/create/src/index.ts +++ b/packages/create/src/index.ts @@ -12,14 +12,9 @@ import { WakuRelay, WakuStore, } from "@waku/core"; -import type { - Waku, - WakuFull, - WakuLight, - WakuPrivacy, -} from "@waku/core/lib/interfaces"; import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list"; import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap_nodes"; +import type { WakuFull, WakuLight, WakuPrivacy } from "@waku/interfaces"; import type { Libp2p } from "libp2p"; import { createLibp2p, Libp2pOptions } from "libp2p"; @@ -150,35 +145,6 @@ export async function createFullNode( ) as WakuFull; } -/** - * @deprecated use { @link createLightNode }, { @link createPrivacyNode } or - * { @link index.waku.WakuNode.constructor } instead. - */ -export async function createWaku( - options?: CreateOptions & WakuOptions & Partial -): Promise { - const libp2pOptions = options?.libp2p ?? {}; - const peerDiscovery = libp2pOptions.peerDiscovery ?? []; - if (options?.defaultBootstrap) { - peerDiscovery.push(defaultPeerDiscovery()); - Object.assign(libp2pOptions, { peerDiscovery }); - } - - const libp2p = await defaultLibp2p(new WakuRelay(options), libp2pOptions); - - const wakuStore = new WakuStore(libp2p, options); - const wakuLightPush = new WakuLightPush(libp2p, options); - const wakuFilter = new WakuFilter(libp2p, options); - - return new WakuNode( - options ?? {}, - libp2p, - wakuStore, - wakuLightPush, - wakuFilter - ); -} - export function defaultPeerDiscovery(): PeerDiscovery { return new PeerDiscoveryStaticPeers(getPredefinedBootstrapNodes()); } diff --git a/packages/interfaces/.eslintrc.cjs b/packages/interfaces/.eslintrc.cjs new file mode 100644 index 0000000000..324f1f526d --- /dev/null +++ b/packages/interfaces/.eslintrc.cjs @@ -0,0 +1,6 @@ +module.exports = { + parserOptions: { + tsconfigRootDir: __dirname, + project: "./tsconfig.dev.json", + }, +}; diff --git a/packages/interfaces/.prettierignore b/packages/interfaces/.prettierignore new file mode 100644 index 0000000000..fecb37a393 --- /dev/null +++ b/packages/interfaces/.prettierignore @@ -0,0 +1,4 @@ +build +bundle +dist +node_modules diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json new file mode 100644 index 0000000000..a77296e53b --- /dev/null +++ b/packages/interfaces/package.json @@ -0,0 +1,170 @@ +{ + "name": "@waku/interfaces", + "version": "0.0.1", + "description": "Definition of Waku interfaces", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts" + } + }, + "type": "module", + "author": "Waku Team", + "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/interfaces#readme", + "repository": { + "type": "git", + "url": "https://github.com/waku-org/js-waku.git" + }, + "bugs": { + "url": "https://github.com/waku-org/js-waku/issues" + }, + "license": "MIT OR Apache-2.0", + "keywords": [ + "waku", + "decentralized", + "secure", + "communication", + "web3", + "ethereum", + "dapps", + "privacy" + ], + "scripts": { + "build": "exit 0", + "fix": "run-s fix:*", + "fix:prettier": "prettier . --write", + "fix:lint": "eslint src --ext .ts --ext .cjs --fix", + "check": "run-s check:*", + "check:lint": "eslint src --ext .ts", + "check:prettier": "prettier . --list-different", + "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", + "check:tsc": "tsc -p tsconfig.dev.json", + "test": "exit 0 # Tested in @waku/core", + "proto": "exit 0 # no proto", + "doc": "run-s doc:*", + "doc:html": "typedoc --treatWarningsAsErrors", + "prepublish": "npm run build", + "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", + "release": "semantic-release" + }, + "engines": { + "node": ">=16" + }, + "devDependencies": { + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^8.0.6", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "semantic-release": "^19.0.5", + "semantic-release-monorepo": "^7.0.5", + "typedoc": "^0.23.10", + "typescript": "^4.6.3" + }, + "release": { + "branches": [ + "master" + ], + "extends": "semantic-release-monorepo", + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "doc", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "scope": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "doc", + "section": "Documentation" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, + "files": [ + "dist", + "bundle", + "src/*.ts", + "src/lib/**/*.ts", + "src/proto/**/*.ts", + "!**/*.spec.*", + "!**/*.json", + "CHANGELOG.md", + "LICENSE", + "README.md" + ] +} diff --git a/packages/core/src/lib/interfaces.ts b/packages/interfaces/src/index.d.ts similarity index 100% rename from packages/core/src/lib/interfaces.ts rename to packages/interfaces/src/index.d.ts diff --git a/packages/interfaces/tsconfig.dev.json b/packages/interfaces/tsconfig.dev.json new file mode 100644 index 0000000000..ffc27ef6ba --- /dev/null +++ b/packages/interfaces/tsconfig.dev.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "module": "esnext", + "noEmit": true + }, + "exclude": [] +} diff --git a/packages/interfaces/tsconfig.json b/packages/interfaces/tsconfig.json new file mode 100644 index 0000000000..7b01b30897 --- /dev/null +++ b/packages/interfaces/tsconfig.json @@ -0,0 +1,54 @@ +{ + "compilerOptions": { + "incremental": true, + "target": "es2020", + "outDir": "dist/", + "rootDir": "src", + "moduleResolution": "node", + "module": "es2020", + "declaration": true, + "sourceMap": true, + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "resolveJsonModule": true /* Include modules imported with .json extension. */, + "tsBuildInfoFile": "dist/.tsbuildinfo", + "strict": true /* Enable all strict type-checking options. */, + + /* Strict Type-Checking Options */ + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + "strictNullChecks": true /* Enable strict null checks. */, + "strictFunctionTypes": true /* Enable strict checking of function types. */, + "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, + "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, + "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */, + "noUnusedParameters": true /* Report errors on unused parameters. */, + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "forceConsistentCasingInFileNames": true, + + /* Debugging Options */ + "traceResolution": false /* Report module resolution log messages. */, + "listEmittedFiles": false /* Print names of generated files part of the compilation. */, + "listFiles": false /* Print names of files part of the compilation. */, + "pretty": true /* Stylize errors and messages using color and context. */, + + // Due to broken types in indirect dependencies + "skipLibCheck": true, + + /* Experimental Options */ + // "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, + // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, + + "lib": ["es2020", "dom"], + "types": ["node", "mocha"], + "typeRoots": ["node_modules/@types", "src/types"] + }, + "include": ["src"], + "exclude": ["src/**/*.spec.ts", "src/test_utils"], + "compileOnSave": false, + "ts-node": { + "files": true + } +} diff --git a/packages/interfaces/typedoc.json b/packages/interfaces/typedoc.json new file mode 100644 index 0000000000..1b4aa6af86 --- /dev/null +++ b/packages/interfaces/typedoc.json @@ -0,0 +1,10 @@ +{ + "entryPoints": ["./src/index.ts"], + "out": "build/docs", + "exclude": ["**/*.spec.ts"], + "excludeInternal": true, + "validation": { + "invalidLink": true, + "notExported": true + } +} From 4eddad31661c2b38150fd545e53b3bf5690db876 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 15:16:38 +1100 Subject: [PATCH 05/23] fix: @waku/interfaces --- package-lock.json | 671 ++++++++++++++++++++++++++++- packages/interfaces/package.json | 10 +- packages/interfaces/src/index.d.ts | 93 ---- packages/interfaces/src/index.ts | 181 ++++++++ 4 files changed, 858 insertions(+), 97 deletions(-) delete mode 100644 packages/interfaces/src/index.d.ts create mode 100644 packages/interfaces/src/index.ts diff --git a/package-lock.json b/package-lock.json index f84f11e353..f3644047f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22396,6 +22396,7 @@ "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", "@waku/create": "*", + "@waku/interfaces": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", @@ -22479,7 +22480,8 @@ "version": "0.0.1", "license": "MIT OR Apache-2.0", "dependencies": { - "@waku/core": "*" + "@waku/core": "*", + "@waku/interfaces": "*" }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.0", @@ -22493,7 +22495,6 @@ "@semantic-release/release-notes-generator": "^10.0.3", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", - "@waku/interfaces": "*", "cspell": "^5.14.0", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", @@ -22517,6 +22518,12 @@ "name": "@waku/interfaces", "version": "0.0.1", "license": "MIT OR Apache-2.0", + "dependencies": { + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@multiformats/multiaddr": "^11.0.6", + "libp2p": "^0.40.0" + }, "devDependencies": { "@semantic-release/changelog": "^6.0.1", "@semantic-release/commit-analyzer": "^9.0.2", @@ -22543,6 +22550,376 @@ "engines": { "node": ">=16" } + }, + "packages/interfaces/node_modules/@libp2p/interface-address-manager": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.0.tgz", + "integrity": "sha512-cEzZMxgy71geUcNMZtbF/gNNZbtc8Gx6MI/bj2sPT7ZVqMR7XhSCrpzm3kBkWpSHdWMYImfXCwU0oLg4UtI9Ow==", + "dependencies": { + "@libp2p/interfaces": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@libp2p/interface-connection": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", + "integrity": "sha512-38R2GQ6BCOtwMi5uWU5MLr+xfEpRmVK9gqOp7jNx+6T7TVn8ji4725XLXNfpzprbOrzZkqf2iER84s8+yX4pMA==", + "dependencies": { + "@libp2p/interface-peer-id": "^1.0.0", + "@libp2p/interfaces": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0", + "it-stream-types": "^1.0.4", + "uint8arraylist": "^2.1.1" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@libp2p/interface-connection-encrypter": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-3.0.1.tgz", + "integrity": "sha512-KZ/4vuLokv2fNCnEAM5S91t8v5lMWXdYa26v/iGLqLgiH5MXmIGOgLLGdboXNMYM2ZYYCBgEpSHv+ZRbfO524Q==", + "dependencies": { + "@libp2p/interface-peer-id": "^1.0.0", + "it-stream-types": "^1.0.4", + "uint8arraylist": "^2.1.1" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@libp2p/interface-pubsub": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-pubsub/-/interface-pubsub-3.0.0.tgz", + "integrity": "sha512-3ziZ/mNdCRlfdzSetu38nNbQU6u/rtpQtgI4S4iaSW7MTyivKscWDEPCo5DkF9Uck25hNCbYHhOyKDBoIMdr6Q==", + "dependencies": { + "@libp2p/interface-connection": "^3.0.0", + "@libp2p/interface-peer-id": "^1.0.0", + "@libp2p/interfaces": "^3.0.0", + "it-pushable": "^3.0.0", + "uint8arraylist": "^2.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@libp2p/interface-stream-muxer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-stream-muxer/-/interface-stream-muxer-3.0.0.tgz", + "integrity": "sha512-qv7Z4KJC2SLu/GhwDzT71VBHhtu2fpSL/DGh0iFmkxicQsMmdpiqmXv9EGKw3+jdQL57uKIUm98OpOi2Hge0kg==", + "dependencies": { + "@libp2p/interface-connection": "^3.0.0", + "@libp2p/interfaces": "^3.0.0", + "it-stream-types": "^1.0.4" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@libp2p/interface-transport": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.0.tgz", + "integrity": "sha512-aK33gpkEzfEtoSPlS7z624Tubf49CD2x4DUbXOmQCXDP/rhh3gAQq5XU5dcincM3QXlx6RRSO1PWRqM8EnLE0Q==", + "dependencies": { + "@libp2p/interface-connection": "^3.0.0", + "@libp2p/interface-stream-muxer": "^3.0.0", + "@libp2p/interfaces": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0", + "it-stream-types": "^1.0.4" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@libp2p/peer-store": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-5.0.0.tgz", + "integrity": "sha512-Yz/JykQ9xA0cpv4jIOt9dzYXBAugjoJFPVpA8/LEwU6Y+aUcTIAC3AhOe88QxjYxy4pz+H7C711K2HNCj207jg==", + "dependencies": { + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-peer-info": "^1.0.3", + "@libp2p/interface-peer-store": "^1.2.2", + "@libp2p/interface-record": "^2.0.1", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/logger": "^2.0.0", + "@libp2p/peer-id": "^1.1.15", + "@libp2p/peer-record": "^4.0.3", + "@multiformats/multiaddr": "^11.0.0", + "err-code": "^3.0.1", + "interface-datastore": "^7.0.0", + "it-all": "^1.0.6", + "it-filter": "^1.0.3", + "it-foreach": "^0.1.1", + "it-map": "^1.0.6", + "it-pipe": "^2.0.3", + "mortice": "^3.0.0", + "multiformats": "^10.0.0", + "protons-runtime": "^4.0.1", + "uint8arraylist": "^2.1.1", + "uint8arrays": "^4.0.2" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/@multiformats/multiaddr": { + "version": "11.0.6", + "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", + "integrity": "sha512-5TvEdCc5uFqcwGA+IwSw49swyHtUbwjhjwF3WQcV9vkzTv1C8oEWhoD2QcsiomDRk8rdqqRyDH6wlZExvLnxjw==", + "dependencies": { + "@chainsafe/is-ip": "^1.0.0", + "dns-over-http-resolver": "^2.1.0", + "err-code": "^3.0.1", + "multiformats": "^10.0.0", + "uint8arrays": "^4.0.2", + "varint": "^6.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/it-drain": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-2.0.0.tgz", + "integrity": "sha512-oa/5iyBtRs9UW486vPpyDTC0ee3rqx5qlrPI7txIUJcqqtiO5yVozEB6LQrl5ysQYv+P3y/dlKEqwVqlCV0SEA==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/it-first": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-first/-/it-first-2.0.0.tgz", + "integrity": "sha512-fzZGzVf01exFyIZXNjkpSMFr1eW2+J1K0v018tYY26Dd4f/O3pWlBTdrOBfSQRZwtI8Pst6c7eKhYczWvFs6tA==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/it-merge": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-2.0.0.tgz", + "integrity": "sha512-mH4bo/ZrMoU+Wlu7ZuYPNNh9oWZ/GvYbeXZ0zll97+Rp6H4jFu98iu6v9qqXDz//RUjdO9zGh8awzMfOElsjpA==", + "dependencies": { + "it-pushable": "^3.1.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/it-sort": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-2.0.0.tgz", + "integrity": "sha512-yeAE97b5PEjCrWFUiNyR90eJdGslj8FB3cjT84rsc+mzx9lxPyR2zJkYB9ZOJoWE5MMebxqcQCLRT3OSlzo7Zg==", + "dependencies": { + "it-all": "^2.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/it-sort/node_modules/it-all": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", + "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/libp2p": { + "version": "0.40.0", + "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.40.0.tgz", + "integrity": "sha512-AeLaA+8KIhUhjpXZcs20+Pnf2wIBp+zdSYPD1IgGCF0PlMbTdCvaIqhPzpTSd3+e5k7NZlgpd/BvCOLgQbfm5Q==", + "dependencies": { + "@achingbrain/nat-port-mapper": "^1.0.3", + "@libp2p/connection": "^4.0.2", + "@libp2p/crypto": "^1.0.4", + "@libp2p/interface-address-manager": "^2.0.0", + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-connection-encrypter": "^3.0.1", + "@libp2p/interface-connection-manager": "^1.1.1", + "@libp2p/interface-content-routing": "^1.0.2", + "@libp2p/interface-dht": "^1.0.1", + "@libp2p/interface-metrics": "^3.0.0", + "@libp2p/interface-peer-discovery": "^1.0.1", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-peer-info": "^1.0.3", + "@libp2p/interface-peer-routing": "^1.0.1", + "@libp2p/interface-peer-store": "^1.2.2", + "@libp2p/interface-pubsub": "^3.0.0", + "@libp2p/interface-registrar": "^2.0.3", + "@libp2p/interface-stream-muxer": "^3.0.0", + "@libp2p/interface-transport": "^2.0.0", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/logger": "^2.0.1", + "@libp2p/multistream-select": "^3.0.0", + "@libp2p/peer-collections": "^2.0.0", + "@libp2p/peer-id": "^1.1.15", + "@libp2p/peer-id-factory": "^1.0.18", + "@libp2p/peer-record": "^4.0.3", + "@libp2p/peer-store": "^5.0.0", + "@libp2p/tracked-map": "^2.0.1", + "@libp2p/utils": "^3.0.2", + "@multiformats/mafmt": "^11.0.2", + "@multiformats/multiaddr": "^11.0.0", + "abortable-iterator": "^4.0.2", + "any-signal": "^3.0.0", + "datastore-core": "^8.0.1", + "err-code": "^3.0.1", + "events": "^3.3.0", + "hashlru": "^2.3.0", + "interface-datastore": "^7.0.0", + "it-all": "^2.0.0", + "it-drain": "^2.0.0", + "it-filter": "^2.0.0", + "it-first": "^2.0.0", + "it-foreach": "^1.0.0", + "it-handshake": "^4.1.2", + "it-length-prefixed": "^8.0.2", + "it-map": "^2.0.0", + "it-merge": "^2.0.0", + "it-pair": "^2.0.2", + "it-pipe": "^2.0.3", + "it-sort": "^2.0.0", + "it-stream-types": "^1.0.4", + "merge-options": "^3.0.4", + "multiformats": "^10.0.0", + "mutable-proxy": "^1.0.0", + "node-forge": "^1.3.1", + "p-fifo": "^1.0.0", + "p-retry": "^5.0.0", + "p-settle": "^5.0.0", + "private-ip": "^2.3.3", + "protons-runtime": "^4.0.1", + "rate-limiter-flexible": "^2.3.11", + "retimer": "^3.0.0", + "sanitize-filename": "^1.6.3", + "set-delayed-interval": "^1.0.0", + "timeout-abort-controller": "^3.0.0", + "uint8arraylist": "^2.3.2", + "uint8arrays": "^4.0.2", + "wherearewe": "^2.0.0", + "xsalsa20": "^1.1.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/libp2p/node_modules/it-all": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", + "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/libp2p/node_modules/it-filter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-2.0.0.tgz", + "integrity": "sha512-E68+zzoNNI7MxdH1T4lUTgwpCyEnymlH349Qg2mcvsqLmYRkaZLM4NfZZ0hUuH7/5DkWXubQSDOYH396va8mpg==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/libp2p/node_modules/it-foreach": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-1.0.0.tgz", + "integrity": "sha512-2j5HK1P6aMwEvgL6K5nzUwOk+81B/mjt05PxiSspFEKwJnqy1LfJYlLLS6llBoM+NdoUxf6EsBCHidFGmsXvhw==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/libp2p/node_modules/it-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-map/-/it-map-2.0.0.tgz", + "integrity": "sha512-mLgtk/NZaN7NZ06iLrMXCA6jjhtZO0vZT5Ocsp31H+nsGI18RSPVmUbFyA1sWx7q+g92J22Sixya7T2QSSAwfA==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/long": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", + "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==" + }, + "packages/interfaces/node_modules/multiformats": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", + "integrity": "sha512-nJEHLFOYhO4L+aNApHhCnWqa31FyqAHv9Q77AhmwU3KsM2f1j7tuJpCk5ByZ33smzycNCpSG5klNIejIyfFx2A==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "packages/interfaces/node_modules/protobufjs": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", + "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", + "hasInstallScript": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/interfaces/node_modules/protons-runtime": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-4.0.1.tgz", + "integrity": "sha512-SPeV+8TzJAp5UJYPV7vJkLRi08CP0DksxpKK60rcNaZSPkMBQwc0jQrmkHqwc5P0cYbZzKsdYrUBwRrDLrzTfQ==", + "dependencies": { + "protobufjs": "^7.0.0", + "uint8arraylist": "^2.3.2" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "peerDependencies": { + "uint8arraylist": "^2.3.2" + } + }, + "packages/interfaces/node_modules/uint8arrays": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", + "integrity": "sha512-8CWXXZdOvVrIL4SeY/Gnp+idxxiGK4XFkP4FY26Sx/fpTz/b6vv4BVWELMDzQweSyyhdcuAcU14H6izzB6k1Cw==", + "dependencies": { + "multiformats": "^10.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } } }, "dependencies": { @@ -26783,6 +27160,7 @@ "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", "@waku/create": "*", + "@waku/interfaces": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", @@ -26898,6 +27276,9 @@ "@waku/interfaces": { "version": "file:packages/interfaces", "requires": { + "@libp2p/interface-connection": "*", + "@libp2p/interface-peer-id": "*", + "@multiformats/multiaddr": "*", "@semantic-release/changelog": "^6.0.1", "@semantic-release/commit-analyzer": "^9.0.2", "@semantic-release/git": "^10.0.1", @@ -26913,12 +27294,298 @@ "eslint-plugin-functional": "^4.0.2", "eslint-plugin-import": "^2.25.3", "eslint-plugin-prettier": "^4.0.0", + "libp2p": "*", "npm-run-all": "^4.1.5", "prettier": "^2.1.1", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", "typedoc": "^0.23.10", "typescript": "^4.6.3" + }, + "dependencies": { + "@libp2p/interface-address-manager": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.0.tgz", + "integrity": "sha512-cEzZMxgy71geUcNMZtbF/gNNZbtc8Gx6MI/bj2sPT7ZVqMR7XhSCrpzm3kBkWpSHdWMYImfXCwU0oLg4UtI9Ow==", + "requires": { + "@libp2p/interfaces": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0" + } + }, + "@libp2p/interface-connection": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", + "integrity": "sha512-38R2GQ6BCOtwMi5uWU5MLr+xfEpRmVK9gqOp7jNx+6T7TVn8ji4725XLXNfpzprbOrzZkqf2iER84s8+yX4pMA==", + "requires": { + "@libp2p/interface-peer-id": "^1.0.0", + "@libp2p/interfaces": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0", + "it-stream-types": "^1.0.4", + "uint8arraylist": "^2.1.1" + } + }, + "@libp2p/interface-connection-encrypter": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-3.0.1.tgz", + "integrity": "sha512-KZ/4vuLokv2fNCnEAM5S91t8v5lMWXdYa26v/iGLqLgiH5MXmIGOgLLGdboXNMYM2ZYYCBgEpSHv+ZRbfO524Q==", + "requires": { + "@libp2p/interface-peer-id": "^1.0.0", + "it-stream-types": "^1.0.4", + "uint8arraylist": "^2.1.1" + } + }, + "@libp2p/interface-pubsub": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-pubsub/-/interface-pubsub-3.0.0.tgz", + "integrity": "sha512-3ziZ/mNdCRlfdzSetu38nNbQU6u/rtpQtgI4S4iaSW7MTyivKscWDEPCo5DkF9Uck25hNCbYHhOyKDBoIMdr6Q==", + "requires": { + "@libp2p/interface-connection": "^3.0.0", + "@libp2p/interface-peer-id": "^1.0.0", + "@libp2p/interfaces": "^3.0.0", + "it-pushable": "^3.0.0", + "uint8arraylist": "^2.0.0" + } + }, + "@libp2p/interface-stream-muxer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-stream-muxer/-/interface-stream-muxer-3.0.0.tgz", + "integrity": "sha512-qv7Z4KJC2SLu/GhwDzT71VBHhtu2fpSL/DGh0iFmkxicQsMmdpiqmXv9EGKw3+jdQL57uKIUm98OpOi2Hge0kg==", + "requires": { + "@libp2p/interface-connection": "^3.0.0", + "@libp2p/interfaces": "^3.0.0", + "it-stream-types": "^1.0.4" + } + }, + "@libp2p/interface-transport": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.0.tgz", + "integrity": "sha512-aK33gpkEzfEtoSPlS7z624Tubf49CD2x4DUbXOmQCXDP/rhh3gAQq5XU5dcincM3QXlx6RRSO1PWRqM8EnLE0Q==", + "requires": { + "@libp2p/interface-connection": "^3.0.0", + "@libp2p/interface-stream-muxer": "^3.0.0", + "@libp2p/interfaces": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0", + "it-stream-types": "^1.0.4" + } + }, + "@libp2p/peer-store": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-5.0.0.tgz", + "integrity": "sha512-Yz/JykQ9xA0cpv4jIOt9dzYXBAugjoJFPVpA8/LEwU6Y+aUcTIAC3AhOe88QxjYxy4pz+H7C711K2HNCj207jg==", + "requires": { + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-peer-info": "^1.0.3", + "@libp2p/interface-peer-store": "^1.2.2", + "@libp2p/interface-record": "^2.0.1", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/logger": "^2.0.0", + "@libp2p/peer-id": "^1.1.15", + "@libp2p/peer-record": "^4.0.3", + "@multiformats/multiaddr": "^11.0.0", + "err-code": "^3.0.1", + "interface-datastore": "^7.0.0", + "it-all": "^1.0.6", + "it-filter": "^1.0.3", + "it-foreach": "^0.1.1", + "it-map": "^1.0.6", + "it-pipe": "^2.0.3", + "mortice": "^3.0.0", + "multiformats": "^10.0.0", + "protons-runtime": "^4.0.1", + "uint8arraylist": "^2.1.1", + "uint8arrays": "^4.0.2" + } + }, + "@multiformats/multiaddr": { + "version": "11.0.6", + "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", + "integrity": "sha512-5TvEdCc5uFqcwGA+IwSw49swyHtUbwjhjwF3WQcV9vkzTv1C8oEWhoD2QcsiomDRk8rdqqRyDH6wlZExvLnxjw==", + "requires": { + "@chainsafe/is-ip": "^1.0.0", + "dns-over-http-resolver": "^2.1.0", + "err-code": "^3.0.1", + "multiformats": "^10.0.0", + "uint8arrays": "^4.0.2", + "varint": "^6.0.0" + } + }, + "it-drain": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-2.0.0.tgz", + "integrity": "sha512-oa/5iyBtRs9UW486vPpyDTC0ee3rqx5qlrPI7txIUJcqqtiO5yVozEB6LQrl5ysQYv+P3y/dlKEqwVqlCV0SEA==" + }, + "it-first": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-first/-/it-first-2.0.0.tgz", + "integrity": "sha512-fzZGzVf01exFyIZXNjkpSMFr1eW2+J1K0v018tYY26Dd4f/O3pWlBTdrOBfSQRZwtI8Pst6c7eKhYczWvFs6tA==" + }, + "it-merge": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-2.0.0.tgz", + "integrity": "sha512-mH4bo/ZrMoU+Wlu7ZuYPNNh9oWZ/GvYbeXZ0zll97+Rp6H4jFu98iu6v9qqXDz//RUjdO9zGh8awzMfOElsjpA==", + "requires": { + "it-pushable": "^3.1.0" + } + }, + "it-sort": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-2.0.0.tgz", + "integrity": "sha512-yeAE97b5PEjCrWFUiNyR90eJdGslj8FB3cjT84rsc+mzx9lxPyR2zJkYB9ZOJoWE5MMebxqcQCLRT3OSlzo7Zg==", + "requires": { + "it-all": "^2.0.0" + }, + "dependencies": { + "it-all": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", + "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==" + } + } + }, + "libp2p": { + "version": "0.40.0", + "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.40.0.tgz", + "integrity": "sha512-AeLaA+8KIhUhjpXZcs20+Pnf2wIBp+zdSYPD1IgGCF0PlMbTdCvaIqhPzpTSd3+e5k7NZlgpd/BvCOLgQbfm5Q==", + "requires": { + "@achingbrain/nat-port-mapper": "^1.0.3", + "@libp2p/connection": "^4.0.2", + "@libp2p/crypto": "^1.0.4", + "@libp2p/interface-address-manager": "^2.0.0", + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-connection-encrypter": "^3.0.1", + "@libp2p/interface-connection-manager": "^1.1.1", + "@libp2p/interface-content-routing": "^1.0.2", + "@libp2p/interface-dht": "^1.0.1", + "@libp2p/interface-metrics": "^3.0.0", + "@libp2p/interface-peer-discovery": "^1.0.1", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-peer-info": "^1.0.3", + "@libp2p/interface-peer-routing": "^1.0.1", + "@libp2p/interface-peer-store": "^1.2.2", + "@libp2p/interface-pubsub": "^3.0.0", + "@libp2p/interface-registrar": "^2.0.3", + "@libp2p/interface-stream-muxer": "^3.0.0", + "@libp2p/interface-transport": "^2.0.0", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/logger": "^2.0.1", + "@libp2p/multistream-select": "^3.0.0", + "@libp2p/peer-collections": "^2.0.0", + "@libp2p/peer-id": "^1.1.15", + "@libp2p/peer-id-factory": "^1.0.18", + "@libp2p/peer-record": "^4.0.3", + "@libp2p/peer-store": "^5.0.0", + "@libp2p/tracked-map": "^2.0.1", + "@libp2p/utils": "^3.0.2", + "@multiformats/mafmt": "^11.0.2", + "@multiformats/multiaddr": "^11.0.0", + "abortable-iterator": "^4.0.2", + "any-signal": "^3.0.0", + "datastore-core": "^8.0.1", + "err-code": "^3.0.1", + "events": "^3.3.0", + "hashlru": "^2.3.0", + "interface-datastore": "^7.0.0", + "it-all": "^2.0.0", + "it-drain": "^2.0.0", + "it-filter": "^2.0.0", + "it-first": "^2.0.0", + "it-foreach": "^1.0.0", + "it-handshake": "^4.1.2", + "it-length-prefixed": "^8.0.2", + "it-map": "^2.0.0", + "it-merge": "^2.0.0", + "it-pair": "^2.0.2", + "it-pipe": "^2.0.3", + "it-sort": "^2.0.0", + "it-stream-types": "^1.0.4", + "merge-options": "^3.0.4", + "multiformats": "^10.0.0", + "mutable-proxy": "^1.0.0", + "node-forge": "^1.3.1", + "p-fifo": "^1.0.0", + "p-retry": "^5.0.0", + "p-settle": "^5.0.0", + "private-ip": "^2.3.3", + "protons-runtime": "^4.0.1", + "rate-limiter-flexible": "^2.3.11", + "retimer": "^3.0.0", + "sanitize-filename": "^1.6.3", + "set-delayed-interval": "^1.0.0", + "timeout-abort-controller": "^3.0.0", + "uint8arraylist": "^2.3.2", + "uint8arrays": "^4.0.2", + "wherearewe": "^2.0.0", + "xsalsa20": "^1.1.0" + }, + "dependencies": { + "it-all": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", + "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==" + }, + "it-filter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-2.0.0.tgz", + "integrity": "sha512-E68+zzoNNI7MxdH1T4lUTgwpCyEnymlH349Qg2mcvsqLmYRkaZLM4NfZZ0hUuH7/5DkWXubQSDOYH396va8mpg==" + }, + "it-foreach": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-1.0.0.tgz", + "integrity": "sha512-2j5HK1P6aMwEvgL6K5nzUwOk+81B/mjt05PxiSspFEKwJnqy1LfJYlLLS6llBoM+NdoUxf6EsBCHidFGmsXvhw==" + }, + "it-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-map/-/it-map-2.0.0.tgz", + "integrity": "sha512-mLgtk/NZaN7NZ06iLrMXCA6jjhtZO0vZT5Ocsp31H+nsGI18RSPVmUbFyA1sWx7q+g92J22Sixya7T2QSSAwfA==" + } + } + }, + "long": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", + "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==" + }, + "multiformats": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", + "integrity": "sha512-nJEHLFOYhO4L+aNApHhCnWqa31FyqAHv9Q77AhmwU3KsM2f1j7tuJpCk5ByZ33smzycNCpSG5klNIejIyfFx2A==" + }, + "protobufjs": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", + "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", + "requires": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + } + }, + "protons-runtime": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-4.0.1.tgz", + "integrity": "sha512-SPeV+8TzJAp5UJYPV7vJkLRi08CP0DksxpKK60rcNaZSPkMBQwc0jQrmkHqwc5P0cYbZzKsdYrUBwRrDLrzTfQ==", + "requires": { + "protobufjs": "^7.0.0", + "uint8arraylist": "^2.3.2" + } + }, + "uint8arrays": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", + "integrity": "sha512-8CWXXZdOvVrIL4SeY/Gnp+idxxiGK4XFkP4FY26Sx/fpTz/b6vv4BVWELMDzQweSyyhdcuAcU14H6izzB6k1Cw==", + "requires": { + "multiformats": "^10.0.0" + } + } } }, "@webassemblyjs/ast": { diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index a77296e53b..2a7b21152d 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -30,7 +30,7 @@ "privacy" ], "scripts": { - "build": "exit 0", + "build": "tsc", "fix": "run-s fix:*", "fix:prettier": "prettier . --write", "fix:lint": "eslint src --ext .ts --ext .cjs --fix", @@ -166,5 +166,11 @@ "CHANGELOG.md", "LICENSE", "README.md" - ] + ], + "dependencies": { + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@multiformats/multiaddr": "^11.0.6", + "libp2p": "^0.40.0" + } } diff --git a/packages/interfaces/src/index.d.ts b/packages/interfaces/src/index.d.ts deleted file mode 100644 index 3d158de236..0000000000 --- a/packages/interfaces/src/index.d.ts +++ /dev/null @@ -1,93 +0,0 @@ -import type { Stream } from "@libp2p/interface-connection"; -import type { PeerId } from "@libp2p/interface-peer-id"; -import type { Multiaddr } from "@multiformats/multiaddr"; -import type { Libp2p } from "libp2p"; - -import type { Protocols } from "./waku"; -import type { WakuFilter } from "./waku_filter"; -import type { WakuLightPush } from "./waku_light_push"; -import type { WakuRelay } from "./waku_relay"; -import type { WakuStore } from "./waku_store"; - -export interface Waku { - libp2p: Libp2p; - relay?: WakuRelay; - store?: WakuStore; - filter?: WakuFilter; - lightPush?: WakuLightPush; - - dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise; - - addPeerToAddressBook( - peerId: PeerId | string, - multiaddrs: Multiaddr[] | string[] - ): void; - - start(): Promise; - - stop(): Promise; - - isStarted(): boolean; -} - -export interface WakuLight extends Waku { - relay: undefined; - store: WakuStore; - filter: WakuFilter; - lightPush: WakuLightPush; -} - -export interface WakuPrivacy extends Waku { - relay: WakuRelay; - store: undefined; - filter: undefined; - lightPush: undefined; -} - -export interface WakuFull extends Waku { - relay: WakuRelay; - store: WakuStore; - filter: WakuFilter; - lightPush: WakuLightPush; -} - -export interface RateLimitProof { - proof: Uint8Array; - merkleRoot: Uint8Array; - epoch: Uint8Array; - shareX: Uint8Array; - shareY: Uint8Array; - nullifier: Uint8Array; - rlnIdentifier: Uint8Array; -} - -export interface ProtoMessage { - payload: Uint8Array | undefined; - contentTopic: string | undefined; - version: number | undefined; - timestamp: bigint | undefined; - rateLimitProof: RateLimitProof | undefined; -} - -export interface Message { - payload: Uint8Array | undefined; - contentTopic: string | undefined; - timestamp: Date | undefined; - rateLimitProof: RateLimitProof | undefined; -} - -export interface Encoder { - contentTopic: string; - toWire: (message: Partial) => Promise; - toProtoObj: (message: Partial) => Promise; -} - -export interface Decoder { - contentTopic: string; - fromWireToProtoObj: (bytes: Uint8Array) => Promise; - fromProtoObj: (proto: ProtoMessage) => Promise; -} - -export interface SendResult { - recipients: PeerId[]; -} diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts new file mode 100644 index 0000000000..cd804aa97f --- /dev/null +++ b/packages/interfaces/src/index.ts @@ -0,0 +1,181 @@ +import type { Stream } from "@libp2p/interface-connection"; +import type { PeerId } from "@libp2p/interface-peer-id"; +import type { Multiaddr } from "@multiformats/multiaddr"; +import type { Libp2p } from "libp2p"; + +export enum Protocols { + Relay = "relay", + Store = "store", + LightPush = "lightpush", + Filter = "filter", +} + +export type ProtocolOptions = { + pubsubTopic?: string; + /** + * Optionally specify an PeerId for the protocol request. If not included, will use a random peer. + */ + peerId?: PeerId; +}; + +export type Callback = (msg: T) => void | Promise; + +export interface Filter { + subscribe: ( + decoders: Decoder[], + callback: Callback, + opts?: ProtocolOptions + ) => Promise<() => Promise>; +} + +export interface LightPush { + push: ( + encoder: Encoder, + message: Partial, + opts?: ProtocolOptions + ) => Promise; +} + +export enum PageDirection { + BACKWARD = "backward", + FORWARD = "forward", +} + +export interface TimeFilter { + startTime: Date; + endTime: Date; +} + +export type StoreQueryOptions = { + /** + * The direction in which pages are retrieved: + * - { @link PageDirection.BACKWARD }: Most recent page first. + * - { @link PageDirection.FORWARD }: Oldest page first. + * + * Note: This does not affect the ordering of messages with the page + * (the oldest message is always first). + * + * @default { @link PageDirection.BACKWARD } + */ + pageDirection?: PageDirection; + /** + * The number of message per page. + * + * @default { @link DefaultPageSize } + */ + pageSize?: number; + /** + * Retrieve messages with a timestamp within the provided values. + */ + timeFilter?: TimeFilter; +} & ProtocolOptions; + +export interface Store { + queryOrderedCallback: ( + decoders: Decoder[], + callback: (message: T) => Promise | boolean | void, + options?: StoreQueryOptions + ) => Promise; + queryCallbackOnPromise: ( + decoders: Decoder[], + callback: ( + message: Promise + ) => Promise | boolean | void, + options?: StoreQueryOptions + ) => Promise; + queryGenerator: ( + decoders: Decoder[], + options?: StoreQueryOptions + ) => AsyncGenerator[]>; +} + +export interface Relay { + send: (encoder: Encoder, message: Partial) => Promise; + addObserver: ( + decoder: Decoder, + callback: Callback + ) => () => void; +} + +export interface Waku { + libp2p: Libp2p; + relay?: Relay; + store?: Store; + filter?: Filter; + lightPush?: LightPush; + + dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise; + + addPeerToAddressBook( + peerId: PeerId | string, + multiaddrs: Multiaddr[] | string[] + ): void; + + start(): Promise; + + stop(): Promise; + + isStarted(): boolean; +} + +export interface WakuLight extends Waku { + relay: undefined; + store: Store; + filter: Filter; + lightPush: LightPush; +} + +export interface WakuPrivacy extends Waku { + relay: Relay; + store: undefined; + filter: undefined; + lightPush: undefined; +} + +export interface WakuFull extends Waku { + relay: Relay; + store: Store; + filter: Filter; + lightPush: LightPush; +} + +export interface RateLimitProof { + proof: Uint8Array; + merkleRoot: Uint8Array; + epoch: Uint8Array; + shareX: Uint8Array; + shareY: Uint8Array; + nullifier: Uint8Array; + rlnIdentifier: Uint8Array; +} + +export interface ProtoMessage { + payload: Uint8Array | undefined; + contentTopic: string | undefined; + version: number | undefined; + timestamp: bigint | undefined; + rateLimitProof: RateLimitProof | undefined; +} + +export interface Message { + payload: Uint8Array | undefined; + contentTopic: string | undefined; + timestamp: Date | undefined; + rateLimitProof: RateLimitProof | undefined; +} + +export interface Encoder { + contentTopic: string; + toWire: (message: Partial) => Promise; + toProtoObj: (message: Partial) => Promise; +} + +export interface Decoder { + contentTopic: string; + fromWireToProtoObj: (bytes: Uint8Array) => Promise; + fromProtoObj: (proto: ProtoMessage) => Promise; +} + +export interface SendResult { + recipients: PeerId[]; +} From 057507f94faf98a7544b422d4bb4dc220b7de6d2 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 16:30:24 +1100 Subject: [PATCH 06/23] fix: @waku/interfaces --- package-lock.json | 575 +----------------- packages/core/package.json | 2 +- packages/core/src/index.ts | 2 +- packages/core/src/lib/to_proto_message.ts | 4 +- packages/core/src/lib/wait_for_remote_peer.ts | 23 +- packages/core/src/lib/waku.ts | 10 +- packages/core/src/lib/waku_filter/index.ts | 33 +- .../core/src/lib/waku_light_push/index.ts | 16 +- .../lib/waku_message/topic_only_message.ts | 2 +- .../core/src/lib/waku_message/version_0.ts | 9 +- .../core/src/lib/waku_message/version_1.ts | 2 +- packages/core/src/lib/waku_relay/index.ts | 13 +- packages/core/src/lib/waku_store/index.ts | 2 +- packages/create/package.json | 2 +- packages/interfaces/package.json | 16 +- packages/interfaces/src/index.ts | 16 +- 16 files changed, 81 insertions(+), 646 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3644047f1..6a4ed2f74e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22519,10 +22519,12 @@ "version": "0.0.1", "license": "MIT OR Apache-2.0", "dependencies": { + "@chainsafe/libp2p-gossipsub": "^4.1.1", "@libp2p/interface-connection": "^3.0.2", "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-peer-store": "^1.2.2", "@multiformats/multiaddr": "^11.0.6", - "libp2p": "^0.40.0" + "libp2p": "0.38.0" }, "devDependencies": { "@semantic-release/changelog": "^6.0.1", @@ -22551,19 +22553,6 @@ "node": ">=16" } }, - "packages/interfaces/node_modules/@libp2p/interface-address-manager": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.0.tgz", - "integrity": "sha512-cEzZMxgy71geUcNMZtbF/gNNZbtc8Gx6MI/bj2sPT7ZVqMR7XhSCrpzm3kBkWpSHdWMYImfXCwU0oLg4UtI9Ow==", - "dependencies": { - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, "packages/interfaces/node_modules/@libp2p/interface-connection": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", @@ -22580,98 +22569,6 @@ "npm": ">=7.0.0" } }, - "packages/interfaces/node_modules/@libp2p/interface-connection-encrypter": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-3.0.1.tgz", - "integrity": "sha512-KZ/4vuLokv2fNCnEAM5S91t8v5lMWXdYa26v/iGLqLgiH5MXmIGOgLLGdboXNMYM2ZYYCBgEpSHv+ZRbfO524Q==", - "dependencies": { - "@libp2p/interface-peer-id": "^1.0.0", - "it-stream-types": "^1.0.4", - "uint8arraylist": "^2.1.1" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/interface-pubsub": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-pubsub/-/interface-pubsub-3.0.0.tgz", - "integrity": "sha512-3ziZ/mNdCRlfdzSetu38nNbQU6u/rtpQtgI4S4iaSW7MTyivKscWDEPCo5DkF9Uck25hNCbYHhOyKDBoIMdr6Q==", - "dependencies": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-peer-id": "^1.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-pushable": "^3.0.0", - "uint8arraylist": "^2.0.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/interface-stream-muxer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-stream-muxer/-/interface-stream-muxer-3.0.0.tgz", - "integrity": "sha512-qv7Z4KJC2SLu/GhwDzT71VBHhtu2fpSL/DGh0iFmkxicQsMmdpiqmXv9EGKw3+jdQL57uKIUm98OpOi2Hge0kg==", - "dependencies": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-stream-types": "^1.0.4" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/interface-transport": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.0.tgz", - "integrity": "sha512-aK33gpkEzfEtoSPlS7z624Tubf49CD2x4DUbXOmQCXDP/rhh3gAQq5XU5dcincM3QXlx6RRSO1PWRqM8EnLE0Q==", - "dependencies": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0", - "it-stream-types": "^1.0.4" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/peer-store": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-5.0.0.tgz", - "integrity": "sha512-Yz/JykQ9xA0cpv4jIOt9dzYXBAugjoJFPVpA8/LEwU6Y+aUcTIAC3AhOe88QxjYxy4pz+H7C711K2HNCj207jg==", - "dependencies": { - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-record": "^2.0.1", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-record": "^4.0.3", - "@multiformats/multiaddr": "^11.0.0", - "err-code": "^3.0.1", - "interface-datastore": "^7.0.0", - "it-all": "^1.0.6", - "it-filter": "^1.0.3", - "it-foreach": "^0.1.1", - "it-map": "^1.0.6", - "it-pipe": "^2.0.3", - "mortice": "^3.0.0", - "multiformats": "^10.0.0", - "protons-runtime": "^4.0.1", - "uint8arraylist": "^2.1.1", - "uint8arrays": "^4.0.2" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, "packages/interfaces/node_modules/@multiformats/multiaddr": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", @@ -22689,178 +22586,6 @@ "npm": ">=7.0.0" } }, - "packages/interfaces/node_modules/it-drain": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-2.0.0.tgz", - "integrity": "sha512-oa/5iyBtRs9UW486vPpyDTC0ee3rqx5qlrPI7txIUJcqqtiO5yVozEB6LQrl5ysQYv+P3y/dlKEqwVqlCV0SEA==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-first": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-first/-/it-first-2.0.0.tgz", - "integrity": "sha512-fzZGzVf01exFyIZXNjkpSMFr1eW2+J1K0v018tYY26Dd4f/O3pWlBTdrOBfSQRZwtI8Pst6c7eKhYczWvFs6tA==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-merge": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-2.0.0.tgz", - "integrity": "sha512-mH4bo/ZrMoU+Wlu7ZuYPNNh9oWZ/GvYbeXZ0zll97+Rp6H4jFu98iu6v9qqXDz//RUjdO9zGh8awzMfOElsjpA==", - "dependencies": { - "it-pushable": "^3.1.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-2.0.0.tgz", - "integrity": "sha512-yeAE97b5PEjCrWFUiNyR90eJdGslj8FB3cjT84rsc+mzx9lxPyR2zJkYB9ZOJoWE5MMebxqcQCLRT3OSlzo7Zg==", - "dependencies": { - "it-all": "^2.0.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-sort/node_modules/it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p": { - "version": "0.40.0", - "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.40.0.tgz", - "integrity": "sha512-AeLaA+8KIhUhjpXZcs20+Pnf2wIBp+zdSYPD1IgGCF0PlMbTdCvaIqhPzpTSd3+e5k7NZlgpd/BvCOLgQbfm5Q==", - "dependencies": { - "@achingbrain/nat-port-mapper": "^1.0.3", - "@libp2p/connection": "^4.0.2", - "@libp2p/crypto": "^1.0.4", - "@libp2p/interface-address-manager": "^2.0.0", - "@libp2p/interface-connection": "^3.0.2", - "@libp2p/interface-connection-encrypter": "^3.0.1", - "@libp2p/interface-connection-manager": "^1.1.1", - "@libp2p/interface-content-routing": "^1.0.2", - "@libp2p/interface-dht": "^1.0.1", - "@libp2p/interface-metrics": "^3.0.0", - "@libp2p/interface-peer-discovery": "^1.0.1", - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-routing": "^1.0.1", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-pubsub": "^3.0.0", - "@libp2p/interface-registrar": "^2.0.3", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interface-transport": "^2.0.0", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.1", - "@libp2p/multistream-select": "^3.0.0", - "@libp2p/peer-collections": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-id-factory": "^1.0.18", - "@libp2p/peer-record": "^4.0.3", - "@libp2p/peer-store": "^5.0.0", - "@libp2p/tracked-map": "^2.0.1", - "@libp2p/utils": "^3.0.2", - "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^11.0.0", - "abortable-iterator": "^4.0.2", - "any-signal": "^3.0.0", - "datastore-core": "^8.0.1", - "err-code": "^3.0.1", - "events": "^3.3.0", - "hashlru": "^2.3.0", - "interface-datastore": "^7.0.0", - "it-all": "^2.0.0", - "it-drain": "^2.0.0", - "it-filter": "^2.0.0", - "it-first": "^2.0.0", - "it-foreach": "^1.0.0", - "it-handshake": "^4.1.2", - "it-length-prefixed": "^8.0.2", - "it-map": "^2.0.0", - "it-merge": "^2.0.0", - "it-pair": "^2.0.2", - "it-pipe": "^2.0.3", - "it-sort": "^2.0.0", - "it-stream-types": "^1.0.4", - "merge-options": "^3.0.4", - "multiformats": "^10.0.0", - "mutable-proxy": "^1.0.0", - "node-forge": "^1.3.1", - "p-fifo": "^1.0.0", - "p-retry": "^5.0.0", - "p-settle": "^5.0.0", - "private-ip": "^2.3.3", - "protons-runtime": "^4.0.1", - "rate-limiter-flexible": "^2.3.11", - "retimer": "^3.0.0", - "sanitize-filename": "^1.6.3", - "set-delayed-interval": "^1.0.0", - "timeout-abort-controller": "^3.0.0", - "uint8arraylist": "^2.3.2", - "uint8arrays": "^4.0.2", - "wherearewe": "^2.0.0", - "xsalsa20": "^1.1.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-filter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-2.0.0.tgz", - "integrity": "sha512-E68+zzoNNI7MxdH1T4lUTgwpCyEnymlH349Qg2mcvsqLmYRkaZLM4NfZZ0hUuH7/5DkWXubQSDOYH396va8mpg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-foreach": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-1.0.0.tgz", - "integrity": "sha512-2j5HK1P6aMwEvgL6K5nzUwOk+81B/mjt05PxiSspFEKwJnqy1LfJYlLLS6llBoM+NdoUxf6EsBCHidFGmsXvhw==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-map/-/it-map-2.0.0.tgz", - "integrity": "sha512-mLgtk/NZaN7NZ06iLrMXCA6jjhtZO0vZT5Ocsp31H+nsGI18RSPVmUbFyA1sWx7q+g92J22Sixya7T2QSSAwfA==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/long": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", - "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==" - }, "packages/interfaces/node_modules/multiformats": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", @@ -22870,45 +22595,6 @@ "npm": ">=7.0.0" } }, - "packages/interfaces/node_modules/protobufjs": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", - "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "packages/interfaces/node_modules/protons-runtime": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-4.0.1.tgz", - "integrity": "sha512-SPeV+8TzJAp5UJYPV7vJkLRi08CP0DksxpKK60rcNaZSPkMBQwc0jQrmkHqwc5P0cYbZzKsdYrUBwRrDLrzTfQ==", - "dependencies": { - "protobufjs": "^7.0.0", - "uint8arraylist": "^2.3.2" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - }, - "peerDependencies": { - "uint8arraylist": "^2.3.2" - } - }, "packages/interfaces/node_modules/uint8arrays": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", @@ -27276,9 +26962,11 @@ "@waku/interfaces": { "version": "file:packages/interfaces", "requires": { - "@libp2p/interface-connection": "*", - "@libp2p/interface-peer-id": "*", - "@multiformats/multiaddr": "*", + "@chainsafe/libp2p-gossipsub": "^4.1.1", + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-peer-store": "^1.2.2", + "@multiformats/multiaddr": "^11.0.6", "@semantic-release/changelog": "^6.0.1", "@semantic-release/commit-analyzer": "^9.0.2", "@semantic-release/git": "^10.0.1", @@ -27294,7 +26982,7 @@ "eslint-plugin-functional": "^4.0.2", "eslint-plugin-import": "^2.25.3", "eslint-plugin-prettier": "^4.0.0", - "libp2p": "*", + "libp2p": "0.38.0", "npm-run-all": "^4.1.5", "prettier": "^2.1.1", "semantic-release": "^19.0.5", @@ -27303,15 +26991,6 @@ "typescript": "^4.6.3" }, "dependencies": { - "@libp2p/interface-address-manager": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.0.tgz", - "integrity": "sha512-cEzZMxgy71geUcNMZtbF/gNNZbtc8Gx6MI/bj2sPT7ZVqMR7XhSCrpzm3kBkWpSHdWMYImfXCwU0oLg4UtI9Ow==", - "requires": { - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0" - } - }, "@libp2p/interface-connection": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", @@ -27324,78 +27003,6 @@ "uint8arraylist": "^2.1.1" } }, - "@libp2p/interface-connection-encrypter": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-3.0.1.tgz", - "integrity": "sha512-KZ/4vuLokv2fNCnEAM5S91t8v5lMWXdYa26v/iGLqLgiH5MXmIGOgLLGdboXNMYM2ZYYCBgEpSHv+ZRbfO524Q==", - "requires": { - "@libp2p/interface-peer-id": "^1.0.0", - "it-stream-types": "^1.0.4", - "uint8arraylist": "^2.1.1" - } - }, - "@libp2p/interface-pubsub": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-pubsub/-/interface-pubsub-3.0.0.tgz", - "integrity": "sha512-3ziZ/mNdCRlfdzSetu38nNbQU6u/rtpQtgI4S4iaSW7MTyivKscWDEPCo5DkF9Uck25hNCbYHhOyKDBoIMdr6Q==", - "requires": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-peer-id": "^1.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-pushable": "^3.0.0", - "uint8arraylist": "^2.0.0" - } - }, - "@libp2p/interface-stream-muxer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-stream-muxer/-/interface-stream-muxer-3.0.0.tgz", - "integrity": "sha512-qv7Z4KJC2SLu/GhwDzT71VBHhtu2fpSL/DGh0iFmkxicQsMmdpiqmXv9EGKw3+jdQL57uKIUm98OpOi2Hge0kg==", - "requires": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-stream-types": "^1.0.4" - } - }, - "@libp2p/interface-transport": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.0.tgz", - "integrity": "sha512-aK33gpkEzfEtoSPlS7z624Tubf49CD2x4DUbXOmQCXDP/rhh3gAQq5XU5dcincM3QXlx6RRSO1PWRqM8EnLE0Q==", - "requires": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0", - "it-stream-types": "^1.0.4" - } - }, - "@libp2p/peer-store": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-5.0.0.tgz", - "integrity": "sha512-Yz/JykQ9xA0cpv4jIOt9dzYXBAugjoJFPVpA8/LEwU6Y+aUcTIAC3AhOe88QxjYxy4pz+H7C711K2HNCj207jg==", - "requires": { - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-record": "^2.0.1", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-record": "^4.0.3", - "@multiformats/multiaddr": "^11.0.0", - "err-code": "^3.0.1", - "interface-datastore": "^7.0.0", - "it-all": "^1.0.6", - "it-filter": "^1.0.3", - "it-foreach": "^0.1.1", - "it-map": "^1.0.6", - "it-pipe": "^2.0.3", - "mortice": "^3.0.0", - "multiformats": "^10.0.0", - "protons-runtime": "^4.0.1", - "uint8arraylist": "^2.1.1", - "uint8arrays": "^4.0.2" - } - }, "@multiformats/multiaddr": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", @@ -27409,175 +27016,11 @@ "varint": "^6.0.0" } }, - "it-drain": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-2.0.0.tgz", - "integrity": "sha512-oa/5iyBtRs9UW486vPpyDTC0ee3rqx5qlrPI7txIUJcqqtiO5yVozEB6LQrl5ysQYv+P3y/dlKEqwVqlCV0SEA==" - }, - "it-first": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-first/-/it-first-2.0.0.tgz", - "integrity": "sha512-fzZGzVf01exFyIZXNjkpSMFr1eW2+J1K0v018tYY26Dd4f/O3pWlBTdrOBfSQRZwtI8Pst6c7eKhYczWvFs6tA==" - }, - "it-merge": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-2.0.0.tgz", - "integrity": "sha512-mH4bo/ZrMoU+Wlu7ZuYPNNh9oWZ/GvYbeXZ0zll97+Rp6H4jFu98iu6v9qqXDz//RUjdO9zGh8awzMfOElsjpA==", - "requires": { - "it-pushable": "^3.1.0" - } - }, - "it-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-2.0.0.tgz", - "integrity": "sha512-yeAE97b5PEjCrWFUiNyR90eJdGslj8FB3cjT84rsc+mzx9lxPyR2zJkYB9ZOJoWE5MMebxqcQCLRT3OSlzo7Zg==", - "requires": { - "it-all": "^2.0.0" - }, - "dependencies": { - "it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==" - } - } - }, - "libp2p": { - "version": "0.40.0", - "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.40.0.tgz", - "integrity": "sha512-AeLaA+8KIhUhjpXZcs20+Pnf2wIBp+zdSYPD1IgGCF0PlMbTdCvaIqhPzpTSd3+e5k7NZlgpd/BvCOLgQbfm5Q==", - "requires": { - "@achingbrain/nat-port-mapper": "^1.0.3", - "@libp2p/connection": "^4.0.2", - "@libp2p/crypto": "^1.0.4", - "@libp2p/interface-address-manager": "^2.0.0", - "@libp2p/interface-connection": "^3.0.2", - "@libp2p/interface-connection-encrypter": "^3.0.1", - "@libp2p/interface-connection-manager": "^1.1.1", - "@libp2p/interface-content-routing": "^1.0.2", - "@libp2p/interface-dht": "^1.0.1", - "@libp2p/interface-metrics": "^3.0.0", - "@libp2p/interface-peer-discovery": "^1.0.1", - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-routing": "^1.0.1", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-pubsub": "^3.0.0", - "@libp2p/interface-registrar": "^2.0.3", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interface-transport": "^2.0.0", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.1", - "@libp2p/multistream-select": "^3.0.0", - "@libp2p/peer-collections": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-id-factory": "^1.0.18", - "@libp2p/peer-record": "^4.0.3", - "@libp2p/peer-store": "^5.0.0", - "@libp2p/tracked-map": "^2.0.1", - "@libp2p/utils": "^3.0.2", - "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^11.0.0", - "abortable-iterator": "^4.0.2", - "any-signal": "^3.0.0", - "datastore-core": "^8.0.1", - "err-code": "^3.0.1", - "events": "^3.3.0", - "hashlru": "^2.3.0", - "interface-datastore": "^7.0.0", - "it-all": "^2.0.0", - "it-drain": "^2.0.0", - "it-filter": "^2.0.0", - "it-first": "^2.0.0", - "it-foreach": "^1.0.0", - "it-handshake": "^4.1.2", - "it-length-prefixed": "^8.0.2", - "it-map": "^2.0.0", - "it-merge": "^2.0.0", - "it-pair": "^2.0.2", - "it-pipe": "^2.0.3", - "it-sort": "^2.0.0", - "it-stream-types": "^1.0.4", - "merge-options": "^3.0.4", - "multiformats": "^10.0.0", - "mutable-proxy": "^1.0.0", - "node-forge": "^1.3.1", - "p-fifo": "^1.0.0", - "p-retry": "^5.0.0", - "p-settle": "^5.0.0", - "private-ip": "^2.3.3", - "protons-runtime": "^4.0.1", - "rate-limiter-flexible": "^2.3.11", - "retimer": "^3.0.0", - "sanitize-filename": "^1.6.3", - "set-delayed-interval": "^1.0.0", - "timeout-abort-controller": "^3.0.0", - "uint8arraylist": "^2.3.2", - "uint8arrays": "^4.0.2", - "wherearewe": "^2.0.0", - "xsalsa20": "^1.1.0" - }, - "dependencies": { - "it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==" - }, - "it-filter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-2.0.0.tgz", - "integrity": "sha512-E68+zzoNNI7MxdH1T4lUTgwpCyEnymlH349Qg2mcvsqLmYRkaZLM4NfZZ0hUuH7/5DkWXubQSDOYH396va8mpg==" - }, - "it-foreach": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-1.0.0.tgz", - "integrity": "sha512-2j5HK1P6aMwEvgL6K5nzUwOk+81B/mjt05PxiSspFEKwJnqy1LfJYlLLS6llBoM+NdoUxf6EsBCHidFGmsXvhw==" - }, - "it-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-map/-/it-map-2.0.0.tgz", - "integrity": "sha512-mLgtk/NZaN7NZ06iLrMXCA6jjhtZO0vZT5Ocsp31H+nsGI18RSPVmUbFyA1sWx7q+g92J22Sixya7T2QSSAwfA==" - } - } - }, - "long": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", - "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==" - }, "multiformats": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", "integrity": "sha512-nJEHLFOYhO4L+aNApHhCnWqa31FyqAHv9Q77AhmwU3KsM2f1j7tuJpCk5ByZ33smzycNCpSG5klNIejIyfFx2A==" }, - "protobufjs": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", - "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", - "requires": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - } - }, - "protons-runtime": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-4.0.1.tgz", - "integrity": "sha512-SPeV+8TzJAp5UJYPV7vJkLRi08CP0DksxpKK60rcNaZSPkMBQwc0jQrmkHqwc5P0cYbZzKsdYrUBwRrDLrzTfQ==", - "requires": { - "protobufjs": "^7.0.0", - "uint8arraylist": "^2.3.2" - } - }, "uint8arrays": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", diff --git a/packages/core/package.json b/packages/core/package.json index 35a156b0a2..6330c6e139 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -79,10 +79,10 @@ "nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)", "nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build", "check": "run-s check:*", + "check:tsc": "tsc -p tsconfig.dev.json", "check:lint": "eslint src --ext .ts", "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", - "check:tsc": "tsc -p tsconfig.dev.json", "test": "run-s test:*", "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:browser": "karma start karma.conf.cjs", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index f78145d5a3..cef0c3a427 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -14,7 +14,7 @@ export * as proto_message from "./proto/message"; export * as proto_topic_only_message from "./proto/topic_only_message"; export * as waku from "./lib/waku"; -export { WakuNode, Protocols } from "./lib/waku"; +export { WakuNode } from "./lib/waku"; export * as waku_filter from "./lib/waku_filter"; export { WakuFilter } from "./lib/waku_filter"; diff --git a/packages/core/src/lib/to_proto_message.ts b/packages/core/src/lib/to_proto_message.ts index edb8a7695d..a2a60fd0c4 100644 --- a/packages/core/src/lib/to_proto_message.ts +++ b/packages/core/src/lib/to_proto_message.ts @@ -1,6 +1,6 @@ -import { WakuMessage as WakuMessageProto } from "../proto/message"; +import { ProtoMessage } from "@waku/interfaces"; -import { ProtoMessage } from "./interfaces"; +import { WakuMessage as WakuMessageProto } from "../proto/message"; const EmptyMessage: ProtoMessage = { payload: undefined, diff --git a/packages/core/src/lib/wait_for_remote_peer.ts b/packages/core/src/lib/wait_for_remote_peer.ts index dd58bc13d3..caa254239a 100644 --- a/packages/core/src/lib/wait_for_remote_peer.ts +++ b/packages/core/src/lib/wait_for_remote_peer.ts @@ -1,26 +1,15 @@ -import type { GossipSub } from "@chainsafe/libp2p-gossipsub"; -import { Peer, PeerProtocolsChangeData } from "@libp2p/interface-peer-store"; +import { PeerProtocolsChangeData } from "@libp2p/interface-peer-store"; +import type { PointToPointProtocol, Relay, Waku } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import debug from "debug"; -import type { Libp2p } from "libp2p"; import { pEvent } from "p-event"; -import type { Waku } from "./interfaces"; -import { Protocols } from "./waku"; import { FilterCodec } from "./waku_filter"; import { LightPushCodec } from "./waku_light_push"; import { StoreCodec } from "./waku_store"; const log = debug("waku:wait-for-remote-peer"); -interface WakuProtocol { - libp2p: Libp2p; - peers: () => Promise; -} - -interface WakuGossipSubProtocol extends GossipSub { - getMeshPeers: () => string[]; -} - /** * Wait for a remote peer to be ready given the passed protocols. * Must be used after attempting to connect to nodes, using @@ -90,7 +79,7 @@ export async function waitForRemotePeer( * Wait for a peer with the given protocol to be connected. */ async function waitForConnectedPeer( - waku: WakuProtocol, + waku: PointToPointProtocol, codecs: string[] ): Promise { const peers = await waku.peers(); @@ -119,9 +108,7 @@ async function waitForConnectedPeer( * Wait for a peer with the given protocol to be connected and in the gossipsub * mesh. */ -async function waitForGossipSubPeerInMesh( - waku: WakuGossipSubProtocol -): Promise { +async function waitForGossipSubPeerInMesh(waku: Relay): Promise { let peers = waku.getMeshPeers(); while (peers.length == 0) { diff --git a/packages/core/src/lib/waku.ts b/packages/core/src/lib/waku.ts index ca8449c02c..f792eb6c56 100644 --- a/packages/core/src/lib/waku.ts +++ b/packages/core/src/lib/waku.ts @@ -4,10 +4,11 @@ import type { PubSub } from "@libp2p/interface-pubsub"; import { peerIdFromString } from "@libp2p/peer-id"; import type { Multiaddr } from "@multiformats/multiaddr"; import { multiaddr } from "@multiformats/multiaddr"; +import type { Waku } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import debug from "debug"; import type { Libp2p } from "libp2p"; -import { Waku } from "./interfaces"; import { FilterCodec, WakuFilter } from "./waku_filter"; import { LightPushCodec, WakuLightPush } from "./waku_light_push"; import { EncoderV0 } from "./waku_message/version_0"; @@ -21,13 +22,6 @@ export const DefaultRelayKeepAliveValueSecs = 5 * 60; const log = debug("waku:waku"); -export enum Protocols { - Relay = "relay", - Store = "store", - LightPush = "lightpush", - Filter = "filter", -} - export interface WakuOptions { /** * Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0` diff --git a/packages/core/src/lib/waku_filter/index.ts b/packages/core/src/lib/waku_filter/index.ts index 65e6b45981..9b526b5d45 100644 --- a/packages/core/src/lib/waku_filter/index.ts +++ b/packages/core/src/lib/waku_filter/index.ts @@ -2,6 +2,13 @@ import type { Stream } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; import type { Peer } from "@libp2p/interface-peer-store"; import type { IncomingStreamData } from "@libp2p/interface-registrar"; +import type { + Callback, + Decoder, + Filter, + Message, + ProtocolOptions, +} from "@waku/interfaces"; import debug from "debug"; import all from "it-all"; import * as lp from "it-length-prefixed"; @@ -11,7 +18,6 @@ import type { Libp2p } from "libp2p"; import { WakuMessage as WakuMessageProto } from "../../proto/message"; import { DefaultPubSubTopic } from "../constants"; import { groupByContentTopic } from "../group_by"; -import { Decoder, Message } from "../interfaces"; import { selectConnection } from "../select_connection"; import { getPeersForProtocol, @@ -39,21 +45,6 @@ export interface CreateOptions { pubSubTopic?: string; } -export type FilterSubscriptionOpts = { - /** - * The Pubsub topic for the subscription - */ - pubsubTopic?: string; - /** - * Optionally specify a PeerId for the subscription. If not included, will use a random peer. - */ - peerId?: PeerId; -}; - -export type FilterCallback = ( - msg: T -) => void | Promise; - export type UnsubscribeFunction = () => Promise; /** @@ -63,9 +54,9 @@ export type UnsubscribeFunction = () => Promise; * - https://github.com/status-im/go-waku/issues/245 * - https://github.com/status-im/nwaku/issues/948 */ -export class WakuFilter { +export class WakuFilter implements Filter { pubSubTopic: string; - private subscriptions: Map>; + private subscriptions: Map>; private decoders: Map< string, // content topic Set> @@ -88,8 +79,8 @@ export class WakuFilter { */ async subscribe( decoders: Decoder[], - callback: FilterCallback, - opts?: FilterSubscriptionOpts + callback: Callback, + opts?: ProtocolOptions ): Promise { const topic = opts?.pubsubTopic ?? this.pubSubTopic; @@ -212,7 +203,7 @@ export class WakuFilter { } } - private addCallback(requestId: string, callback: FilterCallback): void { + private addCallback(requestId: string, callback: Callback): void { this.subscriptions.set(requestId, callback); } diff --git a/packages/core/src/lib/waku_light_push/index.ts b/packages/core/src/lib/waku_light_push/index.ts index 0674213dcd..95ac899349 100644 --- a/packages/core/src/lib/waku_light_push/index.ts +++ b/packages/core/src/lib/waku_light_push/index.ts @@ -1,5 +1,11 @@ import type { PeerId } from "@libp2p/interface-peer-id"; import type { Peer } from "@libp2p/interface-peer-store"; +import type { + Encoder, + Message, + ProtocolOptions, + SendResult, +} from "@waku/interfaces"; import debug from "debug"; import all from "it-all"; import * as lp from "it-length-prefixed"; @@ -9,7 +15,6 @@ import { Uint8ArrayList } from "uint8arraylist"; import { PushResponse } from "../../proto/light_push"; import { DefaultPubSubTopic } from "../constants"; -import { Encoder, Message, SendResult } from "../interfaces"; import { selectConnection } from "../select_connection"; import { getPeersForProtocol, @@ -36,11 +41,6 @@ export interface CreateOptions { pubSubTopic?: string; } -export interface PushOptions { - peerId?: PeerId; - pubSubTopic?: string; -} - /** * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/). */ @@ -54,9 +54,9 @@ export class WakuLightPush { async push( encoder: Encoder, message: Partial, - opts?: PushOptions + opts?: ProtocolOptions ): Promise { - const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic; + const pubSubTopic = opts?.pubsubTopic ? opts.pubsubTopic : this.pubSubTopic; const res = await selectPeerForProtocol( this.libp2p.peerStore, diff --git a/packages/core/src/lib/waku_message/topic_only_message.ts b/packages/core/src/lib/waku_message/topic_only_message.ts index f72bb8bd63..9514847d21 100644 --- a/packages/core/src/lib/waku_message/topic_only_message.ts +++ b/packages/core/src/lib/waku_message/topic_only_message.ts @@ -1,7 +1,7 @@ +import type { Decoder, Message, ProtoMessage } from "@waku/interfaces"; import debug from "debug"; import * as proto from "../../proto/topic_only_message"; -import type { Decoder, Message, ProtoMessage } from "../interfaces"; const log = debug("waku:message:topic-only"); diff --git a/packages/core/src/lib/waku_message/version_0.ts b/packages/core/src/lib/waku_message/version_0.ts index aa83150f8d..4220a20c9c 100644 --- a/packages/core/src/lib/waku_message/version_0.ts +++ b/packages/core/src/lib/waku_message/version_0.ts @@ -1,8 +1,13 @@ +import type { + Decoder, + Encoder, + Message, + ProtoMessage, + RateLimitProof, +} from "@waku/interfaces"; import debug from "debug"; import * as proto from "../../proto/message"; -import { Decoder, Message, ProtoMessage, RateLimitProof } from "../interfaces"; -import { Encoder } from "../interfaces"; const log = debug("waku:message:version-0"); diff --git a/packages/core/src/lib/waku_message/version_1.ts b/packages/core/src/lib/waku_message/version_1.ts index 0a9a6117c6..3b6d46a8e3 100644 --- a/packages/core/src/lib/waku_message/version_1.ts +++ b/packages/core/src/lib/waku_message/version_1.ts @@ -1,9 +1,9 @@ import * as secp from "@noble/secp256k1"; +import type { Decoder, Encoder, Message, ProtoMessage } from "@waku/interfaces"; import debug from "debug"; import * as proto from "../../proto/message"; import { keccak256, randomBytes, sign } from "../crypto"; -import { Decoder, Encoder, Message, ProtoMessage } from "../interfaces"; import { concat, hexToBytes } from "../utils"; import { Symmetric } from "./constants"; diff --git a/packages/core/src/lib/waku_relay/index.ts b/packages/core/src/lib/waku_relay/index.ts index b5cbeb48e6..420bf10cbe 100644 --- a/packages/core/src/lib/waku_relay/index.ts +++ b/packages/core/src/lib/waku_relay/index.ts @@ -8,10 +8,17 @@ import { TopicStr, } from "@chainsafe/libp2p-gossipsub/dist/src/types"; import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types"; +import type { + Callback, + Decoder, + Encoder, + Message, + Relay, + SendResult, +} from "@waku/interfaces"; import debug from "debug"; import { DefaultPubSubTopic } from "../constants"; -import { Decoder, Encoder, Message, SendResult } from "../interfaces"; import { pushOrInitMapSet } from "../push_or_init_map"; import { TopicOnlyDecoder } from "../waku_message/topic_only_message"; @@ -19,8 +26,6 @@ import * as constants from "./constants"; const log = debug("waku:relay"); -export type Callback = (msg: T) => void; - export type Observer = { decoder: Decoder; callback: Callback; @@ -49,7 +54,7 @@ export type CreateOptions = { * * @implements {require('libp2p-interfaces/src/pubsub')} */ -export class WakuRelay extends GossipSub { +export class WakuRelay extends GossipSub implements Relay { pubSubTopic: string; defaultDecoder: Decoder; public static multicodec: string = constants.RelayCodecs[0]; diff --git a/packages/core/src/lib/waku_store/index.ts b/packages/core/src/lib/waku_store/index.ts index 9a7f833b1f..9f02bec8dd 100644 --- a/packages/core/src/lib/waku_store/index.ts +++ b/packages/core/src/lib/waku_store/index.ts @@ -1,6 +1,7 @@ import type { Connection } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; import { Peer } from "@libp2p/interface-peer-store"; +import { Decoder, Message } from "@waku/interfaces"; import debug from "debug"; import all from "it-all"; import * as lp from "it-length-prefixed"; @@ -10,7 +11,6 @@ import { Uint8ArrayList } from "uint8arraylist"; import * as proto from "../../proto/store"; import { DefaultPubSubTopic } from "../constants"; -import { Decoder, Message } from "../interfaces"; import { selectConnection } from "../select_connection"; import { getPeersForProtocol, selectPeerForProtocol } from "../select_peer"; import { toProtoMessage } from "../to_proto_message"; diff --git a/packages/create/package.json b/packages/create/package.json index b094e5ea30..ff58c21b75 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -63,10 +63,10 @@ "node": ">=16" }, "dependencies": { + "@waku/interfaces": "*", "@waku/core": "*" }, "devDependencies": { - "@waku/interfaces": "*", "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.3.0", diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 2a7b21152d..24d6822bf1 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -50,6 +50,14 @@ "engines": { "node": ">=16" }, + "dependencies": { + "@chainsafe/libp2p-gossipsub": "^4.1.1", + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-peer-store": "^1.2.2", + "@multiformats/multiaddr": "^11.0.6", + "libp2p": "0.38.0" + }, "devDependencies": { "@semantic-release/changelog": "^6.0.1", "@semantic-release/commit-analyzer": "^9.0.2", @@ -166,11 +174,5 @@ "CHANGELOG.md", "LICENSE", "README.md" - ], - "dependencies": { - "@libp2p/interface-connection": "^3.0.2", - "@libp2p/interface-peer-id": "^1.0.5", - "@multiformats/multiaddr": "^11.0.6", - "libp2p": "^0.40.0" - } + ] } diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts index cd804aa97f..105230f424 100644 --- a/packages/interfaces/src/index.ts +++ b/packages/interfaces/src/index.ts @@ -1,5 +1,7 @@ +import type { GossipSub } from "@chainsafe/libp2p-gossipsub"; import type { Stream } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; +import type { Peer } from "@libp2p/interface-peer-store"; import type { Multiaddr } from "@multiformats/multiaddr"; import type { Libp2p } from "libp2p"; @@ -10,6 +12,11 @@ export enum Protocols { Filter = "filter", } +export interface PointToPointProtocol { + libp2p: Libp2p; + peers: () => Promise; +} + export type ProtocolOptions = { pubsubTopic?: string; /** @@ -20,7 +27,7 @@ export type ProtocolOptions = { export type Callback = (msg: T) => void | Promise; -export interface Filter { +export interface Filter extends PointToPointProtocol { subscribe: ( decoders: Decoder[], callback: Callback, @@ -28,7 +35,7 @@ export interface Filter { ) => Promise<() => Promise>; } -export interface LightPush { +export interface LightPush extends PointToPointProtocol { push: ( encoder: Encoder, message: Partial, @@ -70,7 +77,7 @@ export type StoreQueryOptions = { timeFilter?: TimeFilter; } & ProtocolOptions; -export interface Store { +export interface Store extends PointToPointProtocol { queryOrderedCallback: ( decoders: Decoder[], callback: (message: T) => Promise | boolean | void, @@ -89,12 +96,13 @@ export interface Store { ) => AsyncGenerator[]>; } -export interface Relay { +export interface Relay extends GossipSub { send: (encoder: Encoder, message: Partial) => Promise; addObserver: ( decoder: Decoder, callback: Callback ) => () => void; + getMeshPeers: () => string[]; } export interface Waku { From a185b5a0ec710faf35ee85437835b864520c9e08 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 16:33:42 +1100 Subject: [PATCH 07/23] fix: @waku/interfaces --- package-lock.json | 2 +- packages/core/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6a4ed2f74e..61feee4182 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22361,6 +22361,7 @@ "@libp2p/websockets": "^3.0.3", "@multiformats/multiaddr": "^11.0.6", "@noble/secp256k1": "^1.3.4", + "@waku/interfaces": "*", "debug": "^4.3.4", "dns-query": "^0.11.2", "hi-base32": "^0.5.1", @@ -22396,7 +22397,6 @@ "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", "@waku/create": "*", - "@waku/interfaces": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", diff --git a/packages/core/package.json b/packages/core/package.json index 6330c6e139..a863bbdfdb 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -104,6 +104,7 @@ "node": ">=16" }, "dependencies": { + "@waku/interfaces": "*", "@chainsafe/libp2p-gossipsub": "^4.1.1", "@chainsafe/libp2p-noise": "^8.0.1", "@ethersproject/rlp": "^5.5.0", @@ -135,8 +136,6 @@ "uuid": "^8.3.2" }, "devDependencies": { - "@waku/create": "*", - "@waku/interfaces": "*", "@libp2p/peer-id-factory": "^1.0.15", "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", @@ -156,6 +155,7 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", + "@waku/create": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", From c409076365869dd25af48ea905bb52e01ced5c8e Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:15:06 +1100 Subject: [PATCH 08/23] fix: @waku/interfaces --- packages/interfaces/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 24d6822bf1..4477717e10 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -3,9 +3,11 @@ "version": "0.0.1", "description": "Definition of Waku interfaces", "types": "./dist/index.d.ts", + "module": "./dist/index.js", "exports": { ".": { - "types": "./dist/index.d.ts" + "types": "./dist/index.d.ts", + "import": "./dist/index.js" } }, "type": "module", From fe818580f25ed877fe2f60710e9464cd5d9847d1 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:20:07 +1100 Subject: [PATCH 09/23] fix: @waku/interfaces --- packages/core/package.json | 3 --- packages/core/typedoc.json | 1 - 2 files changed, 4 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index a863bbdfdb..8e25280216 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,9 +9,6 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js" }, - "./lib/interfaces": { - "types": "./dist/lib/interfaces.d.ts" - }, "./lib/peer_discovery_dns": { "types": "./dist/lib/peer_discovery_dns/index.d.ts", "import": "./dist/lib/peer_discovery_dns/index.js" diff --git a/packages/core/typedoc.json b/packages/core/typedoc.json index 652c71ed24..031b751650 100644 --- a/packages/core/typedoc.json +++ b/packages/core/typedoc.json @@ -1,7 +1,6 @@ { "entryPoints": [ "./src/index.ts", - "./src/lib/interfaces.ts", "./src/lib/peer_discovery_dns.ts", "./src/lib/peer_discovery_static_list.ts", "./src/lib/predefined_bootstrap_nodes.ts", From 9d74c9f6febb0f66c729d6fb63a6a85817dc3aad Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:33:33 +1100 Subject: [PATCH 10/23] fix: core check pass --- packages/core/src/lib/enr/enr.node.spec.ts | 6 +++--- packages/core/src/lib/wait_for_remote_peer.node.spec.ts | 4 ++-- packages/core/src/lib/waku.node.spec.ts | 4 ++-- packages/core/src/lib/waku.spec.ts | 9 ++++----- packages/core/src/lib/waku_filter/index.node.spec.ts | 6 +++--- packages/core/src/lib/waku_filter/index.ts | 2 +- packages/core/src/lib/waku_light_push/index.node.spec.ts | 6 +++--- packages/core/src/lib/waku_light_push/index.ts | 2 +- packages/core/src/lib/waku_relay/index.node.spec.ts | 6 +++--- packages/core/src/lib/waku_store/index.node.spec.ts | 6 +++--- packages/interfaces/src/index.ts | 2 +- 11 files changed, 26 insertions(+), 27 deletions(-) diff --git a/packages/core/src/lib/enr/enr.node.spec.ts b/packages/core/src/lib/enr/enr.node.spec.ts index 3753582875..565a6ed805 100644 --- a/packages/core/src/lib/enr/enr.node.spec.ts +++ b/packages/core/src/lib/enr/enr.node.spec.ts @@ -1,10 +1,10 @@ import { createLightNode } from "@waku/create"; +import type { WakuLight } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; -import type { WakuLight } from "../interfaces"; import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { Protocols } from "../waku"; import { ENR } from "./enr"; @@ -92,7 +92,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createWaku({ + waku = await createLightNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); diff --git a/packages/core/src/lib/wait_for_remote_peer.node.spec.ts b/packages/core/src/lib/wait_for_remote_peer.node.spec.ts index 7c22b27d02..25e219b093 100644 --- a/packages/core/src/lib/wait_for_remote_peer.node.spec.ts +++ b/packages/core/src/lib/wait_for_remote_peer.node.spec.ts @@ -1,12 +1,12 @@ import { createLightNode, createPrivacyNode } from "@waku/create"; +import type { WakuLight, WakuPrivacy } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../test_utils"; import { delay } from "../test_utils/delay"; -import type { WakuLight, WakuPrivacy } from "./interfaces"; import { waitForRemotePeer } from "./wait_for_remote_peer"; -import { Protocols } from "./waku"; describe("Wait for remote peer", function () { let waku1: WakuPrivacy; diff --git a/packages/core/src/lib/waku.node.spec.ts b/packages/core/src/lib/waku.node.spec.ts index f1de32548d..22187366f5 100644 --- a/packages/core/src/lib/waku.node.spec.ts +++ b/packages/core/src/lib/waku.node.spec.ts @@ -1,5 +1,7 @@ import type { PeerId } from "@libp2p/interface-peer-id"; import { createLightNode, createPrivacyNode } from "@waku/create"; +import type { Message, Waku, WakuLight, WakuPrivacy } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import { @@ -10,11 +12,9 @@ import { } from "../test_utils/"; import { generateSymmetricKey } from "./crypto"; -import type { Message, Waku, WakuLight, WakuPrivacy } from "./interfaces"; import { PeerDiscoveryStaticPeers } from "./peer_discovery_static_list"; import { bytesToUtf8, utf8ToBytes } from "./utils"; import { waitForRemotePeer } from "./wait_for_remote_peer"; -import { Protocols } from "./waku"; import { SymDecoder, SymEncoder } from "./waku_message/version_1.js"; const TestContentTopic = "/test/1/waku/utf8"; diff --git a/packages/core/src/lib/waku.spec.ts b/packages/core/src/lib/waku.spec.ts index cd670ee90d..a55da2c16e 100644 --- a/packages/core/src/lib/waku.spec.ts +++ b/packages/core/src/lib/waku.spec.ts @@ -1,12 +1,11 @@ import type { PeerId } from "@libp2p/interface-peer-id"; -import { createWaku } from "@waku/create"; +import { createLightNode } from "@waku/create"; +import type { WakuLight } from "@waku/interfaces"; import { expect } from "chai"; -import type { Waku } from "./interfaces"; - describe("Waku Dial", function () { describe("Bootstrap [live data]", function () { - let waku: Waku; + let waku: WakuLight; afterEach(function () { !!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e)); @@ -23,7 +22,7 @@ describe("Waku Dial", function () { // This dependence must be removed once DNS discovery is implemented this.timeout(20_000); - waku = await createWaku({ + waku = await createLightNode({ defaultBootstrap: true, }); await waku.start(); diff --git a/packages/core/src/lib/waku_filter/index.node.spec.ts b/packages/core/src/lib/waku_filter/index.node.spec.ts index 205335de36..705a813691 100644 --- a/packages/core/src/lib/waku_filter/index.node.spec.ts +++ b/packages/core/src/lib/waku_filter/index.node.spec.ts @@ -1,13 +1,13 @@ +import { createFullNode } from "@waku/create"; +import type { Message, WakuFull } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; import { delay } from "../../test_utils/delay"; -import { createFullNode } from "../create_waku"; -import type { Message, WakuFull } from "../interfaces"; import { bytesToUtf8, utf8ToBytes } from "../utils"; import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { Protocols } from "../waku"; import { DecoderV0, EncoderV0 } from "../waku_message/version_0"; const log = debug("waku:test"); diff --git a/packages/core/src/lib/waku_filter/index.ts b/packages/core/src/lib/waku_filter/index.ts index 9b526b5d45..a2f9c3c7d6 100644 --- a/packages/core/src/lib/waku_filter/index.ts +++ b/packages/core/src/lib/waku_filter/index.ts @@ -82,7 +82,7 @@ export class WakuFilter implements Filter { callback: Callback, opts?: ProtocolOptions ): Promise { - const topic = opts?.pubsubTopic ?? this.pubSubTopic; + const topic = opts?.pubSubTopic ?? this.pubSubTopic; const groupedDecoders = groupByContentTopic(decoders); const contentTopics = Array.from(groupedDecoders.keys()); diff --git a/packages/core/src/lib/waku_light_push/index.node.spec.ts b/packages/core/src/lib/waku_light_push/index.node.spec.ts index 6a9eeb92f6..f05a0234cb 100644 --- a/packages/core/src/lib/waku_light_push/index.node.spec.ts +++ b/packages/core/src/lib/waku_light_push/index.node.spec.ts @@ -1,3 +1,6 @@ +import { createFullNode } from "@waku/create"; +import type { WakuFull } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; @@ -8,11 +11,8 @@ import { Nwaku, } from "../../test_utils"; import { delay } from "../../test_utils/delay"; -import { createFullNode } from "../create_waku"; -import type { WakuFull } from "../interfaces"; import { bytesToUtf8, utf8ToBytes } from "../utils"; import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { Protocols } from "../waku"; import { EncoderV0 } from "../waku_message/version_0"; const log = debug("waku:test:lightpush"); diff --git a/packages/core/src/lib/waku_light_push/index.ts b/packages/core/src/lib/waku_light_push/index.ts index 95ac899349..78600fe9d2 100644 --- a/packages/core/src/lib/waku_light_push/index.ts +++ b/packages/core/src/lib/waku_light_push/index.ts @@ -56,7 +56,7 @@ export class WakuLightPush { message: Partial, opts?: ProtocolOptions ): Promise { - const pubSubTopic = opts?.pubsubTopic ? opts.pubsubTopic : this.pubSubTopic; + const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic; const res = await selectPeerForProtocol( this.libp2p.peerStore, diff --git a/packages/core/src/lib/waku_relay/index.node.spec.ts b/packages/core/src/lib/waku_relay/index.node.spec.ts index 931a2c0e32..7b0af2cdfc 100644 --- a/packages/core/src/lib/waku_relay/index.node.spec.ts +++ b/packages/core/src/lib/waku_relay/index.node.spec.ts @@ -1,4 +1,7 @@ import { PeerId } from "@libp2p/interface-peer-id"; +import { createPrivacyNode } from "@waku/create"; +import type { Message, WakuPrivacy } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; @@ -12,16 +15,13 @@ import { } from "../../test_utils"; import { delay } from "../../test_utils/delay"; import { DefaultPubSubTopic } from "../constants"; -import { createPrivacyNode } from "../create_waku"; import { generatePrivateKey, generateSymmetricKey, getPublicKey, } from "../crypto"; -import type { Message, WakuPrivacy } from "../interfaces"; import { bytesToUtf8, utf8ToBytes } from "../utils"; import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { Protocols } from "../waku"; import { DecoderV0, EncoderV0, MessageV0 } from "../waku_message/version_0.js"; import { AsymDecoder, diff --git a/packages/core/src/lib/waku_store/index.node.spec.ts b/packages/core/src/lib/waku_store/index.node.spec.ts index aa841db6e6..5cd8fc39e9 100644 --- a/packages/core/src/lib/waku_store/index.node.spec.ts +++ b/packages/core/src/lib/waku_store/index.node.spec.ts @@ -1,3 +1,6 @@ +import { createFullNode } from "@waku/create"; +import type { Message, WakuFull } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; @@ -7,16 +10,13 @@ import { NOISE_KEY_2, Nwaku, } from "../../test_utils"; -import { createFullNode } from "../create_waku"; import { generatePrivateKey, generateSymmetricKey, getPublicKey, } from "../crypto"; -import type { Message, WakuFull } from "../interfaces"; import { bytesToUtf8, utf8ToBytes } from "../utils"; import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { Protocols } from "../waku"; import { DecoderV0, EncoderV0 } from "../waku_message/version_0.js"; import { AsymDecoder, diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts index 105230f424..0538cca2fe 100644 --- a/packages/interfaces/src/index.ts +++ b/packages/interfaces/src/index.ts @@ -18,7 +18,7 @@ export interface PointToPointProtocol { } export type ProtocolOptions = { - pubsubTopic?: string; + pubSubTopic?: string; /** * Optionally specify an PeerId for the protocol request. If not included, will use a random peer. */ From 052d5c9d205d8b986b01d20303eb841df3a36650 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:41:34 +1100 Subject: [PATCH 11/23] chore: only bump patch versions for now --- packages/core/package.json | 4 ++-- packages/create/package.json | 4 ++-- packages/interfaces/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 8e25280216..5f53b467ab 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -202,7 +202,7 @@ "releaseRules": [ { "breaking": true, - "release": "major" + "release": "patch" }, { "revert": true, @@ -210,7 +210,7 @@ }, { "type": "feat", - "release": "minor" + "release": "patch" }, { "type": "fix", diff --git a/packages/create/package.json b/packages/create/package.json index ff58c21b75..8c3f8f183f 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -106,7 +106,7 @@ "releaseRules": [ { "breaking": true, - "release": "major" + "release": "patch" }, { "revert": true, @@ -114,7 +114,7 @@ }, { "type": "feat", - "release": "minor" + "release": "patch" }, { "type": "fix", diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 4477717e10..088400a10f 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -96,7 +96,7 @@ "releaseRules": [ { "breaking": true, - "release": "major" + "release": "patch" }, { "revert": true, @@ -104,7 +104,7 @@ }, { "type": "feat", - "release": "minor" + "release": "patch" }, { "type": "fix", From a30354cbd028ffb7fd79f0345744695ca4f1ec2e Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:46:02 +1100 Subject: [PATCH 12/23] test: fix ENR test --- packages/core/src/lib/enr/enr.node.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/lib/enr/enr.node.spec.ts b/packages/core/src/lib/enr/enr.node.spec.ts index 565a6ed805..24b1d3704c 100644 --- a/packages/core/src/lib/enr/enr.node.spec.ts +++ b/packages/core/src/lib/enr/enr.node.spec.ts @@ -1,5 +1,5 @@ -import { createLightNode } from "@waku/create"; -import type { WakuLight } from "@waku/interfaces"; +import { createPrivacyNode } from "@waku/create"; +import type { WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; @@ -9,7 +9,7 @@ import { waitForRemotePeer } from "../wait_for_remote_peer"; import { ENR } from "./enr"; describe("ENR Interop: nwaku", function () { - let waku: WakuLight; + let waku: WakuPrivacy; let nwaku: Nwaku; afterEach(async function () { @@ -28,7 +28,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createLightNode({ + waku = await createPrivacyNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); @@ -60,7 +60,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createLightNode({ + waku = await createPrivacyNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); @@ -92,7 +92,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createLightNode({ + waku = await createPrivacyNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); From fb2b58898d76b48da573aa8abaa419b42fff535b Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:48:44 +1100 Subject: [PATCH 13/23] chore: must build before we check --- .github/workflows/ci.yml | 15 +++------------ bors.toml | 1 - 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0375dd8fe4..e72d535d1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,17 +13,6 @@ env: NODE_JS: "16" jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_JS }} - - uses: bahmutov/npm-install@v1 - - run: npm run check - - run: npm run doc - build: runs-on: ubuntu-latest steps: @@ -33,6 +22,8 @@ jobs: node-version: ${{ env.NODE_JS }} - uses: bahmutov/npm-install@v1 - run: npm run build + - run: npm run check + - run: npm run doc proto: runs-on: ubuntu-latest @@ -146,7 +137,7 @@ jobs: name: Release runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' - needs: [check, build, proto, browser, node] + needs: [build, proto, browser, node] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/bors.toml b/bors.toml index 60984f4bd6..90e7fb8db6 100644 --- a/bors.toml +++ b/bors.toml @@ -1,5 +1,4 @@ status = [ - "check", "build", "proto", "browser", From ce9938e464cb79ec7039dbe0ecb3e5fdd82d8ffd Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 19:57:19 +1100 Subject: [PATCH 14/23] chore: move tests to separate package --- package-lock.json | 53 ++++++++++++++++++- packages/core/package.json | 3 +- packages/tests/.eslintrc.cjs | 6 +++ packages/tests/.mocharc.json | 11 ++++ packages/tests/.prettierignore | 4 ++ packages/tests/karma.conf.cjs | 55 ++++++++++++++++++++ packages/tests/package.json | 82 ++++++++++++++++++++++++++++++ packages/tests/tsconfig.dev.json | 8 +++ packages/tests/tsconfig.json | 54 ++++++++++++++++++++ packages/tests/tsconfig.karma.json | 6 +++ 10 files changed, 278 insertions(+), 4 deletions(-) create mode 100644 packages/tests/.eslintrc.cjs create mode 100644 packages/tests/.mocharc.json create mode 100644 packages/tests/.prettierignore create mode 100644 packages/tests/karma.conf.cjs create mode 100644 packages/tests/package.json create mode 100644 packages/tests/tsconfig.dev.json create mode 100644 packages/tests/tsconfig.json create mode 100644 packages/tests/tsconfig.karma.json diff --git a/package-lock.json b/package-lock.json index 61feee4182..c654affc37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5283,6 +5283,10 @@ "resolved": "packages/interfaces", "link": true }, + "node_modules/@waku/tests": { + "resolved": "packages/tests", + "link": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", @@ -22396,7 +22400,6 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", - "@waku/create": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", @@ -22606,6 +22609,33 @@ "node": ">=16.0.0", "npm": ">=7.0.0" } + }, + "packages/tests": { + "name": "@waku/tests", + "version": "0.0.1", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@waku/core": "*", + "@waku/create": "*", + "@waku/interfaces": "*" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "typescript": "^4.6.3" + }, + "engines": { + "node": ">=16" + } } }, "dependencies": { @@ -26845,7 +26875,6 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", - "@waku/create": "*", "@waku/interfaces": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", @@ -27031,6 +27060,26 @@ } } }, + "@waku/tests": { + "version": "file:packages/tests", + "requires": { + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "@waku/core": "*", + "@waku/create": "*", + "@waku/interfaces": "*", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "typescript": "^4.6.3" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", diff --git a/packages/core/package.json b/packages/core/package.json index 5f53b467ab..765c9f2b42 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -101,7 +101,6 @@ "node": ">=16" }, "dependencies": { - "@waku/interfaces": "*", "@chainsafe/libp2p-gossipsub": "^4.1.1", "@chainsafe/libp2p-noise": "^8.0.1", "@ethersproject/rlp": "^5.5.0", @@ -118,6 +117,7 @@ "@libp2p/websockets": "^3.0.3", "@multiformats/multiaddr": "^11.0.6", "@noble/secp256k1": "^1.3.4", + "@waku/interfaces": "*", "debug": "^4.3.4", "dns-query": "^0.11.2", "hi-base32": "^0.5.1", @@ -152,7 +152,6 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", - "@waku/create": "*", "app-root-path": "^3.0.0", "chai": "^4.3.4", "cspell": "^5.14.0", diff --git a/packages/tests/.eslintrc.cjs b/packages/tests/.eslintrc.cjs new file mode 100644 index 0000000000..324f1f526d --- /dev/null +++ b/packages/tests/.eslintrc.cjs @@ -0,0 +1,6 @@ +module.exports = { + parserOptions: { + tsconfigRootDir: __dirname, + project: "./tsconfig.dev.json", + }, +}; diff --git a/packages/tests/.mocharc.json b/packages/tests/.mocharc.json new file mode 100644 index 0000000000..db9dd73531 --- /dev/null +++ b/packages/tests/.mocharc.json @@ -0,0 +1,11 @@ +{ + "extension": ["ts"], + "spec": "src/**/*.spec.ts", + "require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"], + "loader": "ts-node/esm", + "node-option": [ + "experimental-specifier-resolution=node", + "loader=ts-node/esm" + ], + "exit": true +} diff --git a/packages/tests/.prettierignore b/packages/tests/.prettierignore new file mode 100644 index 0000000000..fecb37a393 --- /dev/null +++ b/packages/tests/.prettierignore @@ -0,0 +1,4 @@ +build +bundle +dist +node_modules diff --git a/packages/tests/karma.conf.cjs b/packages/tests/karma.conf.cjs new file mode 100644 index 0000000000..febf1611b4 --- /dev/null +++ b/packages/tests/karma.conf.cjs @@ -0,0 +1,55 @@ +process.env.CHROME_BIN = require("puppeteer").executablePath(); +const webpack = require("webpack"); + +module.exports = function (config) { + config.set({ + frameworks: ["webpack", "mocha"], + files: ["src/lib/**/!(node).spec.ts"], + preprocessors: { + "src/lib/**/!(node).spec.ts": ["webpack"], + }, + envPreprocessor: ["CI"], + reporters: ["progress"], + browsers: ["ChromeHeadless"], + singleRun: true, + client: { + mocha: { + timeout: 6000, // Default is 2s + }, + }, + webpack: { + mode: "production", + module: { + rules: [ + { + test: /\.(js|tsx?)$/, + use: [ + { + loader: "ts-loader", + options: { configFile: "tsconfig.karma.json" }, + }, + ], + exclude: /(node_modules)|(node\.spec\.ts)/, + }, + { + test: /node\.spec\.ts$/, + use: "ignore-loader", + }, + ], + }, + plugins: [ + new webpack.DefinePlugin({ + "process.env.CI": process.env.CI || false, + }), + new webpack.ProvidePlugin({ + process: "process/browser.js", + }), + ], + resolve: { + extensions: [".ts", ".js"], + }, + stats: { warnings: false }, + devtool: "inline-source-map", + }, + }); +}; diff --git a/packages/tests/package.json b/packages/tests/package.json new file mode 100644 index 0000000000..9f7a134056 --- /dev/null +++ b/packages/tests/package.json @@ -0,0 +1,82 @@ +{ + "name": "@waku/tests", + "private": true, + "version": "0.0.1", + "description": "Waku tests", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "typesVersions": { + "*": { + "lib/*": [ + "dist/lib/*" + ] + } + }, + "type": "module", + "author": "Waku Team", + "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/tests#readme", + "repository": { + "type": "git", + "url": "https://github.com/waku-org/js-waku.git" + }, + "bugs": { + "url": "https://github.com/waku-org/js-waku/issues" + }, + "license": "MIT OR Apache-2.0", + "keywords": [ + "waku", + "decentralized", + "secure", + "communication", + "web3", + "ethereum", + "dapps", + "privacy" + ], + "scripts": { + "build": "run-s build:**", + "build:esm": "tsc", + "fix": "run-s fix:*", + "fix:prettier": "prettier . --write", + "fix:lint": "eslint src --ext .ts --ext .cjs --fix", + "check": "run-s check:*", + "check:lint": "eslint src --ext .ts", + "check:prettier": "prettier . --list-different", + "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", + "check:tsc": "tsc -p tsconfig.dev.json", + "test": "exit 0 # Tested in @waku/core", + "proto": "exit 0 # no proto", + "doc": "exit 0", + "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", + "release": "exit 0" + }, + "engines": { + "node": ">=16" + }, + "dependencies": { + "@waku/interfaces": "*", + "@waku/core": "*", + "@waku/create": "*" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "typescript": "^4.6.3" + } +} diff --git a/packages/tests/tsconfig.dev.json b/packages/tests/tsconfig.dev.json new file mode 100644 index 0000000000..ffc27ef6ba --- /dev/null +++ b/packages/tests/tsconfig.dev.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "module": "esnext", + "noEmit": true + }, + "exclude": [] +} diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json new file mode 100644 index 0000000000..7b01b30897 --- /dev/null +++ b/packages/tests/tsconfig.json @@ -0,0 +1,54 @@ +{ + "compilerOptions": { + "incremental": true, + "target": "es2020", + "outDir": "dist/", + "rootDir": "src", + "moduleResolution": "node", + "module": "es2020", + "declaration": true, + "sourceMap": true, + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "resolveJsonModule": true /* Include modules imported with .json extension. */, + "tsBuildInfoFile": "dist/.tsbuildinfo", + "strict": true /* Enable all strict type-checking options. */, + + /* Strict Type-Checking Options */ + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + "strictNullChecks": true /* Enable strict null checks. */, + "strictFunctionTypes": true /* Enable strict checking of function types. */, + "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, + "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, + "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */, + "noUnusedParameters": true /* Report errors on unused parameters. */, + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "forceConsistentCasingInFileNames": true, + + /* Debugging Options */ + "traceResolution": false /* Report module resolution log messages. */, + "listEmittedFiles": false /* Print names of generated files part of the compilation. */, + "listFiles": false /* Print names of files part of the compilation. */, + "pretty": true /* Stylize errors and messages using color and context. */, + + // Due to broken types in indirect dependencies + "skipLibCheck": true, + + /* Experimental Options */ + // "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, + // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, + + "lib": ["es2020", "dom"], + "types": ["node", "mocha"], + "typeRoots": ["node_modules/@types", "src/types"] + }, + "include": ["src"], + "exclude": ["src/**/*.spec.ts", "src/test_utils"], + "compileOnSave": false, + "ts-node": { + "files": true + } +} diff --git a/packages/tests/tsconfig.karma.json b/packages/tests/tsconfig.karma.json new file mode 100644 index 0000000000..c540c783ff --- /dev/null +++ b/packages/tests/tsconfig.karma.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.dev", + "compilerOptions": { + "noEmit": false + } +} From 3d08cb28c8dab2594de987217ffda5d7f5ea637f Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 20:13:09 +1100 Subject: [PATCH 15/23] chore: move tests to separate package --- packages/tests/.eslintrc.cjs | 2 +- packages/tests/package.json | 14 ++++---------- .../src/lib/enr => tests/tests}/enr.node.spec.ts | 0 .../tests/filter.node.spec.ts} | 0 .../tests/light_push.node.spec.ts} | 0 .../tests/relay.node.spec.ts} | 0 .../tests/store.node.spec.ts} | 0 .../tests}/wait_for_remote_peer.node.spec.ts | 0 .../src/lib => tests/tests}/waku.node.spec.ts | 0 .../{core/src/lib => tests/tests}/waku.spec.ts | 0 packages/tests/tsconfig.dev.json | 8 -------- packages/tests/tsconfig.json | 8 ++++---- packages/tests/tsconfig.karma.json | 2 +- 13 files changed, 10 insertions(+), 24 deletions(-) rename packages/{core/src/lib/enr => tests/tests}/enr.node.spec.ts (100%) rename packages/{core/src/lib/waku_filter/index.node.spec.ts => tests/tests/filter.node.spec.ts} (100%) rename packages/{core/src/lib/waku_light_push/index.node.spec.ts => tests/tests/light_push.node.spec.ts} (100%) rename packages/{core/src/lib/waku_relay/index.node.spec.ts => tests/tests/relay.node.spec.ts} (100%) rename packages/{core/src/lib/waku_store/index.node.spec.ts => tests/tests/store.node.spec.ts} (100%) rename packages/{core/src/lib => tests/tests}/wait_for_remote_peer.node.spec.ts (100%) rename packages/{core/src/lib => tests/tests}/waku.node.spec.ts (100%) rename packages/{core/src/lib => tests/tests}/waku.spec.ts (100%) delete mode 100644 packages/tests/tsconfig.dev.json diff --git a/packages/tests/.eslintrc.cjs b/packages/tests/.eslintrc.cjs index 324f1f526d..37c79ff066 100644 --- a/packages/tests/.eslintrc.cjs +++ b/packages/tests/.eslintrc.cjs @@ -1,6 +1,6 @@ module.exports = { parserOptions: { tsconfigRootDir: __dirname, - project: "./tsconfig.dev.json", + project: "./tsconfig.json", }, }; diff --git a/packages/tests/package.json b/packages/tests/package.json index 9f7a134056..f7bbc3b112 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -41,21 +41,15 @@ "privacy" ], "scripts": { - "build": "run-s build:**", - "build:esm": "tsc", "fix": "run-s fix:*", "fix:prettier": "prettier . --write", - "fix:lint": "eslint src --ext .ts --ext .cjs --fix", + "fix:lint": "eslint tests --ext .ts --ext .cjs --fix", "check": "run-s check:*", - "check:lint": "eslint src --ext .ts", + "check:lint": "eslint tests --ext .ts", "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", - "check:tsc": "tsc -p tsconfig.dev.json", - "test": "exit 0 # Tested in @waku/core", - "proto": "exit 0 # no proto", - "doc": "exit 0", - "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", - "release": "exit 0" + "check:tsc": "tsc -p tsconfig.json", + "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" }, "engines": { "node": ">=16" diff --git a/packages/core/src/lib/enr/enr.node.spec.ts b/packages/tests/tests/enr.node.spec.ts similarity index 100% rename from packages/core/src/lib/enr/enr.node.spec.ts rename to packages/tests/tests/enr.node.spec.ts diff --git a/packages/core/src/lib/waku_filter/index.node.spec.ts b/packages/tests/tests/filter.node.spec.ts similarity index 100% rename from packages/core/src/lib/waku_filter/index.node.spec.ts rename to packages/tests/tests/filter.node.spec.ts diff --git a/packages/core/src/lib/waku_light_push/index.node.spec.ts b/packages/tests/tests/light_push.node.spec.ts similarity index 100% rename from packages/core/src/lib/waku_light_push/index.node.spec.ts rename to packages/tests/tests/light_push.node.spec.ts diff --git a/packages/core/src/lib/waku_relay/index.node.spec.ts b/packages/tests/tests/relay.node.spec.ts similarity index 100% rename from packages/core/src/lib/waku_relay/index.node.spec.ts rename to packages/tests/tests/relay.node.spec.ts diff --git a/packages/core/src/lib/waku_store/index.node.spec.ts b/packages/tests/tests/store.node.spec.ts similarity index 100% rename from packages/core/src/lib/waku_store/index.node.spec.ts rename to packages/tests/tests/store.node.spec.ts diff --git a/packages/core/src/lib/wait_for_remote_peer.node.spec.ts b/packages/tests/tests/wait_for_remote_peer.node.spec.ts similarity index 100% rename from packages/core/src/lib/wait_for_remote_peer.node.spec.ts rename to packages/tests/tests/wait_for_remote_peer.node.spec.ts diff --git a/packages/core/src/lib/waku.node.spec.ts b/packages/tests/tests/waku.node.spec.ts similarity index 100% rename from packages/core/src/lib/waku.node.spec.ts rename to packages/tests/tests/waku.node.spec.ts diff --git a/packages/core/src/lib/waku.spec.ts b/packages/tests/tests/waku.spec.ts similarity index 100% rename from packages/core/src/lib/waku.spec.ts rename to packages/tests/tests/waku.spec.ts diff --git a/packages/tests/tsconfig.dev.json b/packages/tests/tsconfig.dev.json deleted file mode 100644 index ffc27ef6ba..0000000000 --- a/packages/tests/tsconfig.dev.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig", - "compilerOptions": { - "module": "esnext", - "noEmit": true - }, - "exclude": [] -} diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index 7b01b30897..ae5766a55f 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -3,9 +3,10 @@ "incremental": true, "target": "es2020", "outDir": "dist/", - "rootDir": "src", + "rootDir": "tests", + "noEmit": true, "moduleResolution": "node", - "module": "es2020", + "module": "esnext", "declaration": true, "sourceMap": true, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, @@ -45,8 +46,7 @@ "types": ["node", "mocha"], "typeRoots": ["node_modules/@types", "src/types"] }, - "include": ["src"], - "exclude": ["src/**/*.spec.ts", "src/test_utils"], + "include": ["tests"], "compileOnSave": false, "ts-node": { "files": true diff --git a/packages/tests/tsconfig.karma.json b/packages/tests/tsconfig.karma.json index c540c783ff..c945ddb239 100644 --- a/packages/tests/tsconfig.karma.json +++ b/packages/tests/tsconfig.karma.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.dev", + "extends": "./tsconfig", "compilerOptions": { "noEmit": false } From 9d544628935a9d7c4ba6859edf7e2ffd82d90732 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 20:14:01 +1100 Subject: [PATCH 16/23] chore: lerna skip non-existent scripts --- packages/create/package.json | 2 -- packages/interfaces/package.json | 2 -- 2 files changed, 4 deletions(-) diff --git a/packages/create/package.json b/packages/create/package.json index 8c3f8f183f..ec25796597 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -51,8 +51,6 @@ "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.dev.json", - "test": "exit 0 # Tested in @waku/core", - "proto": "exit 0 # no proto", "doc": "run-s doc:*", "doc:html": "typedoc --treatWarningsAsErrors", "prepublish": "npm run build", diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 088400a10f..5d5703167d 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -41,8 +41,6 @@ "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.dev.json", - "test": "exit 0 # Tested in @waku/core", - "proto": "exit 0 # no proto", "doc": "run-s doc:*", "doc:html": "typedoc --treatWarningsAsErrors", "prepublish": "npm run build", From b11d465a9dfded7dc13d1ebe7bd88a16f3e3e360 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 21:31:53 +1100 Subject: [PATCH 17/23] chore: move tests to remove circular dep --- packages/core/package.json | 8 +++ packages/core/rollup.config.js | 2 + packages/core/typedoc.json | 2 + packages/tests/.eslintrc.cjs | 3 + packages/tests/.mocharc.json | 2 +- packages/tests/package.json | 14 ++++- .../src/test_utils => tests/src}/async_fs.ts | 0 .../src/test_utils => tests/src}/constants.ts | 0 .../src/test_utils => tests/src}/delay.ts | 0 .../src/test_utils => tests/src}/index.ts | 0 .../src/test_utils => tests/src}/log_file.ts | 0 .../src/test_utils => tests/src}/nwaku.ts | 12 ++-- packages/tests/tests/enr.node.spec.ts | 13 ++-- packages/tests/tests/filter.node.spec.ts | 12 ++-- packages/tests/tests/light_push.node.spec.ts | 14 +++-- .../tests}/log_file.node.spec.ts | 2 +- .../tests}/nwaku.node.spec.ts | 2 +- packages/tests/tests/relay.node.spec.ts | 44 ++++++++------ packages/tests/tests/store.node.spec.ts | 60 ++++++++++++------- .../tests/wait_for_remote_peer.node.spec.ts | 25 ++++++-- packages/tests/tests/waku.node.spec.ts | 24 ++++---- packages/tests/tsconfig.json | 4 +- 22 files changed, 156 insertions(+), 87 deletions(-) rename packages/{core/src/test_utils => tests/src}/async_fs.ts (100%) rename packages/{core/src/test_utils => tests/src}/constants.ts (100%) rename packages/{core/src/test_utils => tests/src}/delay.ts (100%) rename packages/{core/src/test_utils => tests/src}/index.ts (100%) rename packages/{core/src/test_utils => tests/src}/log_file.ts (100%) rename packages/{core/src/test_utils => tests/src}/nwaku.ts (98%) rename packages/{core/src/test_utils => tests/tests}/log_file.node.spec.ts (90%) rename packages/{core/src/test_utils => tests/tests}/nwaku.node.spec.ts (90%) diff --git a/packages/core/package.json b/packages/core/package.json index 765c9f2b42..488944f962 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,6 +9,10 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js" }, + "./lib/enr": { + "types": "./dist/lib/enr/index.d.ts", + "import": "./dist/lib/enr/index.js" + }, "./lib/peer_discovery_dns": { "types": "./dist/lib/peer_discovery_dns/index.d.ts", "import": "./dist/lib/peer_discovery_dns/index.js" @@ -21,6 +25,10 @@ "types": "./dist/lib/predefined_bootstrap_nodes.d.ts", "import": "./dist/lib/predefined_bootstrap_nodes.js" }, + "./lib/utils": { + "types": "./dist/lib/utils.d.ts", + "import": "./dist/lib/utils.js" + }, "./lib/wait_for_remote_peer": { "types": "./dist/lib/wait_for_remote_peer.d.ts", "import": "./dist/lib/wait_for_remote_peer.js" diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.js index 79fd67420e..4b2cd71a2d 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.js @@ -5,9 +5,11 @@ import json from "@rollup/plugin-json"; export default { input: { index: "dist/index.js", + "lib/enr": "dist/lib/enr/index.js", "lib/peer_discovery_dns": "dist/lib/peer_discovery_dns/index.js", "lib/peer_discovery_static_list": "dist/lib/peer_discovery_static_list.js", "lib/predefined_bootstrap_nodes": "dist/lib/predefined_bootstrap_nodes.js", + "lib/utils": "dist/lib/utils.js", "lib/wait_for_remote_peer": "dist/lib/wait_for_remote_peer.js", "lib/waku_message/version_0": "dist/lib/waku_message/version_0.js", "lib/waku_message/version_1": "dist/lib/waku_message/version_1.js", diff --git a/packages/core/typedoc.json b/packages/core/typedoc.json index 031b751650..0e56836bb7 100644 --- a/packages/core/typedoc.json +++ b/packages/core/typedoc.json @@ -1,9 +1,11 @@ { "entryPoints": [ "./src/index.ts", + "./src/lib/enr/index.ts", "./src/lib/peer_discovery_dns.ts", "./src/lib/peer_discovery_static_list.ts", "./src/lib/predefined_bootstrap_nodes.ts", + "./src/lib/utils.ts", "./src/lib/wait_for_remote_peer.ts", "./src/lib/waku_message/version_0.ts", "./src/lib/waku_message/version_1.ts", diff --git a/packages/tests/.eslintrc.cjs b/packages/tests/.eslintrc.cjs index 37c79ff066..cb52e850cc 100644 --- a/packages/tests/.eslintrc.cjs +++ b/packages/tests/.eslintrc.cjs @@ -3,4 +3,7 @@ module.exports = { tsconfigRootDir: __dirname, project: "./tsconfig.json", }, + rules: { + "@typescript-eslint/no-non-null-assertion": "off", + }, }; diff --git a/packages/tests/.mocharc.json b/packages/tests/.mocharc.json index db9dd73531..0658ab762d 100644 --- a/packages/tests/.mocharc.json +++ b/packages/tests/.mocharc.json @@ -1,6 +1,6 @@ { "extension": ["ts"], - "spec": "src/**/*.spec.ts", + "spec": "tests/**/*.spec.ts", "require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"], "loader": "ts-node/esm", "node-option": [ diff --git a/packages/tests/package.json b/packages/tests/package.json index f7bbc3b112..a340235a64 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -43,12 +43,20 @@ "scripts": { "fix": "run-s fix:*", "fix:prettier": "prettier . --write", - "fix:lint": "eslint tests --ext .ts --ext .cjs --fix", + "fix:lint": "eslint src tests --ext .ts --ext .cjs --fix", + "pretest": "run-s pretest:*", + "pretest:1-init-git-submodules": "[ -f '../../nwaku/build/wakunode2' ] || git submodule update --init --recursive", + "pretest:2-build-nwaku": "[ -f '../../nwaku/build/wakunode2' ] || run-s nwaku:build", + "nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)", + "nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build", "check": "run-s check:*", - "check:lint": "eslint tests --ext .ts", + "check:lint": "eslint src tests --ext .ts", "check:prettier": "prettier . --list-different", - "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", + "check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.json", + "test": "run-s test:*", + "test:node": "TS_NODE_PROJECT=./tsconfig.json mocha", + "test:browser": "karma start karma.conf.cjs", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" }, "engines": { diff --git a/packages/core/src/test_utils/async_fs.ts b/packages/tests/src/async_fs.ts similarity index 100% rename from packages/core/src/test_utils/async_fs.ts rename to packages/tests/src/async_fs.ts diff --git a/packages/core/src/test_utils/constants.ts b/packages/tests/src/constants.ts similarity index 100% rename from packages/core/src/test_utils/constants.ts rename to packages/tests/src/constants.ts diff --git a/packages/core/src/test_utils/delay.ts b/packages/tests/src/delay.ts similarity index 100% rename from packages/core/src/test_utils/delay.ts rename to packages/tests/src/delay.ts diff --git a/packages/core/src/test_utils/index.ts b/packages/tests/src/index.ts similarity index 100% rename from packages/core/src/test_utils/index.ts rename to packages/tests/src/index.ts diff --git a/packages/core/src/test_utils/log_file.ts b/packages/tests/src/log_file.ts similarity index 100% rename from packages/core/src/test_utils/log_file.ts rename to packages/tests/src/log_file.ts diff --git a/packages/core/src/test_utils/nwaku.ts b/packages/tests/src/nwaku.ts similarity index 98% rename from packages/core/src/test_utils/nwaku.ts rename to packages/tests/src/nwaku.ts index 3027963bb5..15ef495690 100644 --- a/packages/core/src/test_utils/nwaku.ts +++ b/packages/tests/src/nwaku.ts @@ -1,24 +1,20 @@ -/** - * @hidden - * @module - */ - import { ChildProcess, spawn } from "child_process"; import type { PeerId } from "@libp2p/interface-peer-id"; import { peerIdFromString } from "@libp2p/peer-id"; import { Multiaddr, multiaddr } from "@multiformats/multiaddr"; +import { DefaultPubSubTopic } from "@waku/core"; +import { utils } from "@waku/core"; import appRoot from "app-root-path"; import debug from "debug"; import portfinder from "portfinder"; -import { DefaultPubSubTopic } from "../lib/constants"; -import { bytesToHex, hexToBytes } from "../lib/utils"; - import { existsAsync, mkdirAsync, openAsync } from "./async_fs"; import { delay } from "./delay"; import waitForLine from "./log_file"; +const { bytesToHex, hexToBytes } = utils; + const log = debug("waku:nwaku"); const WAKU_SERVICE_NODE_DIR = diff --git a/packages/tests/tests/enr.node.spec.ts b/packages/tests/tests/enr.node.spec.ts index 24b1d3704c..3bfabbe2e3 100644 --- a/packages/tests/tests/enr.node.spec.ts +++ b/packages/tests/tests/enr.node.spec.ts @@ -1,12 +1,11 @@ +import { ENR } from "@waku/core/lib/enr"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; import { createPrivacyNode } from "@waku/create"; import type { WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; -import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; - -import { ENR } from "./enr"; +import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src"; describe("ENR Interop: nwaku", function () { let waku: WakuPrivacy; @@ -32,6 +31,8 @@ describe("ENR Interop: nwaku", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku, [Protocols.Relay]); @@ -64,6 +65,8 @@ describe("ENR Interop: nwaku", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku, [Protocols.Relay]); @@ -96,6 +99,8 @@ describe("ENR Interop: nwaku", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku, [Protocols.Relay]); diff --git a/packages/tests/tests/filter.node.spec.ts b/packages/tests/tests/filter.node.spec.ts index 705a813691..561e58d8b8 100644 --- a/packages/tests/tests/filter.node.spec.ts +++ b/packages/tests/tests/filter.node.spec.ts @@ -1,14 +1,14 @@ +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { DecoderV0, EncoderV0 } from "@waku/core/lib/waku_message/version_0"; import { createFullNode } from "@waku/create"; import type { Message, WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; -import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; -import { delay } from "../../test_utils/delay"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { DecoderV0, EncoderV0 } from "../waku_message/version_0"; +import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src"; +import { delay } from "../src/delay"; const log = debug("waku:test"); @@ -34,6 +34,8 @@ describe("Waku Filter", () => { libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } }, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]); }); diff --git a/packages/tests/tests/light_push.node.spec.ts b/packages/tests/tests/light_push.node.spec.ts index f05a0234cb..f937e54a22 100644 --- a/packages/tests/tests/light_push.node.spec.ts +++ b/packages/tests/tests/light_push.node.spec.ts @@ -1,3 +1,6 @@ +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { EncoderV0 } from "@waku/core/lib/waku_message/version_0"; import { createFullNode } from "@waku/create"; import type { WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; @@ -9,11 +12,8 @@ import { MessageRpcResponse, NOISE_KEY_1, Nwaku, -} from "../../test_utils"; -import { delay } from "../../test_utils/delay"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { EncoderV0 } from "../waku_message/version_0"; +} from "../src"; +import { delay } from "../src/delay"; const log = debug("waku:test:lightpush"); @@ -39,6 +39,8 @@ describe("Waku Light Push [node only]", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.LightPush]); @@ -73,6 +75,8 @@ describe("Waku Light Push [node only]", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.LightPush]); diff --git a/packages/core/src/test_utils/log_file.node.spec.ts b/packages/tests/tests/log_file.node.spec.ts similarity index 90% rename from packages/core/src/test_utils/log_file.node.spec.ts rename to packages/tests/tests/log_file.node.spec.ts index c72d3098d0..0d40474b6f 100644 --- a/packages/core/src/test_utils/log_file.node.spec.ts +++ b/packages/tests/tests/log_file.node.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { makeLogFileName } from "./log_file"; +import { makeLogFileName } from "../src"; describe("This", function () { describe("Is", function () { diff --git a/packages/core/src/test_utils/nwaku.node.spec.ts b/packages/tests/tests/nwaku.node.spec.ts similarity index 90% rename from packages/core/src/test_utils/nwaku.node.spec.ts rename to packages/tests/tests/nwaku.node.spec.ts index d2f7e05222..5299aab3f6 100644 --- a/packages/core/src/test_utils/nwaku.node.spec.ts +++ b/packages/tests/tests/nwaku.node.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { argsToArray, defaultArgs } from "./nwaku"; +import { argsToArray, defaultArgs } from "../src"; describe("nwaku", () => { it("Correctly serialized arguments", function () { diff --git a/packages/tests/tests/relay.node.spec.ts b/packages/tests/tests/relay.node.spec.ts index 7b0af2cdfc..bab30edce3 100644 --- a/packages/tests/tests/relay.node.spec.ts +++ b/packages/tests/tests/relay.node.spec.ts @@ -1,4 +1,23 @@ import { PeerId } from "@libp2p/interface-peer-id"; +import { DefaultPubSubTopic } from "@waku/core"; +import { + generatePrivateKey, + generateSymmetricKey, + getPublicKey, +} from "@waku/core"; +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { + DecoderV0, + EncoderV0, + MessageV0, +} from "@waku/core/lib/waku_message/version_0"; +import { + AsymDecoder, + AsymEncoder, + SymDecoder, + SymEncoder, +} from "@waku/core/lib/waku_message/version_1"; import { createPrivacyNode } from "@waku/create"; import type { Message, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; @@ -12,23 +31,8 @@ import { NOISE_KEY_2, NOISE_KEY_3, Nwaku, -} from "../../test_utils"; -import { delay } from "../../test_utils/delay"; -import { DefaultPubSubTopic } from "../constants"; -import { - generatePrivateKey, - generateSymmetricKey, - getPublicKey, -} from "../crypto"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { DecoderV0, EncoderV0, MessageV0 } from "../waku_message/version_0.js"; -import { - AsymDecoder, - AsymEncoder, - SymDecoder, - SymEncoder, -} from "../waku_message/version_1.js"; +} from "../src"; +import { delay } from "../src/delay"; const log = debug("waku:test"); @@ -342,6 +346,8 @@ describe("Waku Relay [node only]", () => { nwaku = new Nwaku(this.test?.ctx?.currentTest?.title + ""); await nwaku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Relay]); }); @@ -439,7 +445,11 @@ describe("Waku Relay [node only]", () => { const nwakuMultiaddr = await nwaku.getMultiaddrWithId(); await Promise.all([ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku1.dial(nwakuMultiaddr), + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku2.dial(nwakuMultiaddr), ]); diff --git a/packages/tests/tests/store.node.spec.ts b/packages/tests/tests/store.node.spec.ts index 5cd8fc39e9..fb779059b2 100644 --- a/packages/tests/tests/store.node.spec.ts +++ b/packages/tests/tests/store.node.spec.ts @@ -1,31 +1,25 @@ +import { + generatePrivateKey, + generateSymmetricKey, + getPublicKey, +} from "@waku/core"; +import { PageDirection } from "@waku/core"; +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { DecoderV0, EncoderV0 } from "@waku/core/lib/waku_message/version_0"; +import { + AsymDecoder, + AsymEncoder, + SymDecoder, + SymEncoder, +} from "@waku/core/lib/waku_message/version_1"; import { createFullNode } from "@waku/create"; import type { Message, WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; -import { - makeLogFileName, - NOISE_KEY_1, - NOISE_KEY_2, - Nwaku, -} from "../../test_utils"; -import { - generatePrivateKey, - generateSymmetricKey, - getPublicKey, -} from "../crypto"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { DecoderV0, EncoderV0 } from "../waku_message/version_0.js"; -import { - AsymDecoder, - AsymEncoder, - SymDecoder, - SymEncoder, -} from "../waku_message/version_1.js"; - -import { PageDirection } from "./history_rpc"; +import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src"; const log = debug("waku:test:store"); @@ -67,6 +61,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -98,6 +94,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -138,6 +136,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -179,6 +179,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -218,6 +220,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -261,6 +265,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -343,7 +349,11 @@ describe("Waku Store", () => { log("Waku nodes created"); await Promise.all([ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku1.dial(nimWakuMultiaddr), + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku2.dial(nimWakuMultiaddr), ]); @@ -425,6 +435,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -486,6 +498,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -545,6 +559,8 @@ describe("Waku Store, custom pubsub topic", () => { pubSubTopic: customPubSubTopic, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); diff --git a/packages/tests/tests/wait_for_remote_peer.node.spec.ts b/packages/tests/tests/wait_for_remote_peer.node.spec.ts index 25e219b093..9ba26feeb3 100644 --- a/packages/tests/tests/wait_for_remote_peer.node.spec.ts +++ b/packages/tests/tests/wait_for_remote_peer.node.spec.ts @@ -1,12 +1,11 @@ +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; import { createLightNode, createPrivacyNode } from "@waku/create"; import type { WakuLight, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; -import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../test_utils"; -import { delay } from "../test_utils/delay"; - -import { waitForRemotePeer } from "./wait_for_remote_peer"; +import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src"; +import { delay } from "../src/delay"; describe("Wait for remote peer", function () { let waku1: WakuPrivacy; @@ -37,6 +36,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku1.dial(multiAddrWithId); await delay(1000); await waitForRemotePeer(waku1, [Protocols.Relay]); @@ -65,6 +66,8 @@ describe("Wait for remote peer", function () { const waitPromise = waitForRemotePeer(waku1, [Protocols.Relay]); await delay(1000); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku1.dial(multiAddrWithId); await waitPromise; @@ -110,6 +113,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await delay(1000); await waitForRemotePeer(waku2, [Protocols.Store]); @@ -139,6 +144,8 @@ describe("Wait for remote peer", function () { await waku2.start(); const waitPromise = waitForRemotePeer(waku2, [Protocols.Store], 2000); await delay(1000); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitPromise; @@ -165,6 +172,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitForRemotePeer(waku2, [Protocols.LightPush]); @@ -193,6 +202,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitForRemotePeer(waku2, [Protocols.Filter]); @@ -222,6 +233,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitForRemotePeer(waku2); @@ -258,10 +271,12 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku1.dial(multiAddrWithId); await waitForRemotePeer(waku1); - const peers = await waku1.relay.getMeshPeers(); + const peers = waku1.relay.getMeshPeers(); const nimPeerId = multiAddrWithId.getPeerId(); diff --git a/packages/tests/tests/waku.node.spec.ts b/packages/tests/tests/waku.node.spec.ts index 22187366f5..8999460ffb 100644 --- a/packages/tests/tests/waku.node.spec.ts +++ b/packages/tests/tests/waku.node.spec.ts @@ -1,21 +1,15 @@ import type { PeerId } from "@libp2p/interface-peer-id"; +import { generateSymmetricKey } from "@waku/core"; +import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list"; +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { SymDecoder, SymEncoder } from "@waku/core/lib/waku_message/version_1"; import { createLightNode, createPrivacyNode } from "@waku/create"; import type { Message, Waku, WakuLight, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; -import { - makeLogFileName, - NOISE_KEY_1, - NOISE_KEY_2, - Nwaku, -} from "../test_utils/"; - -import { generateSymmetricKey } from "./crypto"; -import { PeerDiscoveryStaticPeers } from "./peer_discovery_static_list"; -import { bytesToUtf8, utf8ToBytes } from "./utils"; -import { waitForRemotePeer } from "./wait_for_remote_peer"; -import { SymDecoder, SymEncoder } from "./waku_message/version_1.js"; +import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src/"; const TestContentTopic = "/test/1/waku/utf8"; @@ -44,6 +38,8 @@ describe("Waku Dial [node only]", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku); @@ -70,6 +66,8 @@ describe("Waku Dial [node only]", function () { waku = await createLightNode({ staticNoiseKey: NOISE_KEY_1, libp2p: { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos peerDiscovery: [new PeerDiscoveryStaticPeers([multiAddrWithId])], }, }); @@ -97,6 +95,8 @@ describe("Waku Dial [node only]", function () { staticNoiseKey: NOISE_KEY_1, libp2p: { peerDiscovery: [ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos new PeerDiscoveryStaticPeers([await nwaku.getMultiaddrWithId()]), ], }, diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index ae5766a55f..165ba89ee0 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -2,8 +2,6 @@ "compilerOptions": { "incremental": true, "target": "es2020", - "outDir": "dist/", - "rootDir": "tests", "noEmit": true, "moduleResolution": "node", "module": "esnext", @@ -46,7 +44,7 @@ "types": ["node", "mocha"], "typeRoots": ["node_modules/@types", "src/types"] }, - "include": ["tests"], + "include": ["tests", "src"], "compileOnSave": false, "ts-node": { "files": true From 5ba1ee12c73db2cd44a376335a1417ecf867d06c Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Wed, 2 Nov 2022 13:53:26 +1100 Subject: [PATCH 18/23] test: re-introduce build --- packages/tests/.eslintrc.cjs | 2 +- packages/tests/.mocharc.json | 2 +- packages/tests/karma.conf.cjs | 4 ++-- packages/tests/package.json | 3 ++- packages/tests/tsconfig.dev.json | 8 ++++++++ packages/tests/tsconfig.json | 7 ++++--- packages/tests/tsconfig.karma.json | 2 +- 7 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 packages/tests/tsconfig.dev.json diff --git a/packages/tests/.eslintrc.cjs b/packages/tests/.eslintrc.cjs index cb52e850cc..8de4a3fd8d 100644 --- a/packages/tests/.eslintrc.cjs +++ b/packages/tests/.eslintrc.cjs @@ -1,7 +1,7 @@ module.exports = { parserOptions: { tsconfigRootDir: __dirname, - project: "./tsconfig.json", + project: "./tsconfig.dev.json", }, rules: { "@typescript-eslint/no-non-null-assertion": "off", diff --git a/packages/tests/.mocharc.json b/packages/tests/.mocharc.json index 0658ab762d..b4cde4e22d 100644 --- a/packages/tests/.mocharc.json +++ b/packages/tests/.mocharc.json @@ -1,6 +1,6 @@ { "extension": ["ts"], - "spec": "tests/**/*.spec.ts", + "spec": "tests/*.spec.ts", "require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"], "loader": "ts-node/esm", "node-option": [ diff --git a/packages/tests/karma.conf.cjs b/packages/tests/karma.conf.cjs index febf1611b4..daa7293fc1 100644 --- a/packages/tests/karma.conf.cjs +++ b/packages/tests/karma.conf.cjs @@ -4,9 +4,9 @@ const webpack = require("webpack"); module.exports = function (config) { config.set({ frameworks: ["webpack", "mocha"], - files: ["src/lib/**/!(node).spec.ts"], + files: ["tests/**/!(node).spec.ts"], preprocessors: { - "src/lib/**/!(node).spec.ts": ["webpack"], + "tests/**/!(node).spec.ts": ["webpack"], }, envPreprocessor: ["CI"], reporters: ["progress"], diff --git a/packages/tests/package.json b/packages/tests/package.json index a340235a64..ee663da492 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -41,6 +41,7 @@ "privacy" ], "scripts": { + "build": "tsc", "fix": "run-s fix:*", "fix:prettier": "prettier . --write", "fix:lint": "eslint src tests --ext .ts --ext .cjs --fix", @@ -50,8 +51,8 @@ "nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)", "nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build", "check": "run-s check:*", - "check:lint": "eslint src tests --ext .ts", "check:prettier": "prettier . --list-different", + "check:lint": "eslint src tests --ext .ts", "check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.json", "test": "run-s test:*", diff --git a/packages/tests/tsconfig.dev.json b/packages/tests/tsconfig.dev.json new file mode 100644 index 0000000000..d64199f6ad --- /dev/null +++ b/packages/tests/tsconfig.dev.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "module": "esnext", + "noEmit": true + }, + "include": ["src", "tests"] +} diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index 165ba89ee0..49df3977af 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -2,9 +2,9 @@ "compilerOptions": { "incremental": true, "target": "es2020", - "noEmit": true, + "outDir": "dist/", "moduleResolution": "node", - "module": "esnext", + "module": "es2020", "declaration": true, "sourceMap": true, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, @@ -44,7 +44,8 @@ "types": ["node", "mocha"], "typeRoots": ["node_modules/@types", "src/types"] }, - "include": ["tests", "src"], + "include": ["src"], + "exclude": [], "compileOnSave": false, "ts-node": { "files": true diff --git a/packages/tests/tsconfig.karma.json b/packages/tests/tsconfig.karma.json index c945ddb239..c540c783ff 100644 --- a/packages/tests/tsconfig.karma.json +++ b/packages/tests/tsconfig.karma.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig", + "extends": "./tsconfig.dev", "compilerOptions": { "noEmit": false } From 6d717f2e5541c04ea6202adebaa108177d7e9834 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Wed, 2 Nov 2022 14:08:32 +1100 Subject: [PATCH 19/23] tests: all files in `tests` are actually node only Except for a live test that always fails. --- packages/create/package.json | 8 ---- packages/tests/karma.conf.cjs | 55 ------------------------- packages/tests/package.json | 9 ---- packages/tests/tests/relay.node.spec.ts | 2 +- packages/tests/tests/waku.spec.ts | 42 ------------------- 5 files changed, 1 insertion(+), 115 deletions(-) delete mode 100644 packages/tests/karma.conf.cjs delete mode 100644 packages/tests/tests/waku.spec.ts diff --git a/packages/create/package.json b/packages/create/package.json index ec25796597..02b0fb8d36 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -2,7 +2,6 @@ "name": "@waku/create", "version": "0.0.1", "description": "Easily create a Waku node", - "main": "./dist/index.js", "types": "./dist/index.d.ts", "module": "./dist/index.js", "exports": { @@ -11,13 +10,6 @@ "import": "./dist/index.js" } }, - "typesVersions": { - "*": { - "lib/*": [ - "dist/lib/*" - ] - } - }, "type": "module", "author": "Waku Team", "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/create#readme", diff --git a/packages/tests/karma.conf.cjs b/packages/tests/karma.conf.cjs deleted file mode 100644 index daa7293fc1..0000000000 --- a/packages/tests/karma.conf.cjs +++ /dev/null @@ -1,55 +0,0 @@ -process.env.CHROME_BIN = require("puppeteer").executablePath(); -const webpack = require("webpack"); - -module.exports = function (config) { - config.set({ - frameworks: ["webpack", "mocha"], - files: ["tests/**/!(node).spec.ts"], - preprocessors: { - "tests/**/!(node).spec.ts": ["webpack"], - }, - envPreprocessor: ["CI"], - reporters: ["progress"], - browsers: ["ChromeHeadless"], - singleRun: true, - client: { - mocha: { - timeout: 6000, // Default is 2s - }, - }, - webpack: { - mode: "production", - module: { - rules: [ - { - test: /\.(js|tsx?)$/, - use: [ - { - loader: "ts-loader", - options: { configFile: "tsconfig.karma.json" }, - }, - ], - exclude: /(node_modules)|(node\.spec\.ts)/, - }, - { - test: /node\.spec\.ts$/, - use: "ignore-loader", - }, - ], - }, - plugins: [ - new webpack.DefinePlugin({ - "process.env.CI": process.env.CI || false, - }), - new webpack.ProvidePlugin({ - process: "process/browser.js", - }), - ], - resolve: { - extensions: [".ts", ".js"], - }, - stats: { warnings: false }, - devtool: "inline-source-map", - }, - }); -}; diff --git a/packages/tests/package.json b/packages/tests/package.json index ee663da492..50056b14b3 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -3,7 +3,6 @@ "private": true, "version": "0.0.1", "description": "Waku tests", - "main": "./dist/index.js", "types": "./dist/index.d.ts", "module": "./dist/index.js", "exports": { @@ -12,13 +11,6 @@ "import": "./dist/index.js" } }, - "typesVersions": { - "*": { - "lib/*": [ - "dist/lib/*" - ] - } - }, "type": "module", "author": "Waku Team", "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/tests#readme", @@ -57,7 +49,6 @@ "check:tsc": "tsc -p tsconfig.json", "test": "run-s test:*", "test:node": "TS_NODE_PROJECT=./tsconfig.json mocha", - "test:browser": "karma start karma.conf.cjs", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" }, "engines": { diff --git a/packages/tests/tests/relay.node.spec.ts b/packages/tests/tests/relay.node.spec.ts index bab30edce3..cef9e21c88 100644 --- a/packages/tests/tests/relay.node.spec.ts +++ b/packages/tests/tests/relay.node.spec.ts @@ -1,6 +1,6 @@ import { PeerId } from "@libp2p/interface-peer-id"; -import { DefaultPubSubTopic } from "@waku/core"; import { + DefaultPubSubTopic, generatePrivateKey, generateSymmetricKey, getPublicKey, diff --git a/packages/tests/tests/waku.spec.ts b/packages/tests/tests/waku.spec.ts deleted file mode 100644 index a55da2c16e..0000000000 --- a/packages/tests/tests/waku.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { PeerId } from "@libp2p/interface-peer-id"; -import { createLightNode } from "@waku/create"; -import type { WakuLight } from "@waku/interfaces"; -import { expect } from "chai"; - -describe("Waku Dial", function () { - describe("Bootstrap [live data]", function () { - let waku: WakuLight; - - afterEach(function () { - !!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e)); - }); - - before(function () { - if (process.env.CI) { - this.skip(); - } - }); - - it("Enabling default [live data]", async function () { - // This test depends on fleets.status.im being online. - // This dependence must be removed once DNS discovery is implemented - this.timeout(20_000); - - waku = await createLightNode({ - defaultBootstrap: true, - }); - await waku.start(); - - const connectedPeerID: PeerId = await new Promise((resolve) => { - waku.libp2p.connectionManager.addEventListener( - "peer:connect", - (evt) => { - resolve(evt.detail.remotePeer); - } - ); - }); - - expect(connectedPeerID).to.not.be.undefined; - }); - }); -}); From 5df320de32572479281a7eea2ea0439ef264a37c Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Wed, 2 Nov 2022 14:11:21 +1100 Subject: [PATCH 20/23] chore: must always build first now --- .github/workflows/ci.yml | 8 +++++--- bors.toml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e72d535d1b..90acc57d56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ env: NODE_JS: "16" jobs: - build: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -52,6 +52,7 @@ jobs: with: node-version: ${{ env.NODE_JS }} - uses: bahmutov/npm-install@v1 + - run: npm run build - run: npm run test:browser node: @@ -75,6 +76,7 @@ jobs: with: node-version: ${{ env.NODE_JS }} - uses: bahmutov/npm-install@v1 + - run: npm run build - run: npm run test:node env: DEBUG: "waku:nwaku*,waku:test*" @@ -121,7 +123,7 @@ jobs: node-version: ${{ env.NODE_JS }} - uses: bahmutov/npm-install@v1 - + - run: npm run build - run: npm run test:node env: DEBUG: "waku:nwaku*,waku:test*" @@ -137,7 +139,7 @@ jobs: name: Release runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' - needs: [build, proto, browser, node] + needs: [check, proto, browser, node] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/bors.toml b/bors.toml index 90e7fb8db6..b5274599df 100644 --- a/bors.toml +++ b/bors.toml @@ -1,5 +1,5 @@ status = [ - "build", + "check", "proto", "browser", "node", From ef2475ffb8a3742aba56ed900c9db1faea3f5cf4 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Wed, 2 Nov 2022 14:20:20 +1100 Subject: [PATCH 21/23] chore: fix size-limit --- .size-limit.cjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.size-limit.cjs b/.size-limit.cjs index 64b384d8de..9d4a1b12c8 100644 --- a/.size-limit.cjs +++ b/.size-limit.cjs @@ -7,11 +7,11 @@ module.exports = [ { name: "Waku default setup", path: [ - "packages/core/bundle/index.js", - "packages/core/bundle/lib/create_waku.js", + "packages/create/bundle/index.js", + "packages/core/bundle/lib/wait_for_remote_peer.js" ], import: { - "./packages/core/bundle/lib/create_waku.js": "{ createLightNode }", + "./packages/create/bundle/index.js": "{ createLightNode }", "./packages/core/bundle/lib/wait_for_remote_peer.js": "{ waitForRemotePeer }", "./packages/core/bundle/lib/waku_message/version_0.js": From 69c94db23a38a53fe4fbed4e349416c0fa97a332 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Wed, 2 Nov 2022 15:05:12 +1100 Subject: [PATCH 22/23] chore: fix doc --- .gitignore | 1 + ci/deploy.js | 51 +++++++++++--------- package-lock.json | 9 +--- package.json | 4 +- packages/core/package.json | 7 ++- packages/core/typedoc.json | 21 -------- packages/create/package.json | 10 ++-- packages/create/src/index.ts | 2 - packages/interfaces/package.json | 6 +-- packages/interfaces/src/index.ts | 2 - packages/interfaces/typedoc.json | 10 ---- packages/tests/package.json | 4 +- packages/create/typedoc.json => typedoc.json | 5 +- 13 files changed, 50 insertions(+), 82 deletions(-) delete mode 100644 packages/core/typedoc.json delete mode 100644 packages/interfaces/typedoc.json rename packages/create/typedoc.json => typedoc.json (50%) diff --git a/.gitignore b/.gitignore index ac07995727..038613d5b3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ src/**.js coverage *.log *.tsbuildinfo +docs diff --git a/ci/deploy.js b/ci/deploy.js index e8672c0a15..c49b5e91ce 100644 --- a/ci/deploy.js +++ b/ci/deploy.js @@ -1,40 +1,45 @@ -import { promisify } from 'util' -import { publish } from 'gh-pages' +import { promisify } from "util"; + +import { publish } from "gh-pages"; /* fix for "Unhandled promise rejections" */ -process.on('unhandledRejection', err => { throw err }) +process.on("unhandledRejection", (err) => { + throw err; +}); -const ghpublish = promisify(publish) +const ghpublish = promisify(publish); -const Args = process.argv.slice(2) -const USE_HTTPS = Args[0] && Args[0].toUpperCase() === 'HTTPS' +const Args = process.argv.slice(2); +const USE_HTTPS = Args[0] && Args[0].toUpperCase() === "HTTPS"; -const branch = 'gh-pages' -const org = 'waku-org' -const repo = 'js-waku' +const branch = "gh-pages"; +const org = "waku-org"; +const repo = "js-waku"; /* use SSH auth by default */ let repoUrl = USE_HTTPS ? `https://github.com/${org}/${repo}.git` - : `git@github.com:${org}/${repo}.git` + : `git@github.com:${org}/${repo}.git`; /* alternative auth using GitHub user and API token */ if (typeof process.env.GH_USER !== "undefined") { - repoUrl = ( - 'https://' + process.env.GH_USER + - ':' + process.env.GH_TOKEN + - '@' + `github.com/${org}/${repo}.git` - ) + repoUrl = + "https://" + + process.env.GH_USER + + ":" + + process.env.GH_TOKEN + + "@" + + `github.com/${org}/${repo}.git`; } -const main = async (url, branch)=> { - console.log(`Pushing to: ${url}`) - console.log(`On branch: ${branch}`) - await ghpublish('build/docs', { +const main = async (url, branch) => { + console.log(`Pushing to: ${url}`); + console.log(`On branch: ${branch}`); + await ghpublish("docs", { repo: url, branch: branch, dotfiles: true, - silent: false - }) -} + silent: false, + }); +}; -main(repoUrl, branch) +main(repoUrl, branch); diff --git a/package-lock.json b/package-lock.json index c654affc37..bf113920af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,8 @@ "husky": "^8.0.1", "lerna": "^6.0.1", "lint-staged": "^13.0.3", - "size-limit": "^8.1.0" + "size-limit": "^8.1.0", + "typedoc": "^0.23.19" } }, "node_modules/@achingbrain/ip-address": { @@ -22433,7 +22434,6 @@ "tail": "^2.2.0", "ts-loader": "^9.3.1", "ts-node": "^10.9.1", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "engines": { @@ -22510,7 +22510,6 @@ "rollup": "^2.75.0", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "engines": { @@ -22549,7 +22548,6 @@ "prettier": "^2.1.1", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "engines": { @@ -26919,7 +26917,6 @@ "tail": "^2.2.0", "ts-loader": "^9.3.1", "ts-node": "^10.9.1", - "typedoc": "^0.23.10", "typescript": "^4.6.3", "uint8arraylist": "^2.3.2", "uint8arrays": "^3.0.0", @@ -26984,7 +26981,6 @@ "rollup": "^2.75.0", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", - "typedoc": "^0.23.10", "typescript": "^4.6.3" } }, @@ -27016,7 +27012,6 @@ "prettier": "^2.1.1", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "dependencies": { diff --git a/package.json b/package.json index dcd72a79f2..8390460ad6 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "test:browser": "lerna run test:browser", "test:node": "lerna run test:node", "proto": "lerna run proto", - "doc": "lerna run doc", + "doc": "run-s doc:*", + "doc:html": "typedoc # --treatWarningsAsErrors", + "doc:cname": "echo 'js.waku.org' > docs/CNAME", "release": "lerna run --concurrency 1 release -- --" }, "devDependencies": { diff --git a/packages/core/package.json b/packages/core/package.json index 488944f962..f49a3064f1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -94,9 +94,6 @@ "proto": "rimraf src/proto/*.ts; protons src/proto/*.proto", "watch:build": "tsc -p tsconfig.json -w", "watch:test": "mocha --watch", - "doc": "run-s doc:*", - "doc:html": "typedoc --treatWarningsAsErrors", - "doc:cname": "echo 'js.waku.org' > build/docs/CNAME", "prepublish": "npm run build", "deploy": "node ci/deploy.js", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", @@ -193,7 +190,6 @@ "tail": "^2.2.0", "ts-loader": "^9.3.1", "ts-node": "^10.9.1", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "release": { @@ -278,6 +274,9 @@ "@semantic-release/git" ] }, + "typedoc": { + "entryPoint": "./src/index.ts" + }, "files": [ "dist", "bundle", diff --git a/packages/core/typedoc.json b/packages/core/typedoc.json deleted file mode 100644 index 0e56836bb7..0000000000 --- a/packages/core/typedoc.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "entryPoints": [ - "./src/index.ts", - "./src/lib/enr/index.ts", - "./src/lib/peer_discovery_dns.ts", - "./src/lib/peer_discovery_static_list.ts", - "./src/lib/predefined_bootstrap_nodes.ts", - "./src/lib/utils.ts", - "./src/lib/wait_for_remote_peer.ts", - "./src/lib/waku_message/version_0.ts", - "./src/lib/waku_message/version_1.ts", - "./src/lib/waku_message/topic_only_message.ts" - ], - "out": "build/docs", - "exclude": ["**/*.spec.ts"], - "excludeInternal": true, - "validation": { - "invalidLink": true, - "notExported": true - } -} diff --git a/packages/create/package.json b/packages/create/package.json index 02b0fb8d36..c092b0bebe 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -43,8 +43,6 @@ "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.dev.json", - "doc": "run-s doc:*", - "doc:html": "typedoc --treatWarningsAsErrors", "prepublish": "npm run build", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", "release": "semantic-release" @@ -53,8 +51,8 @@ "node": ">=16" }, "dependencies": { - "@waku/interfaces": "*", - "@waku/core": "*" + "@waku/core": "*", + "@waku/interfaces": "*" }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.0", @@ -80,7 +78,6 @@ "rollup": "^2.75.0", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "release": { @@ -165,6 +162,9 @@ "@semantic-release/git" ] }, + "typedoc": { + "entryPoint": "./src/index.ts" + }, "files": [ "dist", "bundle", diff --git a/packages/create/src/index.ts b/packages/create/src/index.ts index 76fb399a89..89a6015f4e 100644 --- a/packages/create/src/index.ts +++ b/packages/create/src/index.ts @@ -32,8 +32,6 @@ export interface CreateOptions { * * The usage of the default pubsub topic is recommended. * See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/) for details. - * - * @default {@link index.DefaultPubSubTopic} */ pubSubTopic?: string; /** diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 5d5703167d..79abebd2e3 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -41,8 +41,6 @@ "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.dev.json", - "doc": "run-s doc:*", - "doc:html": "typedoc --treatWarningsAsErrors", "prepublish": "npm run build", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", "release": "semantic-release" @@ -78,7 +76,6 @@ "prettier": "^2.1.1", "semantic-release": "^19.0.5", "semantic-release-monorepo": "^7.0.5", - "typedoc": "^0.23.10", "typescript": "^4.6.3" }, "release": { @@ -163,6 +160,9 @@ "@semantic-release/git" ] }, + "typedoc": { + "entryPoint": "./src/index.ts" + }, "files": [ "dist", "bundle", diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts index 0538cca2fe..f95555a6aa 100644 --- a/packages/interfaces/src/index.ts +++ b/packages/interfaces/src/index.ts @@ -67,8 +67,6 @@ export type StoreQueryOptions = { pageDirection?: PageDirection; /** * The number of message per page. - * - * @default { @link DefaultPageSize } */ pageSize?: number; /** diff --git a/packages/interfaces/typedoc.json b/packages/interfaces/typedoc.json deleted file mode 100644 index 1b4aa6af86..0000000000 --- a/packages/interfaces/typedoc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "entryPoints": ["./src/index.ts"], - "out": "build/docs", - "exclude": ["**/*.spec.ts"], - "excludeInternal": true, - "validation": { - "invalidLink": true, - "notExported": true - } -} diff --git a/packages/tests/package.json b/packages/tests/package.json index 50056b14b3..296fb881e8 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -55,9 +55,9 @@ "node": ">=16" }, "dependencies": { - "@waku/interfaces": "*", "@waku/core": "*", - "@waku/create": "*" + "@waku/create": "*", + "@waku/interfaces": "*" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.8.1", diff --git a/packages/create/typedoc.json b/typedoc.json similarity index 50% rename from packages/create/typedoc.json rename to typedoc.json index 1b4aa6af86..c381a4fcb7 100644 --- a/packages/create/typedoc.json +++ b/typedoc.json @@ -1,6 +1,7 @@ { - "entryPoints": ["./src/index.ts"], - "out": "build/docs", + "entryPointStrategy": "packages", + "entryPoints": ["packages/core", "packages/interfaces", "packages/create"], + "out": "docs", "exclude": ["**/*.spec.ts"], "excludeInternal": true, "validation": { From 613ba08fc23ebf90cf95fc201f2e6d3da1cf25ae Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Wed, 2 Nov 2022 15:17:02 +1100 Subject: [PATCH 23/23] chore: fix doc --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8390460ad6..e596fd9995 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "husky": "^8.0.1", "lerna": "^6.0.1", "lint-staged": "^13.0.3", - "size-limit": "^8.1.0" + "size-limit": "^8.1.0", + "typedoc": "^0.23.19" }, "lint-staged": { "*.ts": [