mirror of https://github.com/waku-org/js-waku.git
Merge pull request #990 from waku-org/feat/split-create-waku
This commit is contained in:
commit
39ae77ea07
|
@ -21,19 +21,10 @@ jobs:
|
|||
with:
|
||||
node-version: ${{ env.NODE_JS }}
|
||||
- uses: bahmutov/npm-install@v1
|
||||
- run: npm run build
|
||||
- run: npm run check
|
||||
- run: npm run doc
|
||||
|
||||
build:
|
||||
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 build
|
||||
|
||||
proto:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -61,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:
|
||||
|
@ -84,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*"
|
||||
|
@ -130,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*"
|
||||
|
@ -146,7 +139,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: [check, proto, browser, node]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
|
|
@ -8,3 +8,4 @@ src/**.js
|
|||
coverage
|
||||
*.log
|
||||
*.tsbuildinfo
|
||||
docs
|
||||
|
|
|
@ -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":
|
||||
|
|
51
ci/deploy.js
51
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);
|
||||
|
|
|
@ -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": {
|
||||
|
@ -5275,6 +5276,18 @@
|
|||
"resolved": "packages/core",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@waku/create": {
|
||||
"resolved": "packages/create",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@waku/interfaces": {
|
||||
"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",
|
||||
|
@ -22353,6 +22366,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",
|
||||
|
@ -22420,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": {
|
||||
|
@ -22464,6 +22477,163 @@
|
|||
"node": ">=16.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"packages/create": {
|
||||
"name": "@waku/create",
|
||||
"version": "0.0.1",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@waku/core": "*",
|
||||
"@waku/interfaces": "*"
|
||||
},
|
||||
"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",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"packages/interfaces": {
|
||||
"name": "@waku/interfaces",
|
||||
"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.38.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",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"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/@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/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/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"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
|
@ -26703,6 +26873,7 @@
|
|||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||
"@typescript-eslint/parser": "^5.8.1",
|
||||
"@waku/interfaces": "*",
|
||||
"app-root-path": "^3.0.0",
|
||||
"chai": "^4.3.4",
|
||||
"cspell": "^5.14.0",
|
||||
|
@ -26742,11 +26913,10 @@
|
|||
"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",
|
||||
"typedoc": "^0.23.10",
|
||||
"typescript": "^4.6.3",
|
||||
"uint8arraylist": "^2.3.2",
|
||||
"uint8arrays": "^3.0.0",
|
||||
|
@ -26783,6 +26953,128 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@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",
|
||||
"@waku/core": "*",
|
||||
"@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",
|
||||
"rollup": "^2.75.0",
|
||||
"semantic-release": "^19.0.5",
|
||||
"semantic-release-monorepo": "^7.0.5",
|
||||
"typescript": "^4.6.3"
|
||||
}
|
||||
},
|
||||
"@waku/interfaces": {
|
||||
"version": "file:packages/interfaces",
|
||||
"requires": {
|
||||
"@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",
|
||||
"@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",
|
||||
"libp2p": "0.38.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.1.1",
|
||||
"semantic-release": "^19.0.5",
|
||||
"semantic-release-monorepo": "^7.0.5",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@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"
|
||||
}
|
||||
},
|
||||
"@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"
|
||||
}
|
||||
},
|
||||
"multiformats": {
|
||||
"version": "10.0.2",
|
||||
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz",
|
||||
"integrity": "sha512-nJEHLFOYhO4L+aNApHhCnWqa31FyqAHv9Q77AhmwU3KsM2f1j7tuJpCk5ByZ33smzycNCpSG5klNIejIyfFx2A=="
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@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",
|
||||
|
|
|
@ -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": {
|
||||
|
@ -22,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": [
|
||||
|
|
|
@ -9,12 +9,9 @@
|
|||
"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"
|
||||
"./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",
|
||||
|
@ -28,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"
|
||||
|
@ -83,19 +84,16 @@
|
|||
"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",
|
||||
"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",
|
||||
|
@ -124,6 +122,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",
|
||||
|
@ -191,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": {
|
||||
|
@ -207,7 +205,7 @@
|
|||
"releaseRules": [
|
||||
{
|
||||
"breaking": true,
|
||||
"release": "major"
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"revert": true,
|
||||
|
@ -215,7 +213,7 @@
|
|||
},
|
||||
{
|
||||
"type": "feat",
|
||||
"release": "minor"
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"type": "fix",
|
||||
|
@ -276,6 +274,9 @@
|
|||
"@semantic-release/git"
|
||||
]
|
||||
},
|
||||
"typedoc": {
|
||||
"entryPoint": "./src/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bundle",
|
||||
|
|
|
@ -5,10 +5,11 @@ import json from "@rollup/plugin-json";
|
|||
export default {
|
||||
input: {
|
||||
index: "dist/index.js",
|
||||
"lib/create_waku": "dist/lib/create_waku.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",
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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<Stream>;
|
||||
|
||||
addPeerToAddressBook(
|
||||
peerId: PeerId | string,
|
||||
multiaddrs: Multiaddr[] | string[]
|
||||
): void;
|
||||
|
||||
start(): Promise<void>;
|
||||
|
||||
stop(): Promise<void>;
|
||||
|
||||
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<Message>) => Promise<Uint8Array | undefined>;
|
||||
toProtoObj: (message: Partial<Message>) => Promise<ProtoMessage | undefined>;
|
||||
}
|
||||
|
||||
export interface Decoder<T extends Message> {
|
||||
contentTopic: string;
|
||||
fromWireToProtoObj: (bytes: Uint8Array) => Promise<ProtoMessage | undefined>;
|
||||
fromProtoObj: (proto: ProtoMessage) => Promise<T | undefined>;
|
||||
}
|
||||
|
||||
export interface SendResult {
|
||||
recipients: PeerId[];
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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<Peer[]>;
|
||||
}
|
||||
|
||||
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<void> {
|
||||
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<void> {
|
||||
async function waitForGossipSubPeerInMesh(waku: Relay): Promise<void> {
|
||||
let peers = waku.getMeshPeers();
|
||||
|
||||
while (peers.length == 0) {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { createWaku } from "./create_waku";
|
||||
import type { Waku } from "./interfaces";
|
||||
|
||||
describe("Waku Dial", function () {
|
||||
describe("Bootstrap [live data]", function () {
|
||||
let waku: Waku;
|
||||
|
||||
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 createWaku({
|
||||
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;
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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`
|
||||
|
|
|
@ -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<T extends Message> = (
|
||||
msg: T
|
||||
) => void | Promise<void>;
|
||||
|
||||
export type UnsubscribeFunction = () => Promise<void>;
|
||||
|
||||
/**
|
||||
|
@ -63,9 +54,9 @@ export type UnsubscribeFunction = () => Promise<void>;
|
|||
* - 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<string, FilterCallback<any>>;
|
||||
private subscriptions: Map<string, Callback<any>>;
|
||||
private decoders: Map<
|
||||
string, // content topic
|
||||
Set<Decoder<any>>
|
||||
|
@ -88,10 +79,10 @@ export class WakuFilter {
|
|||
*/
|
||||
async subscribe<T extends Message>(
|
||||
decoders: Decoder<T>[],
|
||||
callback: FilterCallback<T>,
|
||||
opts?: FilterSubscriptionOpts
|
||||
callback: Callback<T>,
|
||||
opts?: ProtocolOptions
|
||||
): Promise<UnsubscribeFunction> {
|
||||
const topic = opts?.pubsubTopic ?? this.pubSubTopic;
|
||||
const topic = opts?.pubSubTopic ?? this.pubSubTopic;
|
||||
|
||||
const groupedDecoders = groupByContentTopic(decoders);
|
||||
const contentTopics = Array.from(groupedDecoders.keys());
|
||||
|
@ -212,7 +203,7 @@ export class WakuFilter {
|
|||
}
|
||||
}
|
||||
|
||||
private addCallback(requestId: string, callback: FilterCallback<any>): void {
|
||||
private addCallback(requestId: string, callback: Callback<any>): void {
|
||||
this.subscriptions.set(requestId, callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 +54,7 @@ export class WakuLightPush {
|
|||
async push(
|
||||
encoder: Encoder,
|
||||
message: Partial<Message>,
|
||||
opts?: PushOptions
|
||||
opts?: ProtocolOptions
|
||||
): Promise<SendResult> {
|
||||
const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic;
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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<T extends Message> = (msg: T) => void;
|
||||
|
||||
export type Observer<T extends Message> = {
|
||||
decoder: Decoder<T>;
|
||||
callback: Callback<T>;
|
||||
|
@ -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<Message>;
|
||||
public static multicodec: string = constants.RelayCodecs[0];
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"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",
|
||||
"./src/lib/predefined_bootstrap_nodes.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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: "./tsconfig.dev.json",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
|
@ -0,0 +1,180 @@
|
|||
{
|
||||
"name": "@waku/create",
|
||||
"version": "0.0.1",
|
||||
"description": "Easily create a Waku node",
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@waku/core": "*",
|
||||
"@waku/interfaces": "*"
|
||||
},
|
||||
"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",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"release": {
|
||||
"branches": [
|
||||
"master"
|
||||
],
|
||||
"extends": "semantic-release-monorepo",
|
||||
"plugins": [
|
||||
[
|
||||
"@semantic-release/commit-analyzer",
|
||||
{
|
||||
"preset": "conventionalcommits",
|
||||
"releaseRules": [
|
||||
{
|
||||
"breaking": true,
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"revert": true,
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"type": "feat",
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"typedoc": {
|
||||
"entryPoint": "./src/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bundle",
|
||||
"src/*.ts",
|
||||
"src/lib/**/*.ts",
|
||||
"src/proto/**/*.ts",
|
||||
"!**/*.spec.*",
|
||||
"!**/*.json",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
]
|
||||
}
|
|
@ -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,
|
||||
}),
|
||||
],
|
||||
};
|
|
@ -3,17 +3,23 @@ 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 {
|
||||
waku,
|
||||
waku_relay,
|
||||
WakuFilter,
|
||||
WakuLightPush,
|
||||
WakuNode,
|
||||
WakuRelay,
|
||||
WakuStore,
|
||||
} from "@waku/core";
|
||||
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";
|
||||
|
||||
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";
|
||||
type WakuOptions = waku.WakuOptions;
|
||||
type RelayCreateOptions = waku_relay.CreateOptions;
|
||||
|
||||
export interface CreateOptions {
|
||||
/**
|
||||
|
@ -26,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;
|
||||
/**
|
||||
|
@ -139,35 +143,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<RelayCreateOptions>
|
||||
): Promise<Waku> {
|
||||
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());
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"noEmit": true
|
||||
},
|
||||
"exclude": []
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: "./tsconfig.dev.json",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
|
@ -0,0 +1,178 @@
|
|||
{
|
||||
"name": "@waku/interfaces",
|
||||
"version": "0.0.1",
|
||||
"description": "Definition of Waku interfaces",
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"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": "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",
|
||||
"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"
|
||||
},
|
||||
"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",
|
||||
"@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",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"release": {
|
||||
"branches": [
|
||||
"master"
|
||||
],
|
||||
"extends": "semantic-release-monorepo",
|
||||
"plugins": [
|
||||
[
|
||||
"@semantic-release/commit-analyzer",
|
||||
{
|
||||
"preset": "conventionalcommits",
|
||||
"releaseRules": [
|
||||
{
|
||||
"breaking": true,
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"revert": true,
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"type": "feat",
|
||||
"release": "patch"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"typedoc": {
|
||||
"entryPoint": "./src/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bundle",
|
||||
"src/*.ts",
|
||||
"src/lib/**/*.ts",
|
||||
"src/proto/**/*.ts",
|
||||
"!**/*.spec.*",
|
||||
"!**/*.json",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
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";
|
||||
|
||||
export enum Protocols {
|
||||
Relay = "relay",
|
||||
Store = "store",
|
||||
LightPush = "lightpush",
|
||||
Filter = "filter",
|
||||
}
|
||||
|
||||
export interface PointToPointProtocol {
|
||||
libp2p: Libp2p;
|
||||
peers: () => Promise<Peer[]>;
|
||||
}
|
||||
|
||||
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<T extends Message> = (msg: T) => void | Promise<void>;
|
||||
|
||||
export interface Filter extends PointToPointProtocol {
|
||||
subscribe: <T extends Message>(
|
||||
decoders: Decoder<T>[],
|
||||
callback: Callback<T>,
|
||||
opts?: ProtocolOptions
|
||||
) => Promise<() => Promise<void>>;
|
||||
}
|
||||
|
||||
export interface LightPush extends PointToPointProtocol {
|
||||
push: (
|
||||
encoder: Encoder,
|
||||
message: Partial<Message>,
|
||||
opts?: ProtocolOptions
|
||||
) => Promise<SendResult>;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* Retrieve messages with a timestamp within the provided values.
|
||||
*/
|
||||
timeFilter?: TimeFilter;
|
||||
} & ProtocolOptions;
|
||||
|
||||
export interface Store extends PointToPointProtocol {
|
||||
queryOrderedCallback: <T extends Message>(
|
||||
decoders: Decoder<T>[],
|
||||
callback: (message: T) => Promise<void | boolean> | boolean | void,
|
||||
options?: StoreQueryOptions
|
||||
) => Promise<void>;
|
||||
queryCallbackOnPromise: <T extends Message>(
|
||||
decoders: Decoder<T>[],
|
||||
callback: (
|
||||
message: Promise<T | undefined>
|
||||
) => Promise<void | boolean> | boolean | void,
|
||||
options?: StoreQueryOptions
|
||||
) => Promise<void>;
|
||||
queryGenerator: <T extends Message>(
|
||||
decoders: Decoder<T>[],
|
||||
options?: StoreQueryOptions
|
||||
) => AsyncGenerator<Promise<T | undefined>[]>;
|
||||
}
|
||||
|
||||
export interface Relay extends GossipSub {
|
||||
send: (encoder: Encoder, message: Partial<Message>) => Promise<SendResult>;
|
||||
addObserver: <T extends Message>(
|
||||
decoder: Decoder<T>,
|
||||
callback: Callback<T>
|
||||
) => () => void;
|
||||
getMeshPeers: () => string[];
|
||||
}
|
||||
|
||||
export interface Waku {
|
||||
libp2p: Libp2p;
|
||||
relay?: Relay;
|
||||
store?: Store;
|
||||
filter?: Filter;
|
||||
lightPush?: LightPush;
|
||||
|
||||
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
||||
|
||||
addPeerToAddressBook(
|
||||
peerId: PeerId | string,
|
||||
multiaddrs: Multiaddr[] | string[]
|
||||
): void;
|
||||
|
||||
start(): Promise<void>;
|
||||
|
||||
stop(): Promise<void>;
|
||||
|
||||
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<Message>) => Promise<Uint8Array | undefined>;
|
||||
toProtoObj: (message: Partial<Message>) => Promise<ProtoMessage | undefined>;
|
||||
}
|
||||
|
||||
export interface Decoder<T extends Message> {
|
||||
contentTopic: string;
|
||||
fromWireToProtoObj: (bytes: Uint8Array) => Promise<ProtoMessage | undefined>;
|
||||
fromProtoObj: (proto: ProtoMessage) => Promise<T | undefined>;
|
||||
}
|
||||
|
||||
export interface SendResult {
|
||||
recipients: PeerId[];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"noEmit": true
|
||||
},
|
||||
"exclude": []
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
module.exports = {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: "./tsconfig.dev.json",
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extension": ["ts"],
|
||||
"spec": "tests/*.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
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"name": "@waku/tests",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"description": "Waku tests",
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"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": "tsc",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"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: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:*",
|
||||
"test:node": "TS_NODE_PROJECT=./tsconfig.json mocha",
|
||||
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
|
@ -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 =
|
|
@ -1,15 +1,14 @@
|
|||
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 { createWaku } from "../create_waku";
|
||||
import type { Waku } from "../interfaces";
|
||||
import { waitForRemotePeer } from "../wait_for_remote_peer";
|
||||
import { Protocols } from "../waku";
|
||||
|
||||
import { ENR } from "./enr";
|
||||
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
|
||||
|
||||
describe("ENR Interop: nwaku", function () {
|
||||
let waku: Waku;
|
||||
let waku: WakuPrivacy;
|
||||
let nwaku: Nwaku;
|
||||
|
||||
afterEach(async function () {
|
||||
|
@ -28,10 +27,12 @@ describe("ENR Interop: nwaku", function () {
|
|||
});
|
||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||
|
||||
waku = await createWaku({
|
||||
waku = await createPrivacyNode({
|
||||
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]);
|
||||
|
||||
|
@ -60,10 +61,12 @@ describe("ENR Interop: nwaku", function () {
|
|||
});
|
||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||
|
||||
waku = await createWaku({
|
||||
waku = await createPrivacyNode({
|
||||
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]);
|
||||
|
||||
|
@ -92,10 +95,12 @@ describe("ENR Interop: nwaku", function () {
|
|||
});
|
||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||
|
||||
waku = await createWaku({
|
||||
waku = await createPrivacyNode({
|
||||
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]);
|
||||
|
|
@ -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 { 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";
|
||||
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]);
|
||||
});
|
|
@ -1,3 +1,9 @@
|
|||
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";
|
||||
import { expect } from "chai";
|
||||
import debug from "debug";
|
||||
|
||||
|
@ -6,14 +12,8 @@ import {
|
|||
MessageRpcResponse,
|
||||
NOISE_KEY_1,
|
||||
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";
|
||||
} 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]);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName } from "./log_file";
|
||||
import { makeLogFileName } from "../src";
|
||||
|
||||
describe("This", function () {
|
||||
describe("Is", function () {
|
|
@ -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 () {
|
|
@ -1,4 +1,26 @@
|
|||
import { PeerId } from "@libp2p/interface-peer-id";
|
||||
import {
|
||||
DefaultPubSubTopic,
|
||||
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";
|
||||
import { expect } from "chai";
|
||||
import debug from "debug";
|
||||
|
||||
|
@ -9,26 +31,8 @@ import {
|
|||
NOISE_KEY_2,
|
||||
NOISE_KEY_3,
|
||||
Nwaku,
|
||||
} 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,
|
||||
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),
|
||||
]);
|
||||
|
|
@ -1,31 +1,25 @@
|
|||
import { expect } from "chai";
|
||||
import debug from "debug";
|
||||
|
||||
import {
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
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";
|
||||
} 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_message/version_1.js";
|
||||
} 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 { 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]);
|
||||
|
|
@ -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 { createLightNode, createPrivacyNode } from "./create_waku";
|
||||
import type { WakuLight, WakuPrivacy } from "./interfaces";
|
||||
import { waitForRemotePeer } from "./wait_for_remote_peer";
|
||||
import { Protocols } from "./waku";
|
||||
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();
|
||||
|
|
@ -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 { createLightNode, createPrivacyNode } from "./create_waku";
|
||||
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";
|
||||
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()]),
|
||||
],
|
||||
},
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src", "tests"]
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"target": "es2020",
|
||||
"outDir": "dist/",
|
||||
"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": [],
|
||||
"compileOnSave": false,
|
||||
"ts-node": {
|
||||
"files": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"extends": "./tsconfig.dev",
|
||||
"compilerOptions": {
|
||||
"noEmit": false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"entryPointStrategy": "packages",
|
||||
"entryPoints": ["packages/core", "packages/interfaces", "packages/create"],
|
||||
"out": "docs",
|
||||
"exclude": ["**/*.spec.ts"],
|
||||
"excludeInternal": true,
|
||||
"validation": {
|
||||
"invalidLink": true,
|
||||
"notExported": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue