mirror of https://github.com/waku-org/js-waku.git
Merge pull request #987 from waku-org/chore/monorepo
This commit is contained in:
commit
fdd617de3c
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": { "project": "./tsconfig.dev.json" },
|
||||
"env": { "es6": true },
|
||||
"ignorePatterns": ["node_modules", "build", "coverage", "proto"],
|
||||
"plugins": ["import", "eslint-comments", "functional"],
|
||||
|
|
|
@ -21,11 +21,8 @@ jobs:
|
|||
with:
|
||||
node-version: ${{ env.NODE_JS }}
|
||||
- uses: bahmutov/npm-install@v1
|
||||
- run: npm run test:lint
|
||||
- run: npm run test:prettier
|
||||
- run: npm run test:spelling
|
||||
- run: npm run test:tsc
|
||||
- run: npm run doc:html
|
||||
- run: npm run check
|
||||
- run: npm run doc
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -102,7 +99,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_WAKU_VERSION: "0.2.2"
|
||||
WAKU_SERVICE_NODE_DIR: ./go-waku
|
||||
WAKU_SERVICE_NODE_DIR: ../../go-waku
|
||||
WAKU_SERVICE_NODE_BIN: ./waku
|
||||
WAKU_SERVICE_NODE_PARAMS: "--min-relay-peers-to-publish=0" # Can be removed once https://github.com/status-im/nwaku/issues/1004 is done
|
||||
DEBUG: "waku*"
|
||||
|
@ -123,6 +120,7 @@ jobs:
|
|||
shell: bash
|
||||
run: |
|
||||
uname -a
|
||||
cd packages/core
|
||||
cd "${WAKU_SERVICE_NODE_DIR}"
|
||||
"${WAKU_SERVICE_NODE_BIN}" --version
|
||||
|
||||
|
@ -143,27 +141,3 @@ jobs:
|
|||
with:
|
||||
name: go-waku-logs
|
||||
path: log/
|
||||
|
||||
release_next:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
needs: [check, build, proto, browser, node]
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_JS }}
|
||||
- uses: bahmutov/npm-install@v1
|
||||
|
||||
- name: Append git hash to version
|
||||
shell: bash
|
||||
run: |
|
||||
CURR_VERSION=$(cat package.json | jq .version | tr -d '"')
|
||||
GIT_HASH=$(git rev-parse --short HEAD)
|
||||
cat package.json| jq --arg version "$CURR_VERSION-$GIT_HASH" '.version |= $version' > _package.json
|
||||
mv -f _package.json package.json
|
||||
|
||||
- name: Authenticate with registry
|
||||
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ./.npmrc
|
||||
|
||||
- run: npm publish --tag next --access public
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: "Semantic PR"
|
||||
name: "Conventional PR"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
|
@ -16,9 +16,14 @@ jobs:
|
|||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
# fix: bug fix on prod code
|
||||
# feat: new feature on prod code
|
||||
# test: only modify test or test utils
|
||||
# doc: only modify docs/comments
|
||||
# chore: anything else
|
||||
types: |
|
||||
fix # Bug fix on prod code
|
||||
feat # New feature on prod code
|
||||
test # Only modify test or test utils
|
||||
doc # Only modify docs/comments
|
||||
chore # Anything else
|
||||
fix
|
||||
feat
|
||||
test
|
||||
doc
|
||||
chore
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
.idea/*
|
||||
.angular
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
src/**.js
|
||||
coverage
|
||||
*.log
|
||||
/tsconfig.tsbuildinfo
|
||||
/tsconfig.dev.tsbuildinfo
|
||||
/bundle/
|
||||
*.tsbuildinfo
|
||||
|
|
|
@ -1,42 +1,46 @@
|
|||
module.exports = [
|
||||
{
|
||||
name: "Waku core",
|
||||
path: "bundle/index.js",
|
||||
path: "packages/core/bundle/index.js",
|
||||
import: "{ WakuNode }",
|
||||
},
|
||||
{
|
||||
name: "Waku default setup",
|
||||
path: ["bundle/index.js", "bundle/lib/create_waku.js"],
|
||||
path: [
|
||||
"packages/core/bundle/index.js",
|
||||
"packages/core/bundle/lib/create_waku.js",
|
||||
],
|
||||
import: {
|
||||
"./bundle/lib/create_waku.js": "{ createLightNode }",
|
||||
"./bundle/lib/wait_for_remote_peer.js": "{ waitForRemotePeer }",
|
||||
"./bundle/lib/waku_message/version_0.js":
|
||||
"./packages/core/bundle/lib/create_waku.js": "{ createLightNode }",
|
||||
"./packages/core/bundle/lib/wait_for_remote_peer.js":
|
||||
"{ waitForRemotePeer }",
|
||||
"./packages/core/bundle/lib/waku_message/version_0.js":
|
||||
"{ MessageV0, DecoderV0, EncoderV0 }",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Asymmetric, symmetric encryption and signature",
|
||||
path: "bundle/lib/waku_message/version_1.js",
|
||||
path: "packages/core/bundle/lib/waku_message/version_1.js",
|
||||
import: "{ MessageV1, AsymEncoder, AsymDecoder, SymEncoder, SymDecoder }",
|
||||
},
|
||||
{
|
||||
name: "DNS discovery",
|
||||
path: "bundle/lib/peer_discovery_dns.js",
|
||||
path: "packages/core/bundle/lib/peer_discovery_dns.js",
|
||||
import: "{ PeerDiscoveryDns }",
|
||||
},
|
||||
{
|
||||
name: "Privacy preserving protocols",
|
||||
path: "bundle/index.js",
|
||||
path: "packages/core/bundle/index.js",
|
||||
import: "{ WakuRelay }",
|
||||
},
|
||||
{
|
||||
name: "Light protocols",
|
||||
path: "bundle/index.js",
|
||||
path: "packages/core/bundle/index.js",
|
||||
import: "{ WakuLightPush, WakuFilter }",
|
||||
},
|
||||
{
|
||||
name: "History retrieval protocols",
|
||||
path: "bundle/index.js",
|
||||
path: "packages/core/bundle/index.js",
|
||||
import: "{ WakuStore }",
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
## Examples
|
||||
|
||||
Moved to https://github.com/waku-org/js-waku-examples.
|
|
@ -1 +0,0 @@
|
|||
Moved to https://docs.wakuconnect.dev/docs/guides/
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"useWorkspaces": true,
|
||||
"version": "0.0.0"
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"tasksRunnerOptions": {
|
||||
"default": {
|
||||
"runner": "nx/tasks-runners/default",
|
||||
"options": {
|
||||
"cacheableOperations": [
|
||||
"build",
|
||||
"build:esm",
|
||||
"build:bundle",
|
||||
"fix",
|
||||
"fix:prettier",
|
||||
"fix:lint",
|
||||
"check",
|
||||
"check:lint",
|
||||
"check:prettier",
|
||||
"check:spelling",
|
||||
"check:tsc",
|
||||
"test",
|
||||
"test:node",
|
||||
"test:browser",
|
||||
"proto"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"targetDefaults": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["{projectRoot}/dist, {projectRoot}/bundle"]
|
||||
},
|
||||
"build:esm": {
|
||||
"dependsOn": ["^build:esm"],
|
||||
"outputs": ["{projectRoot}/dist"]
|
||||
},
|
||||
"build:bundle": {
|
||||
"dependsOn": ["^build:bundle"],
|
||||
"outputs": ["{projectRoot}/bundle"]
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
209
package.json
209
package.json
|
@ -1,208 +1,33 @@
|
|||
{
|
||||
"name": "js-waku",
|
||||
"version": "0.30.0",
|
||||
"description": "TypeScript implementation of the Waku v2 protocol",
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"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/peer_discovery_dns": {
|
||||
"types": "./dist/lib/peer_discovery_dns/index.d.ts",
|
||||
"import": "./dist/lib/peer_discovery_dns/index.js"
|
||||
},
|
||||
"./lib/peer_discovery_static_list": {
|
||||
"types": "./dist/lib/peer_discovery_static_list.d.ts",
|
||||
"import": "./dist/lib/peer_discovery_static_list.js"
|
||||
},
|
||||
"./lib/predefined_bootstrap_nodes": {
|
||||
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
|
||||
"import": "./dist/lib/predefined_bootstrap_nodes.js"
|
||||
},
|
||||
"./lib/wait_for_remote_peer": {
|
||||
"types": "./dist/lib/wait_for_remote_peer.d.ts",
|
||||
"import": "./dist/lib/wait_for_remote_peer.js"
|
||||
},
|
||||
"./lib/waku_message/version_0": {
|
||||
"types": "./dist/lib/waku_message/version_0.d.ts",
|
||||
"import": "./dist/lib/waku_message/version_0.js"
|
||||
},
|
||||
"./lib/waku_message/version_1": {
|
||||
"types": "./dist/lib/waku_message/version_1.d.ts",
|
||||
"import": "./dist/lib/waku_message/version_1.js"
|
||||
},
|
||||
"./lib/waku_message/topic_only_message": {
|
||||
"types": "./dist/lib/waku_message/topic_only_message.d.ts",
|
||||
"import": "./dist/lib/waku_message/topic_only_message.js"
|
||||
}
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"lib/*": [
|
||||
"dist/lib/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "module",
|
||||
"repository": "https://github.com/status-im/js-waku",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"keywords": [
|
||||
"waku",
|
||||
"decentralised",
|
||||
"communication",
|
||||
"web3",
|
||||
"ethereum",
|
||||
"dapps"
|
||||
"name": "root",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"build": "run-s build:**",
|
||||
"build:esm": "tsc && node build-scripts/fix-imports.js",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"build": "lerna run build",
|
||||
"size": "npm run build && size-limit",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.*js\" \".github/**/*.yml\" --write",
|
||||
"fix:lint": "eslint src --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": "(cd nwaku; make update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$(nproc --all 2>/dev/null || echo 2) wakunode2)",
|
||||
"nwaku:force-build": "(cd nwaku && rm -rf ./build/ ./vendor && make -j$(nproc --all 2>/dev/null || echo 2) update) && run-s nwaku:build",
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint src --ext .ts",
|
||||
"test:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.*js\" \".github/**/*.yml\" --list-different",
|
||||
"test:spelling": "cspell \"{README.md,.github/*.md,guides/*.md,src/**/*.ts}\"",
|
||||
"test:tsc": "tsc -p tsconfig.dev.json",
|
||||
"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"
|
||||
},
|
||||
"browser": {
|
||||
"crypto": false
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-gossipsub": "^4.1.1",
|
||||
"@chainsafe/libp2p-noise": "^8.0.1",
|
||||
"@ethersproject/rlp": "^5.5.0",
|
||||
"@libp2p/crypto": "^1.0.4",
|
||||
"@libp2p/interface-connection": "3.0.1",
|
||||
"@libp2p/interface-peer-discovery": "^1.0.0",
|
||||
"@libp2p/interface-peer-id": "^1.0.2",
|
||||
"@libp2p/interface-peer-info": "^1.0.1",
|
||||
"@libp2p/interface-peer-store": "^1.0.0",
|
||||
"@libp2p/interface-pubsub": "^2.0.1",
|
||||
"@libp2p/interfaces": "^3.0.2",
|
||||
"@libp2p/mplex": "^5.1.1",
|
||||
"@libp2p/peer-id": "^1.1.10",
|
||||
"@libp2p/websockets": "^3.0.3",
|
||||
"@multiformats/multiaddr": "^10.4.0",
|
||||
"@noble/secp256k1": "^1.3.4",
|
||||
"debug": "^4.3.4",
|
||||
"dns-query": "^0.11.2",
|
||||
"hi-base32": "^0.5.1",
|
||||
"it-all": "^1.0.6",
|
||||
"it-length-prefixed": "^8.0.2",
|
||||
"it-pipe": "^2.0.4",
|
||||
"js-sha3": "^0.8.0",
|
||||
"libp2p": "0.38.0",
|
||||
"p-event": "^5.0.1",
|
||||
"protons-runtime": "^3.1.0",
|
||||
"uint8arraylist": "^2.3.2",
|
||||
"uint8arrays": "^3.0.0",
|
||||
"uuid": "^8.3.2"
|
||||
"fix": "lerna run fix",
|
||||
"check": "lerna run check",
|
||||
"test": "lerna run test",
|
||||
"test:browser": "lerna run test:browser",
|
||||
"test:node": "lerna run test:node",
|
||||
"proto": "lerna run proto",
|
||||
"doc": "lerna run doc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@libp2p/peer-id-factory": "^1.0.15",
|
||||
"@rollup/plugin-commonjs": "^22.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||
"@size-limit/preset-big-lib": "^8.0.0",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/chai": "^4.2.15",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^17.0.6",
|
||||
"@types/tail": "^2.0.0",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||
"@typescript-eslint/parser": "^5.8.1",
|
||||
"app-root-path": "^3.0.0",
|
||||
"chai": "^4.3.4",
|
||||
"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",
|
||||
"fast-check": "^2.14.0",
|
||||
"gh-pages": "^3.2.3",
|
||||
"husky": "^7.0.4",
|
||||
"ignore-loader": "^0.1.2",
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"jsdom": "^19.0.0",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"karma": "^6.3.12",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-webpack": "^5.0.0",
|
||||
"@size-limit/preset-big-lib": "^8.1.0",
|
||||
"husky": "^8.0.1",
|
||||
"lerna": "^6.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"mocha": "^9.1.3",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"p-timeout": "^6.0.0",
|
||||
"portfinder": "^1.0.28",
|
||||
"prettier": "^2.1.1",
|
||||
"process": "^0.11.10",
|
||||
"protons": "^5.1.0",
|
||||
"puppeteer": "^13.0.1",
|
||||
"rollup": "^2.75.0",
|
||||
"size-limit": "^8.0.0",
|
||||
"tail": "^2.2.0",
|
||||
"ts-loader": "^9.3.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typedoc": "^0.23.10",
|
||||
"typescript": "^4.6.3"
|
||||
"size-limit": "^8.1.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bundle",
|
||||
"src/*.ts",
|
||||
"src/lib/**/*.ts",
|
||||
"src/proto/**/*.ts",
|
||||
"!**/*.spec.*",
|
||||
"!**/*.json",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"lint-staged": {
|
||||
"*.ts": [
|
||||
"eslint --fix"
|
||||
],
|
||||
"*.{ts,json,conf*.*js}": [
|
||||
"prettier --write"
|
||||
],
|
||||
"./*.*js": [
|
||||
"*.{ts,json,js}": [
|
||||
"prettier --write"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: "./tsconfig.dev.json",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
|
@ -292,19 +292,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.14.1] - 2021-10-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- Issue when importing the `utils` module.
|
||||
|
||||
## [0.14.0] - 2021-10-13
|
||||
|
||||
### Added
|
||||
|
||||
- If the `callback` function passed to`WakuStore.queryHistory` returns `true`, then no further pages are retrieved from the store.
|
||||
- Use webpack to build UMD bundle of the library, see [README](./README.md) for usage.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: Renamed `WakuStore.QueryOptions`'s `direction` to `pageDirection` (and its type) as it only affects the page ordering,
|
||||
not the ordering of messages with the page.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Docs: Ensure that `WakuStore`'s `QueryOptions` documentation is available [online](https://js-waku.wakuconnect.dev/).
|
||||
|
||||
## [0.13.1] - 2021-09-21
|
||||
|
@ -316,6 +320,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.13.0] - 2021-09-16
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrade libp2p libraries: @chainsafe/libp2p-noise@4.1.1, libp2p@0.32.4, libp2p-gossipsub@0.11.1.
|
||||
- Connects to a limited number of bootstrap nodes, defaults to 1.
|
||||
|
||||
|
@ -328,11 +333,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.12.1] - 2021-09-16
|
||||
|
||||
### Changed
|
||||
|
||||
- **hot fix**: Connects to a limited number of bootstrap nodes, defaults to 1.
|
||||
|
||||
## [0.12.0] - 2021-09-2
|
||||
|
||||
### Added
|
||||
|
||||
- Examples (eth-pm): Encrypt Public Key Messages using symmetric encryption.
|
||||
- Guides: Encrypt messages using Waku Message Version 1.
|
||||
- Allow passing decryption keys in hex string format.
|
||||
|
@ -341,22 +348,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `Waku.waitForConnectedPeer` helper to ensure that we are connected to Waku peers when using the bootstrap option.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: Moved `startTime` and `endTime` for history queries to a `timeFilter` property as both or neither must be passed; passing only one parameter is not supported.
|
||||
- Renamed and promote the usage of `generateSymmetricKey()` to generate random symmetric keys.
|
||||
- Improved errors thrown by `WakuStore.queryHistory`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Buffer concat error when using symmetric encryption in the browser.
|
||||
|
||||
## [0.11.0] - 2021-08-20
|
||||
|
||||
### Added
|
||||
|
||||
- Examples: New [Ethereum Private Message Using Wallet Encryption Web App](./examples/eth-pm-wallet-encryption/README.md)
|
||||
example that demonstrates the usage of `eth_encrypt` API (available on Metamask) and EIP-712 for typed structured data signing.
|
||||
- New `bootstrap` option for `Waku.create` to easily connect to Waku nodes upon start up.
|
||||
- Support for `startTime` and `endTime` in Store queries to filter by time window as per [21/WAKU2-FTSTORE](https://rfc.vac.dev/spec/21/).
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `discover.getStatusFleetNodes` to `discovery.getBootstrapNodes`;
|
||||
Changed the API to allow retrieval of bootstrap nodes from other sources.
|
||||
- Examples: Renamed `eth-dm` to `eth-pm`; "Direct Message" can lead to confusion with "Direct Connection" that
|
||||
|
@ -367,6 +378,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- **Breaking**: Rename all `pubsubTopic` occurrences to `pubSubTopic`, across all interfaces.
|
||||
|
||||
### Removed
|
||||
|
||||
- Examples (cli-chat): The focus of this library is Web environment;
|
||||
Several examples now cover usage of Waku Relay and Waku Store making cli-chat example obsolete;
|
||||
web-chat POC should be preferred to use the [TOY-CHAT](https://rfc.vac.dev/spec/22/) protocol.
|
||||
|
@ -378,32 +390,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.10.0] - 2021-08-06
|
||||
|
||||
### Added
|
||||
|
||||
- Relay and ReactJS guides and examples
|
||||
([#56](https://github.com/status-im/js-waku/issues/56)).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: The `WakuMessage` APIs have been changed to move `contentTopic` out of the optional parameters.
|
||||
- **Breaking**: Move `contentTopics` out the `WakuStore.queryHistory`'s optional parameters.
|
||||
- **Breaking**: `WakuStore.queryHistory` throws when encountering an error instead of returning a `null` value.
|
||||
|
||||
### Removed
|
||||
|
||||
- Examples (web-chat): Remove broken `/fleet` command.
|
||||
- **Breaking**: Removed `DefaultContentTopic` as developers must choose a content topic for their app;
|
||||
recommendations for content topic can be found at https://rfc.vac.dev/spec/23/.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `WakuMessage.payloadAsUtf8` returning garbage on utf-8 non-ascii characters.
|
||||
- `ChatMessage.payloadAsUtf8` returning garbage on utf-8 non-ascii characters.
|
||||
|
||||
## [0.9.0] - 2021-07-26
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: Store Response Protobuf changed to align with nim-waku v0.5
|
||||
([nim-waku#676](https://github.com/status-im/nim-waku/pull/676)).
|
||||
|
||||
## [0.8.1] - 2021-07-16
|
||||
|
||||
### Added
|
||||
|
||||
- Examples (web-chat): New `/fleet` command to switch connection between Status prod and test fleets.
|
||||
- Export `generatePrivateKey` and `getPublicKey` directly from the root.
|
||||
- Usage of the encryption and signature APIs to the readme.
|
||||
|
@ -411,6 +429,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
([#238](https://github.com/status-im/js-waku/issues/238)).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: Renamed `WakuRelay.(add|delete)PrivateDecryptionKey` to `WakuRelay.(add|delete)DecryptionKey` to make it clearer that it accepts both symmetric keys and asymmetric private keys.
|
||||
- Upgrade libp2p to 0.32.0.
|
||||
- **Breaking**: Rename `keepAlive` option to `pingKeepAlive`.
|
||||
|
@ -419,12 +438,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
([#185](https://github.com/status-im/js-waku/issues/185), [js-libp2p#939](https://github.com/libp2p/js-libp2p/issues/939))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Align `WakuMessage` readme example with actual code behaviour.
|
||||
- Remove infinite loop when an error with Waku Store is encountered.
|
||||
|
||||
## [0.8.0] - 2021-07-15
|
||||
|
||||
### Added
|
||||
|
||||
- `WakuRelay.deleteObserver` to allow removal of observers, useful when a React component add observers when mounting and needs to delete it when unmounting.
|
||||
- Keep alive feature that pings host regularly, reducing the chance of connections being dropped due to idle.
|
||||
Can be disabled or default frequency (10s) can be changed when calling `Waku.create`.
|
||||
|
@ -436,6 +457,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Add support for Waku Message version 1: Asymmetric encryption, symmetric encryption, and signature of the data.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: Auto select peer if none provided for store and light push protocols.
|
||||
- Upgrade to `libp2p@0.31.7` and `libp2p-gossipsub@0.10.0` to avoid `TextEncoder` errors in ReactJS tests.
|
||||
- Disable keep alive by default as latest nim-waku release does not support ping protocol.
|
||||
|
@ -448,11 +470,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Examples (eth-dm): Use Protobuf for direct messages instead of JSON ([#214](https://github.com/status-im/js-waku/issues/214)).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Disable `keepAlive` if set to `0`.
|
||||
|
||||
## [0.7.0] - 2021-06-15
|
||||
|
||||
### Changed
|
||||
|
||||
- Test: Upgrade nim-waku node to v0.4.
|
||||
- Waku Light Push upgraded to `2.0.0-beta1`.
|
||||
- Examples (web chat): Catch error if chat message decoding fails.
|
||||
|
@ -461,6 +485,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.6.0] - 2021-06-09
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking**: Websocket protocol is not automatically added anymore if the user specifies a protocol in `libp2p.modules`
|
||||
when using `Waku.create`.
|
||||
- **Breaking**: Options passed to `Waku.create` used to be passed to `Libp2p.create`;
|
||||
|
@ -468,6 +493,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Examples (cli chat): Use tcp protocol instead of websocket.
|
||||
|
||||
### Added
|
||||
|
||||
- Enable access to `WakuMessage.timestamp`.
|
||||
- Examples (web chat): Use `WakuMessage.timestamp` as unique key for list items.
|
||||
- Doc: Link to new [topic guidelines](https://rfc.vac.dev/spec/23/) in README.
|
||||
|
@ -480,6 +506,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.5.0] - 2021-05-21
|
||||
|
||||
### Added
|
||||
|
||||
- Implement [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
||||
- Expose `Direction` enum from js-waku root (it was only accessible via the proto module).
|
||||
- Examples (cli chat): Use light push to send messages if `--lightPush` is passed.
|
||||
|
@ -488,11 +515,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.4.0] - 2021-05-18
|
||||
|
||||
### Added
|
||||
|
||||
- `callback` argument to `WakuStore.queryHistory()`, called as messages are retrieved
|
||||
; Messages are retrieved using pagination, and it may take some time to retrieve all messages,
|
||||
with the `callback` function, messages are processed as soon as they are received.
|
||||
|
||||
### Changed
|
||||
|
||||
- Testing: Upgrade nim-waku node to v0.3.
|
||||
- **Breaking**: Modify `WakuStore.queryHistory()` to accept one `Object` instead of multiple individual arguments.
|
||||
- `getStatusFleetNodes` return prod nodes by default, instead of test nodes.
|
||||
|
@ -500,26 +529,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Examples (cli chat): Connect to test fleet by default, use `--prod` to connect to prod fleet.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Expose `Enviroment` and `Protocol` enums to pass to `getStatusFleetNodes`.
|
||||
|
||||
## [0.3.0] - 2021-05-15
|
||||
|
||||
### Added
|
||||
|
||||
- `getStatusFleetNodes` to connect to Status' nim-waku nodes.
|
||||
|
||||
### Changed
|
||||
|
||||
- Clarify content topic format in README.md.
|
||||
|
||||
## Removed
|
||||
|
||||
- Unused dependencies.
|
||||
|
||||
## [0.2.0] - 2021-05-14
|
||||
|
||||
### Added
|
||||
|
||||
- `WakuRelay.getPeers` method.
|
||||
- Use `WakuRelay.getPeers` in web chat app example to disable send button.
|
||||
|
||||
### Changed
|
||||
|
||||
- Enable passing `string`s to `addPeerToAddressBook`.
|
||||
- Use `addPeerToAddressBook` in examples and usage doc.
|
||||
- Settle on `js-waku` name across the board.
|
||||
|
@ -528,6 +563,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [0.1.0] - 2021-05-12
|
||||
|
||||
### Added
|
||||
|
||||
- Add usage section to the README.
|
||||
- Support of [Waku v2 Relay](https://rfc.vac.dev/spec/11/).
|
||||
- Support of [Waku v2 Store](https://rfc.vac.dev/spec/13/).
|
||||
|
@ -535,7 +571,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- [ReactJS Chat App example](./examples/web-chat).
|
||||
- [Typedoc Documentation](https://js-waku.wakuconnect.dev/).
|
||||
|
||||
[Unreleased]: https://github.com/status-im/js-waku/compare/v0.30.0...HEAD
|
||||
[unreleased]: https://github.com/status-im/js-waku/compare/v0.30.0...HEAD
|
||||
[0.30.0]: https://github.com/status-im/js-waku/compare/v0.29.0...v0.30.0
|
||||
[0.29.0]: https://github.com/status-im/js-waku/compare/v0.28.0...v0.29.0
|
||||
[0.28.1]: https://github.com/status-im/js-waku/compare/v0.28.0...v0.28.1
|
|
@ -0,0 +1,193 @@
|
|||
{
|
||||
"name": "@waku/core",
|
||||
"version": "0.0.1",
|
||||
"description": "TypeScript implementation of the Waku v2 protocol",
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"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/peer_discovery_dns": {
|
||||
"types": "./dist/lib/peer_discovery_dns/index.d.ts",
|
||||
"import": "./dist/lib/peer_discovery_dns/index.js"
|
||||
},
|
||||
"./lib/peer_discovery_static_list": {
|
||||
"types": "./dist/lib/peer_discovery_static_list.d.ts",
|
||||
"import": "./dist/lib/peer_discovery_static_list.js"
|
||||
},
|
||||
"./lib/predefined_bootstrap_nodes": {
|
||||
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
|
||||
"import": "./dist/lib/predefined_bootstrap_nodes.js"
|
||||
},
|
||||
"./lib/wait_for_remote_peer": {
|
||||
"types": "./dist/lib/wait_for_remote_peer.d.ts",
|
||||
"import": "./dist/lib/wait_for_remote_peer.js"
|
||||
},
|
||||
"./lib/waku_message/version_0": {
|
||||
"types": "./dist/lib/waku_message/version_0.d.ts",
|
||||
"import": "./dist/lib/waku_message/version_0.js"
|
||||
},
|
||||
"./lib/waku_message/version_1": {
|
||||
"types": "./dist/lib/waku_message/version_1.d.ts",
|
||||
"import": "./dist/lib/waku_message/version_1.js"
|
||||
},
|
||||
"./lib/waku_message/topic_only_message": {
|
||||
"types": "./dist/lib/waku_message/topic_only_message.d.ts",
|
||||
"import": "./dist/lib/waku_message/topic_only_message.js"
|
||||
}
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"lib/*": [
|
||||
"dist/lib/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "module",
|
||||
"repository": "https://github.com/status-im/js-waku",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"keywords": [
|
||||
"waku",
|
||||
"decentralised",
|
||||
"communication",
|
||||
"web3",
|
||||
"ethereum",
|
||||
"dapps"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "run-s build:**",
|
||||
"build:esm": "tsc && node build-scripts/fix-imports.js",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src --ext .ts --ext .cjs --fix",
|
||||
"pretest": "run-s pretest:*",
|
||||
"pretest:1-init-git-submodules": "[ -f '../../nwaku/build/wakunode2' ] || git submodule update --init --recursive",
|
||||
"pretest:2-build-nwaku": "[ -f '../../nwaku/build/wakunode2' ] || run-s nwaku:build",
|
||||
"nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)",
|
||||
"nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint 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"
|
||||
},
|
||||
"browser": {
|
||||
"crypto": false
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-gossipsub": "^4.1.1",
|
||||
"@chainsafe/libp2p-noise": "^8.0.1",
|
||||
"@ethersproject/rlp": "^5.5.0",
|
||||
"@libp2p/crypto": "^1.0.4",
|
||||
"@libp2p/interface-connection": "3.0.1",
|
||||
"@libp2p/interface-peer-discovery": "^1.0.0",
|
||||
"@libp2p/interface-peer-id": "^1.0.2",
|
||||
"@libp2p/interface-peer-info": "^1.0.1",
|
||||
"@libp2p/interface-peer-store": "^1.0.0",
|
||||
"@libp2p/interface-pubsub": "^2.0.1",
|
||||
"@libp2p/interfaces": "^3.0.2",
|
||||
"@libp2p/mplex": "^5.1.1",
|
||||
"@libp2p/peer-id": "^1.1.10",
|
||||
"@libp2p/websockets": "^3.0.3",
|
||||
"@multiformats/multiaddr": "^11.0.6",
|
||||
"@noble/secp256k1": "^1.3.4",
|
||||
"debug": "^4.3.4",
|
||||
"dns-query": "^0.11.2",
|
||||
"hi-base32": "^0.5.1",
|
||||
"it-all": "^1.0.6",
|
||||
"it-length-prefixed": "^8.0.2",
|
||||
"it-pipe": "^2.0.4",
|
||||
"js-sha3": "^0.8.0",
|
||||
"libp2p": "0.38.0",
|
||||
"p-event": "^5.0.1",
|
||||
"protons-runtime": "^3.1.0",
|
||||
"uint8arraylist": "^2.3.2",
|
||||
"uint8arrays": "^3.0.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@libp2p/peer-id-factory": "^1.0.15",
|
||||
"@rollup/plugin-commonjs": "^22.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/chai": "^4.2.15",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^17.0.6",
|
||||
"@types/tail": "^2.0.0",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||
"@typescript-eslint/parser": "^5.8.1",
|
||||
"app-root-path": "^3.0.0",
|
||||
"chai": "^4.3.4",
|
||||
"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",
|
||||
"fast-check": "^2.14.0",
|
||||
"gh-pages": "^3.2.3",
|
||||
"ignore-loader": "^0.1.2",
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"jsdom": "^19.0.0",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"karma": "^6.3.12",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^9.1.3",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"p-timeout": "^6.0.0",
|
||||
"portfinder": "^1.0.28",
|
||||
"prettier": "^2.1.1",
|
||||
"process": "^0.11.10",
|
||||
"protons": "^5.1.0",
|
||||
"puppeteer": "^13.0.1",
|
||||
"rollup": "^2.75.0",
|
||||
"tail": "^2.2.0",
|
||||
"ts-loader": "^9.3.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typedoc": "^0.23.10",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bundle",
|
||||
"src/*.ts",
|
||||
"src/lib/**/*.ts",
|
||||
"src/proto/**/*.ts",
|
||||
"!**/*.spec.*",
|
||||
"!**/*.json",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import { assert, expect } from "chai";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
|
||||
|
@ -17,15 +17,11 @@ describe("ENR", function () {
|
|||
const peerId = await createSecp256k1PeerId();
|
||||
const enr = await ENR.createFromPeerId(peerId);
|
||||
const keypair = await createKeypairFromPeerId(peerId);
|
||||
enr.setLocationMultiaddr(new Multiaddr("/ip4/18.223.219.100/udp/9000"));
|
||||
enr.setLocationMultiaddr(multiaddr("/ip4/18.223.219.100/udp/9000"));
|
||||
enr.multiaddrs = [
|
||||
new Multiaddr(
|
||||
"/dns4/node1.do-ams.wakuv2.test.statusim.net/tcp/443/wss"
|
||||
),
|
||||
new Multiaddr(
|
||||
"/dns6/node2.ac-chi.wakuv2.test.statusim.net/tcp/443/wss"
|
||||
),
|
||||
new Multiaddr(
|
||||
multiaddr("/dns4/node1.do-ams.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
multiaddr("/dns6/node2.ac-chi.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
multiaddr(
|
||||
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234/wss"
|
||||
),
|
||||
];
|
||||
|
@ -44,8 +40,8 @@ describe("ENR", function () {
|
|||
if (!enr2.signature) throw "enr.signature is undefined";
|
||||
|
||||
expect(bytesToHex(enr2.signature)).to.be.equal(bytesToHex(enr.signature));
|
||||
const multiaddr = enr2.getLocationMultiaddr("udp")!;
|
||||
expect(multiaddr.toString()).to.be.equal("/ip4/18.223.219.100/udp/9000");
|
||||
const ma = enr2.getLocationMultiaddr("udp")!;
|
||||
expect(ma.toString()).to.be.equal("/ip4/18.223.219.100/udp/9000");
|
||||
expect(enr2.multiaddrs).to.not.be.undefined;
|
||||
expect(enr2.multiaddrs!.length).to.be.equal(3);
|
||||
const multiaddrsAsStr = enr2.multiaddrs!.map((ma) => ma.toString());
|
||||
|
@ -113,12 +109,12 @@ describe("ENR", function () {
|
|||
const peerId = await createSecp256k1PeerId();
|
||||
const enr = await ENR.createFromPeerId(peerId);
|
||||
const keypair = await createKeypairFromPeerId(peerId);
|
||||
enr.setLocationMultiaddr(new Multiaddr("/ip4/18.223.219.100/udp/9000"));
|
||||
enr.setLocationMultiaddr(multiaddr("/ip4/18.223.219.100/udp/9000"));
|
||||
|
||||
enr.set("id", new Uint8Array([0]));
|
||||
const txt = await enr.encodeTxt(keypair.privateKey);
|
||||
|
||||
ENR.decodeTxt(txt);
|
||||
await ENR.decodeTxt(txt);
|
||||
assert.fail("Expect error here");
|
||||
} catch (err: unknown) {
|
||||
const e = err as Error;
|
||||
|
@ -200,7 +196,7 @@ describe("ENR", function () {
|
|||
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
|
||||
);
|
||||
record = await ENR.createV4(getPublicKey(privateKey));
|
||||
record.setLocationMultiaddr(new Multiaddr("/ip4/127.0.0.1/udp/30303"));
|
||||
record.setLocationMultiaddr(multiaddr("/ip4/127.0.0.1/udp/30303"));
|
||||
record.seq = seq;
|
||||
await record.encodeTxt(privateKey);
|
||||
});
|
||||
|
@ -248,7 +244,7 @@ describe("ENR", function () {
|
|||
});
|
||||
|
||||
it("should get / set UDP multiaddr", () => {
|
||||
const multi0 = new Multiaddr("/ip4/127.0.0.1/udp/30303");
|
||||
const multi0 = multiaddr("/ip4/127.0.0.1/udp/30303");
|
||||
const tuples0 = multi0.tuples();
|
||||
|
||||
if (!tuples0[0][1] || !tuples0[1][1]) {
|
||||
|
@ -262,7 +258,7 @@ describe("ENR", function () {
|
|||
multi0.toString()
|
||||
);
|
||||
// set the multiaddr
|
||||
const multi1 = new Multiaddr("/ip4/0.0.0.0/udp/30300");
|
||||
const multi1 = multiaddr("/ip4/0.0.0.0/udp/30300");
|
||||
record.setLocationMultiaddr(multi1);
|
||||
// and get the multiaddr
|
||||
expect(record.getLocationMultiaddr("udp")!.toString()).to.equal(
|
||||
|
@ -275,7 +271,7 @@ describe("ENR", function () {
|
|||
});
|
||||
|
||||
it("should get / set TCP multiaddr", () => {
|
||||
const multi0 = new Multiaddr("/ip4/127.0.0.1/tcp/30303");
|
||||
const multi0 = multiaddr("/ip4/127.0.0.1/tcp/30303");
|
||||
const tuples0 = multi0.tuples();
|
||||
|
||||
if (!tuples0[0][1] || !tuples0[1][1]) {
|
||||
|
@ -290,7 +286,7 @@ describe("ENR", function () {
|
|||
multi0.toString()
|
||||
);
|
||||
// set the multiaddr
|
||||
const multi1 = new Multiaddr("/ip4/0.0.0.0/tcp/30300");
|
||||
const multi1 = multiaddr("/ip4/0.0.0.0/tcp/30300");
|
||||
record.setLocationMultiaddr(multi1);
|
||||
// and get the multiaddr
|
||||
expect(record.getLocationMultiaddr("tcp")!.toString()).to.equal(
|
||||
|
@ -324,43 +320,43 @@ describe("ENR", function () {
|
|||
|
||||
it("should properly create location multiaddrs - udp4", () => {
|
||||
expect(enr.getLocationMultiaddr("udp4")).to.deep.equal(
|
||||
new Multiaddr(`/ip4/${ip4}/udp/${udp}`)
|
||||
multiaddr(`/ip4/${ip4}/udp/${udp}`)
|
||||
);
|
||||
});
|
||||
|
||||
it("should properly create location multiaddrs - tcp4", () => {
|
||||
expect(enr.getLocationMultiaddr("tcp4")).to.deep.equal(
|
||||
new Multiaddr(`/ip4/${ip4}/tcp/${tcp}`)
|
||||
multiaddr(`/ip4/${ip4}/tcp/${tcp}`)
|
||||
);
|
||||
});
|
||||
|
||||
it("should properly create location multiaddrs - udp6", () => {
|
||||
expect(enr.getLocationMultiaddr("udp6")).to.deep.equal(
|
||||
new Multiaddr(`/ip6/${ip6}/udp/${udp}`)
|
||||
multiaddr(`/ip6/${ip6}/udp/${udp}`)
|
||||
);
|
||||
});
|
||||
|
||||
it("should properly create location multiaddrs - tcp6", () => {
|
||||
expect(enr.getLocationMultiaddr("tcp6")).to.deep.equal(
|
||||
new Multiaddr(`/ip6/${ip6}/tcp/${tcp}`)
|
||||
multiaddr(`/ip6/${ip6}/tcp/${tcp}`)
|
||||
);
|
||||
});
|
||||
|
||||
it("should properly create location multiaddrs - udp", () => {
|
||||
// default to ip4
|
||||
expect(enr.getLocationMultiaddr("udp")).to.deep.equal(
|
||||
new Multiaddr(`/ip4/${ip4}/udp/${udp}`)
|
||||
multiaddr(`/ip4/${ip4}/udp/${udp}`)
|
||||
);
|
||||
// if ip6 is set, use it
|
||||
enr.ip = undefined;
|
||||
expect(enr.getLocationMultiaddr("udp")).to.deep.equal(
|
||||
new Multiaddr(`/ip6/${ip6}/udp/${udp}`)
|
||||
multiaddr(`/ip6/${ip6}/udp/${udp}`)
|
||||
);
|
||||
// if ip6 does not exist, use ip4
|
||||
enr.ip6 = undefined;
|
||||
enr.ip = ip4;
|
||||
expect(enr.getLocationMultiaddr("udp")).to.deep.equal(
|
||||
new Multiaddr(`/ip4/${ip4}/udp/${udp}`)
|
||||
multiaddr(`/ip4/${ip4}/udp/${udp}`)
|
||||
);
|
||||
enr.ip6 = ip6;
|
||||
});
|
||||
|
@ -368,18 +364,18 @@ describe("ENR", function () {
|
|||
it("should properly create location multiaddrs - tcp", () => {
|
||||
// default to ip4
|
||||
expect(enr.getLocationMultiaddr("tcp")).to.deep.equal(
|
||||
new Multiaddr(`/ip4/${ip4}/tcp/${tcp}`)
|
||||
multiaddr(`/ip4/${ip4}/tcp/${tcp}`)
|
||||
);
|
||||
// if ip6 is set, use it
|
||||
enr.ip = undefined;
|
||||
expect(enr.getLocationMultiaddr("tcp")).to.deep.equal(
|
||||
new Multiaddr(`/ip6/${ip6}/tcp/${tcp}`)
|
||||
multiaddr(`/ip6/${ip6}/tcp/${tcp}`)
|
||||
);
|
||||
// if ip6 does not exist, use ip4
|
||||
enr.ip6 = undefined;
|
||||
enr.ip = ip4;
|
||||
expect(enr.getLocationMultiaddr("tcp")).to.deep.equal(
|
||||
new Multiaddr(`/ip4/${ip4}/tcp/${tcp}`)
|
||||
multiaddr(`/ip4/${ip4}/tcp/${tcp}`)
|
||||
);
|
||||
enr.ip6 = ip6;
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { convertToString } from "@multiformats/multiaddr/convert";
|
||||
|
||||
export function multiaddrFromFields(
|
||||
ipFamily: string,
|
||||
protocol: string,
|
||||
ipBytes: Uint8Array,
|
||||
protocolBytes: Uint8Array
|
||||
): Multiaddr {
|
||||
let ma = multiaddr("/" + ipFamily + "/" + convertToString(ipFamily, ipBytes));
|
||||
|
||||
ma = ma.encapsulate(
|
||||
multiaddr("/" + protocol + "/" + convertToString(protocol, protocolBytes))
|
||||
);
|
||||
|
||||
return ma;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { decodeMultiaddrs, encodeMultiaddrs } from "./multiaddrs_codec";
|
||||
|
@ -6,13 +6,11 @@ import { decodeMultiaddrs, encodeMultiaddrs } from "./multiaddrs_codec";
|
|||
describe("ENR multiaddrs codec", function () {
|
||||
it("Sample", async () => {
|
||||
const multiaddrs = [
|
||||
new Multiaddr(
|
||||
"/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss"
|
||||
),
|
||||
new Multiaddr(
|
||||
multiaddr("/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
multiaddr(
|
||||
"/dns6/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss"
|
||||
),
|
||||
new Multiaddr(
|
||||
multiaddr(
|
||||
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234/wss"
|
||||
),
|
||||
];
|
|
@ -1,4 +1,5 @@
|
|||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
|
||||
import { MULTIADDR_LENGTH_SIZE } from "./constants";
|
||||
|
||||
|
@ -19,8 +20,7 @@ export function decodeMultiaddrs(bytes: Uint8Array): Multiaddr[] {
|
|||
const multiaddrBytes = bytes.slice(index, index + size);
|
||||
index += size;
|
||||
|
||||
const multiaddr = new Multiaddr(multiaddrBytes);
|
||||
multiaddrs.push(multiaddr);
|
||||
multiaddrs.push(multiaddr(multiaddrBytes));
|
||||
}
|
||||
return multiaddrs;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { ENR, Waku2 } from "../enr";
|
||||
|
@ -9,11 +9,11 @@ import { fetchNodesUntilCapabilitiesFulfilled } from "./fetch_nodes";
|
|||
async function createEnr(waku2: Waku2): Promise<ENR> {
|
||||
const peerId = await createSecp256k1PeerId();
|
||||
const enr = await ENR.createFromPeerId(peerId);
|
||||
enr.setLocationMultiaddr(new Multiaddr("/ip4/18.223.219.100/udp/9000"));
|
||||
enr.setLocationMultiaddr(multiaddr("/ip4/18.223.219.100/udp/9000"));
|
||||
enr.multiaddrs = [
|
||||
new Multiaddr("/dns4/node1.do-ams.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
new Multiaddr("/dns6/node2.ac-chi.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
new Multiaddr(
|
||||
multiaddr("/dns4/node1.do-ams.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
multiaddr("/dns6/node2.ac-chi.wakuv2.test.statusim.net/tcp/443/wss"),
|
||||
multiaddr(
|
||||
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234/wss"
|
||||
),
|
||||
];
|
|
@ -5,7 +5,8 @@ import type {
|
|||
import { symbol } from "@libp2p/interface-peer-discovery";
|
||||
import type { PeerInfo } from "@libp2p/interface-peer-info";
|
||||
import { CustomEvent, EventEmitter } from "@libp2p/interfaces/events";
|
||||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import debug from "debug";
|
||||
|
||||
import { multiaddrsToPeerInfo } from "./multiaddr_to_peer_info";
|
||||
|
@ -52,7 +53,7 @@ export class PeerDiscoveryStaticPeers
|
|||
|
||||
const peerMas = peers.map((peer: string | Multiaddr) => {
|
||||
if (typeof peer === "string") {
|
||||
return new Multiaddr(peer);
|
||||
return multiaddr(peer);
|
||||
} else {
|
||||
return peer;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
|
||||
import { getPseudoRandomSubset } from "./random_subset";
|
||||
|
||||
|
@ -41,7 +42,7 @@ export function getPredefinedBootstrapNodes(
|
|||
|
||||
nodes = Object.values(nodes) as string[];
|
||||
|
||||
nodes = nodes.map((node: string) => new Multiaddr(node));
|
||||
nodes = nodes.map((node: string) => multiaddr(node));
|
||||
return getPseudoRandomSubset(nodes, wantedNumber);
|
||||
}
|
||||
|
|
@ -141,6 +141,9 @@ describe("Decryption Keys", () => {
|
|||
|
||||
waku1.addPeerToAddressBook(
|
||||
waku2.libp2p.peerId,
|
||||
// TODO: Upgrade libp2p package.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: New multiaddr type but they seem mostly compatible
|
||||
waku2.libp2p.getMultiaddrs()
|
||||
);
|
||||
|
|
@ -137,6 +137,8 @@ export class WakuNode implements Waku {
|
|||
codecs.push(FilterCodec);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: new Multiaddr is not backward compatible
|
||||
return this.libp2p.dialProtocol(peer, codecs);
|
||||
}
|
||||
|
|
@ -64,6 +64,9 @@ describe("Waku Relay [node only]", () => {
|
|||
log("Instances started, adding waku2 to waku1's address book");
|
||||
waku1.addPeerToAddressBook(
|
||||
waku2.libp2p.peerId,
|
||||
// TODO: Upgrade libp2p package.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: New multiaddr type but they seem mostly compatible
|
||||
waku2.libp2p.getMultiaddrs()
|
||||
);
|
||||
|
||||
|
@ -279,10 +282,16 @@ describe("Waku Relay [node only]", () => {
|
|||
|
||||
waku1.addPeerToAddressBook(
|
||||
waku2.libp2p.peerId,
|
||||
// TODO: Upgrade libp2p package.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: New multiaddr type but they seem mostly compatible
|
||||
waku2.libp2p.getMultiaddrs()
|
||||
);
|
||||
waku3.addPeerToAddressBook(
|
||||
waku2.libp2p.peerId,
|
||||
// TODO: Upgrade libp2p package.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: New multiaddr type but they seem mostly compatible
|
||||
waku2.libp2p.getMultiaddrs()
|
||||
);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue