mirror of https://github.com/waku-org/js-waku.git
a3c45b6e1a
* `ProtocolCreateOptions` now has `pubSubTopic` as `pubSubTopic[]` * chore: update encoder & decoder to support `PubSubTopic` * feat(protocols): allow multiple `PubSubTopic[]` * feat(relay): allow multiple `PubSubTopic[]` * chore(tests): update for new API * chore: minor fixes * chore: make store more robust * fix(relay): correctly set types * chore(address comments): update terminology around configured pubsub topics * chore(address comments): minor refactoring * chore(relay): split `subscribe` into smaller functions for readability & modularity * chore(address comments): refactor `waitForGossipSubPeerInMesh` * chore(store): only allow to query one `pubSubTopic` * fix: `store` bug * feat(tests): add some basic tests * sharding utils * address comments * feat(relay): re-add API for `getMeshPeers` * update error message Co-authored-by: fryorcraken <110212804+fryorcraken@users.noreply.github.com> * refactor for new API * feat: simplify handling of observers (#1614) * refactor: simplify handling of observers * refactor: Remove redundant PubSubTopic from Observer * use `??` instead of `||` * update `pubsubTopic` to `pubSubTopic` * update `interval` typo * change occurence of `pubsubTopic` to `pubSubTopic` * relay: rm `getAllMeshPeers` and make `pubSubTopics` public * relay: use `push_or_init_map` and move to `utils` * fix: update API for tests * fix: relay waitForRemotePeer --------- Co-authored-by: fryorcraken <110212804+fryorcraken@users.noreply.github.com> |
||
---|---|---|
.. | ||
src | ||
.eslintrc.cjs | ||
.mocharc.json | ||
CHANGELOG.md | ||
README.md | ||
karma.conf.cjs | ||
package.json | ||
rollup.config.js | ||
tsconfig.dev.json | ||
tsconfig.json | ||
typedoc.json |
README.md
@waku/message-encryption
Provide Waku Message Version 1 payload encryption as defined in 26/WAKU2-PAYLOAD.
Symmetric Encryption
Symmetric encryption uses a unique key to encrypt and decrypt messages.
import {
createDecoder,
createEncoder,
generateSymmetricKey
} from "@waku/message-encryption/symmetric";
// Generate a random key
const key = generateSymmetricKey();
// To send messages, create an encoder
const encoder = createEncoder(contentTopic, key);
// For example
waku.lightPush.push(encoder, { payload });
// To receive messages, create a decoder
const decoder = createDecoder(contentTopic, key);
// For example
await waku.store.queryOrderedCallback([decoder], (msg) => {
// ...
});
ECIES Encryption
ECIES encryption enables encryption for a public key and decryption using a private key.
import {
createDecoder,
createEncoder,
generatePrivateKey,
getPublicKey
} from "@waku/message-encryption/ecies";
// Generate a random private key
const privateKey = generatePrivateKey();
// Keep the private key secure, provide the public key to the sender
const publicKey = getPublicKey(privateKey);
// To send messages, create an encoder
const encoder = createEncoder(contentTopic, publicKey);
// For example
waku.lightPush.push(encoder, { payload });
// To receive messages, create a decoder
const decoder = createDecoder(contentTopic, privateKey);
// For example
await waku.store.queryOrderedCallback([decoder], (msg) => {
// ...
});