Commit Graph

334 Commits

Author SHA1 Message Date
Franck Royer 80cfa3c87a
Increase timeout to shutdown node 2021-08-09 12:09:21 +10:00
Franck Royer c14951cb0e
Increase timeout for nim-waku starts
Took 5 seconds in CI run.
2021-08-09 11:58:58 +10:00
Franck Royer ad9d629daa
`ChatMessage` has been moved from js-waku to web-chat example
It is a type used for the [TOY-CHAT](https://rfc.vac.dev/spec/22/)
 protocol;
js-waku users should not build on top if this toy protocol and instead
design message data structures appropriate to their use case.
2021-08-06 17:25:12 +10:00
Franck Royer d035359616
Workaround the fact that ni-waku does not accept integers as timestamp 2021-08-05 13:32:37 +10:00
Franck Royer 45dc8f81c9
Fixed `ChatMessage.payloadAsUtf8` returning garbage on utf-8 non-ascii 2021-08-02 10:36:50 +10:00
Franck Royer 1f692f1683
Fixed `payloadAsUtf8` returning garbage on utf-8 non-ascii characters 2021-08-02 09:51:37 +10:00
Franck Royer 0cfdd34284
Removed `DefaultContentTopic`
As developers must choose a content topic for their app.
The`WakuMessage` APIs have been changed to move `contentTopic` out of
the optional parameters. Recommendations for content topic can be found
at https://rfc.vac.dev/spec/23/.
2021-07-28 12:03:51 +10:00
Franck Royer 5e056d8b81
Shorten imports, remove warning 2021-07-28 11:58:05 +10:00
Franck Royer 9638f6db10
Introduced new `relayKeepAlive` option
..on `Waku` with a default to 5min to send ping messages over relay
to ensure the relay stream stays open.

This is a workaround until
[js-libp2p#744](https://github.com/libp2p/js-libp2p/issues/744) is done
as there are issues when TCP(?) timeouts and the stream gets closed.
2021-07-27 16:24:04 +10:00
Franck Royer ea33b9cd8a
Rename `keepAlive` option to `pingKeepAlive`
In preparation for introducing a relay keep alive feature.
2021-07-27 16:06:57 +10:00
Franck Royer c4d0501c6a
nim-waku v0.5 uses new waku relay protocol id 2021-07-26 11:35:08 +10:00
Franck Royer 5f7eee394b
Store Response Protobuf change to align with nim-waku
status-im/nim-waku#676
2021-07-26 11:35:08 +10:00
Franck Royer 6817a2f6b2
Pass timestamp to RPC call 2021-07-26 11:32:50 +10:00
Franck Royer be007f4839
Ensure there is no infinite loop on error 2021-07-21 15:44:00 +10:00
Franck Royer 92a76b3be0
Support multiple protocol id for relay
Support id of latest nim-waku release 0.4 and current master.
2021-07-21 15:43:30 +10:00
Franck Royer 6135127e5d
Correct name 2021-07-21 15:02:38 +10:00
Franck Royer 1d4137e2c4
Rename so that it does make dev thinks it's for asymmetric enc only 2021-07-16 10:24:29 +10:00
Franck Royer addf9543a2
Export `generatePrivateKey` and `getPublicKey` directly from the root 2021-07-16 09:43:10 +10:00
Franck Royer f3738b1eac
doc: Fix keep alive default value 2021-07-15 14:00:24 +10:00
Franck Royer 0b3f1a33c2
test: Symmetric encryption with waku store 2021-07-15 12:26:05 +10:00
Franck Royer 44efd28ac1
Update terminology and docs to cater for both sym and asym encryption 2021-07-15 12:25:47 +10:00
Franck Royer b74acd73dc
Remove unknown type 2021-07-15 12:16:21 +10:00
Franck Royer 75d1b3834c
Simplify expression 2021-07-15 12:16:03 +10:00
Franck Royer 13c8a0527b
Test symmetric encryption with nim-waku using relay 2021-07-15 12:12:43 +10:00
Franck Royer 302fc20243
Remove dupe tests 2021-07-15 10:36:24 +10:00
Franck Royer 9374de1931
Karma: Remove tests folder and use in place files & update contrib guide
*.browser.spec.ts files will be tested on both node and browser.
Other files only tested on node.
2021-07-15 10:36:24 +10:00
Franck Royer 25fccb4c9a
Add symmetric encryption support to Waku Message 2021-07-15 10:23:40 +10:00
Franck Royer 56c30059b2
Add comments on Waku Message Options 2021-07-15 10:23:34 +10:00
Franck Royer 57f65267c2
Implement and test symmetric encryption in the browser 2021-07-14 16:31:11 +10:00
Franck Royer 06ee0ac1d8
Symmetric encryption for node 2021-07-14 15:34:48 +10:00
Franck Royer ac4f0aab98
Only include lib files, segregate browser tests 2021-07-14 13:04:11 +10:00
Franck Royer a9c83dac13
Do not use same key value for both constants 2021-07-14 13:03:22 +10:00
Franck Royer e443237a81
Remove local type definitions for Karma to not return "not found" 2021-07-14 12:25:23 +10:00
Franck Royer 70058f0e36
Split browser and node tests 2021-07-14 11:56:48 +10:00
Franck Royer a0d3a21762
Improve importing of Muxed Stream type 2021-07-14 11:38:59 +10:00
Franck Royer c2cef05c2d
Use protobuf instead of JSON for direct messages 2021-07-12 17:29:52 +10:00
Franck Royer 48bdb0b3f2
Use WakuMessage version 1 instead of eth-crypto 2021-07-12 17:09:44 +10:00
Franck Royer 0e9c482a19
Enable decryption of messages retrieve via `WakuStore.queryHistory` 2021-07-12 13:15:19 +10:00
Franck Royer d68ee3fb74
New `peers` and `randomPeer` methods to return available peers 2021-07-12 13:15:19 +10:00
Franck Royer 4fe0116039
Use ecies library that provide right ECIES parameters 2021-07-12 11:30:19 +10:00
Franck Royer 63923f4368
Prefer usage of utils 2021-07-09 16:06:49 +10:00
Franck Royer b70f7c5a95
Use DOM random generator if available 2021-07-09 16:06:49 +10:00
Franck Royer 1f6ed9b525
Prefer secp256k1 lib over ecies 2021-07-09 15:50:17 +10:00
Franck Royer 2b1a6dafea
Skip nim-waku interop tests
ecies-parity does not provide the same ECIES that waku:
ecies-parity uses a shared hmac of `[0,0]` whereas waku uses `[]`.

Work is needed to find or create a new library.
2021-07-09 15:50:17 +10:00
Franck Royer 8cd5a52eba
Provide hex/bytes utils as part of js-waku 2021-07-09 15:50:17 +10:00
Franck Royer 22c716e0e6
Add API to generate keys 2021-07-09 15:50:16 +10:00
Franck Royer f123cd7e62
Test asymmetric encryption against nim-waku 2021-07-09 15:50:16 +10:00
Franck Royer f95d9aec3c
Add version 1 support to waku relay, test decryption against nim-waku 2021-07-09 15:50:16 +10:00
Franck Royer acdc032253
Simplify code 2021-07-09 15:50:16 +10:00
Franck Royer 34e6ac5247
Add version 1 support to WakuMessage 2021-07-09 15:50:15 +10:00
Franck Royer 2266f31d30
Move optional parameters to a single `Options` object. 2021-07-09 15:50:15 +10:00
Franck Royer 381333347e
Remove dupe code 2021-07-09 15:50:15 +10:00
Franck Royer f2a2233c77
Add encrypt/decrypt asymmetric 2021-07-09 15:50:15 +10:00
Franck Royer f97dc4de81
Implement Waku Message Version 1 encoding and signature 2021-07-09 14:49:09 +10:00
Franck Royer 7b5c8d6094
Move waku_message to dedicated folder 2021-07-09 14:49:09 +10:00
Franck Royer c3b726cb99
Remove deprecated call 2021-07-09 14:49:08 +10:00
Franck Royer aaf3b1867e
Disable keep alive by default as latest nim-waku release does not
support ping protocol.
2021-07-05 09:40:07 +10:00
Franck Royer 354dcd66a5
Constructor is more appropriate when comparing function signatures 2021-07-02 13:52:50 +10:00
Franck Royer 370a347ff2
Actually disable keep alive if set to 0 2021-07-02 10:51:58 +10:00
Franck Royer 8cecfc205b
Use plain websocket in tests
Thanks to the libp2p upgrade, waku actually tries to listen to a
secure websocket. Using plain websocket for now, testing secure
websocket is tracked with #50.
2021-06-22 14:11:38 +10:00
Franck Royer 6cb92dd4b9
Upgrade to latest libp2p versions
And few other packages
2021-06-22 13:21:23 +10:00
Franck Royer dbab0cc582
Unnecessary and create conflicts due to disparity of version
Between libp2p-interfaces from libp2p and libp2p-gossipsub.
2021-06-22 10:08:02 +10:00
Franck Royer 381fc8b82c
Add keep alive feature
Using libp2p ping protocol.
2021-06-21 09:46:41 +10:00
Franck Royer e3b4a42822
Add keep alive feature
Using libp2p ping protocol.
2021-06-21 09:46:29 +10:00
Franck Royer 939b5fb20a
Auto select peer if none provided for store and light push protocols 2021-06-16 23:51:20 +10:00
Franck Royer 60eb473047
Add `WakuRelay.deleteObserver` to allow removal of observers
Useful when a React component add observers when mounting and needs to
delete it when unmounting.
2021-06-16 16:37:04 +10:00
Franck Royer af1e97fafe
Use Set to facilitate removal of observers 2021-06-16 16:37:04 +10:00
Franck Royer bc544c8e0b
Update Light Push protocol string to match nim-waku v0.4 2021-06-11 14:38:08 +10:00
Franck Royer 5ce0717f05
Enable passing a custom pubsub topic
Note that we currently only support one, and only one, pubsub topic for
a given instance across the codebase. The PubSub topic needs to be set
when instantiating the Waku* classes.

At this stage, we believe that most DApp will use, and only use, the
default PubSub topic. Some application want to use an alternative topic
but not use the default one so this behaviour should be fine. See #174
for details.
2021-06-09 15:00:03 +10:00
Franck Royer f0f14f9995
Rename type before introducing CreateOptions 2021-06-09 15:00:03 +10:00
Franck Royer eb521b4dbd
Extract subscription logic from start method 2021-06-09 15:00:02 +10:00
Franck Royer d8629b7fbc
Define type for WakuRelay create options 2021-06-09 15:00:02 +10:00
Franck Royer f17a008278
Separate the libp2p create options from Waku's 2021-06-09 15:00:02 +10:00
Franck Royer 9e64eec2a6
Enable test encoding and decoding of WakuMessage.timestamp 2021-05-28 22:35:59 +10:00
Franck Royer 3055881c57
Proto message is expected, not the wrapping class 2021-05-28 15:59:57 +10:00
Franck Royer b13ecdd45f
Do not inherit doc for Waku Relay
As it clutters the documentation and at this stage we do not expect
users to use inherited methods.
2021-05-21 11:47:17 +10:00
Franck Royer c347ec28b4
Ensure that no unnecessary js node are started for interop tests
Indeed, the beforeEach/afterEach methods are called for all tests in the
block, including interop tests.
2021-05-20 15:49:13 +10:00
Franck Royer ed69122ac3
Remove warning 2021-05-19 12:55:39 +10:00
Franck Royer fb7e9f2b9e
Get messages from store in chronological order 2021-05-19 12:29:29 +10:00
Franck Royer de3aea626a
Implement Light Push protocol 2021-05-19 12:29:29 +10:00
Franck Royer 2cd87b561d
Expose `Enviroment` & `Protocol` enums to pass to `getStatusFleetNodes` 2021-05-18 13:45:49 +10:00
Franck Royer 537a2b73a7
Use prod nodes by default instead of test 2021-05-18 13:26:42 +10:00
Franck Royer 243b6629c3
Add callback option to store query 2021-05-17 16:32:34 +10:00
Franck Royer 4b6fe84392
Use one object as we are increasing the number of parameters 2021-05-17 16:32:33 +10:00
Franck Royer 79bef35460
Add and use `getStatusFleetNodes` to connect to Status' wakunodes 2021-05-15 19:52:05 +10:00
Franck Royer a8d4d494f8
Add getPeers method
To know if relay messages would be published.
2021-05-13 20:48:33 +10:00
Franck Royer eb9955314c
Align terminology with specs
In specs, this is referenced as a `pubsubTopic`.
2021-05-13 20:48:30 +10:00
Franck Royer 065593b0cf
Revert naming to js-waku
To align with go-waku and nim-waku and keep bors working.
2021-05-13 20:27:38 +10:00
Franck Royer 6f7c1e0ca3
Enhance addPeerToAddressBook
So that consumer does not need to import multiaddr and peer-id.
2021-05-13 13:42:40 +10:00
Franck Royer 19e265c490
Remove unneeded variable 2021-05-13 12:30:13 +10:00
Franck Royer fda65ca83b
Fix documentation 2021-05-13 12:30:13 +10:00
Franck Royer 7c6730b4a3
Remove `declare` keyword which removes the values from generated JS 2021-05-11 14:05:13 +10:00
Franck Royer 40fd7ff365
Use Typedoc comment style 2021-05-11 09:06:22 +10:00
Franck Royer 50eaa39fec
Add debug statement in tests
Also enable debug logs in CI.
2021-05-10 20:18:26 +10:00
Franck Royer 3663ce260d
Rework exports for an easy use of the library 2021-05-10 16:41:58 +10:00
Franck Royer e91f7933c9
Pass proto in constructor
Makes the relation between the protobuf class and the wrapper more
direct. Conversion only happens at creates or on getters.
2021-05-10 16:29:25 +10:00
Franck Royer 3b7fc44419
Remove `Proto` suffix
Manage with namespace instead.
2021-05-10 15:53:23 +10:00
Franck Royer ba6b67cc53
Enable observers to filter by contentTopic 2021-05-10 14:54:08 +10:00
Franck Royer de3dcd9e22
Improve test readability
By avoiding buffer comparison.
2021-05-10 14:10:37 +10:00
Franck Royer 71a5b23bd2
Add observer interface that directly pass waku messages 2021-05-10 12:38:44 +10:00
Franck Royer ace5f2776f
Prefer camel case for module constants 2021-05-10 12:38:44 +10:00
Franck Royer cbe9559096
Clarify what methods should be used 2021-05-10 12:38:44 +10:00
Franck Royer 21414ad55e
Upgrade nim-waku to latest version 2021-05-07 11:30:36 +10:00
Franck Royer d19be03862
Ensure that rpc call to send messages is successful 2021-05-07 11:30:35 +10:00
Franck Royer 775a288a5c
Log more around usage of waku store 2021-05-07 10:41:38 +10:00
Franck Royer abd5709f86
Move cli chat to examples folder 2021-05-05 10:53:40 +10:00
Franck Royer 906d118d7d
Remove empty file 2021-05-05 09:59:36 +10:00
Franck Royer 19d6459883
Move chat message in js-waku 2021-05-05 09:59:19 +10:00
Franck Royer de57b2691e
Only the `result` property is ever used 2021-05-04 11:12:32 +10:00
Franck Royer 9e30627e2b
Force return types to be specified
Makes it easier to use the library. Best to enforce this early on.
2021-05-04 11:12:32 +10:00
bors[bot] 3ae782d3b4
Merge #118 #121 #122
118: Clean up WakuMessage API r=D4nte a=D4nte



121: Always trigger store query at connection r=D4nte a=D4nte

If no new messages are received, the rendering does not change
as dupe messages are filtered out.

122: Use provided API r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@status.im>
2021-05-04 00:26:12 +00:00
Franck Royer d0020744b4
Use provided API 2021-05-04 10:23:31 +10:00
Franck Royer 0ff0e6ee7b
Clean up WakuMessage API 2021-05-03 16:26:02 +10:00
Franck Royer 1016e85f70
Enable pubsub topic filter in history queries
Resolves #78
2021-04-29 16:52:55 +10:00
Franck Royer 5664c14743
Check subscribers until it finds one 2021-04-29 16:38:50 +10:00
Franck Royer 0270003556
Increase test timeouts 2021-04-29 16:07:37 +10:00
Franck Royer 2c66f86e91
Upgrade libp2p packages 2021-04-29 12:06:38 +10:00
Franck Royer 69a3f73ee6
Self emit to see own messages 2021-04-22 14:47:43 +10:00
Franck Royer 09fa8a0447
Must pass filter.all to connect to ip4 ws peer 2021-04-22 10:39:05 +10:00
Franck Royer df5a4f8326
waku is undefined 2021-04-21 16:17:32 +10:00
Franck Royer afba3210e9
Upgrade libp2p to 0.31.0-rc.3 2021-04-21 16:17:32 +10:00
Franck Royer bf11d76a93
Log in error raised by question 2021-04-21 09:57:21 +10:00
Franck Royer dd0a843770
Upgrade ts-proto to fix long dependency warning/error 2021-04-20 16:11:53 +10:00
Franck Royer ee6226bd32
Update waku store as per the latest spec 2021-04-20 15:38:40 +10:00
Franck Royer 0241d9edf3
Catch nick promise failure 2021-04-20 15:32:10 +10:00
Franck Royer 4542e01f0e
Check in protobuf generated files
So that developers do not have to install protobuf suite by default.
2021-04-20 15:32:10 +10:00
Franck Royer 6ee404c3ce
Skip the js-nim-js test as it fails in CI 2021-04-20 15:26:01 +10:00
Franck Royer eec55b7b71
Add sleep for failing tests + logging 2021-04-20 15:15:18 +10:00
Franck Royer 818a8256e7
Wait for identify protocol to finish 2021-04-20 10:34:23 +10:00
Franck Royer 00e303ee0a
Increase test timeout 2021-04-20 10:13:13 +10:00
Franck Royer e233ad8da4
Increase test timeouts 2021-04-20 09:38:30 +10:00
Franck Royer e0debac165
Subscribe to default topic when starting, Remove dual Waku relay classes 2021-04-16 11:25:08 +10:00
Franck Royer bc1ba3f4e4
Increase test timeout 2021-04-15 15:24:01 +10:00
Franck Royer 896462340a
Simplify API
At this stage, if waku relay is mounted then we always want to subscribe
to default topic.

We can re-introduce the flexibility once we know what matters to the user.

Resolves #17.
2021-04-15 14:45:14 +10:00
Franck Royer 9a305033bc
Use peerStore event to determine if identify is done 2021-04-15 14:44:35 +10:00
Franck Royer 503157401e
Allow passing transports, enable websocket transport 2021-04-15 13:56:07 +10:00
Franck Royer 1a813256e9
Start Waku first
So that even if the user does not enter a nick, the chat app
already acts as a waku node.
2021-04-15 13:56:07 +10:00
Franck Royer 31a45bf44e
Group imports 2021-04-15 13:56:07 +10:00
Franck Royer 1a4407b4f5
Increase test timeout 2021-04-15 13:56:06 +10:00
Franck Royer 4b31a6aaba
Wait for identify protocol to finish when dialing
Removes most `delay()`.
2021-04-13 22:43:13 +10:00
Franck Royer b38634fd14
Remove warnings 2021-04-13 15:25:00 +10:00
Franck Royer ee8db698b3
Allow constant condition for loops 2021-04-13 15:03:14 +10:00
Franck Royer 0e9b0b1b74
Ensure store waku calls returns messages in chronological order
Oldest at the start of the list.
2021-04-13 15:02:56 +10:00
Franck Royer 433f0432b3
Use pagination to retrieve all results from store 2021-04-13 15:02:53 +10:00
Franck Royer 1e10eeb5f5
Change API to directly return array of Waku Messages 2021-04-13 12:51:04 +10:00
Franck Royer 59df437490
test: History messages through several pages are retrieved 2021-04-13 11:47:15 +10:00
Franck Royer ef409bd89b
Upgrade to latest nim-waku commit 2021-04-13 10:36:22 +10:00
Franck Royer e534e0a4c8
Do not rely on nim-waku trace logs for test purposes 2021-04-13 09:51:41 +10:00
Franck Royer e9d51a6c57
Implement Waku store protocol 2021-04-09 16:54:30 +10:00
Franck Royer 79a9520348
Test cleanup 2021-04-09 16:05:43 +10:00