mirror of https://github.com/waku-org/js-waku.git
Rename so that it does make dev thinks it's for asymmetric enc only
This commit is contained in:
parent
07cba4f8ca
commit
1d4137e2c4
|
@ -11,8 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Examples (web-chat): New `/fleet` command to switch connection between Status prod and test fleets.
|
||||
- Export `generatePrivateKey` and `getPublicKey` directly from the root.
|
||||
|
||||
### 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.
|
||||
|
||||
### Fix
|
||||
- Align `WakuMessage` readme example with actual code behaviour.
|
||||
- Align `WakuMessage` readme example with actual code behaviour.
|
||||
|
||||
## [0.8.0] - 2021-07-15
|
||||
|
||||
|
|
|
@ -128,13 +128,13 @@ function App() {
|
|||
if (!waku) return;
|
||||
if (!ethDmKeyPair) return;
|
||||
|
||||
waku.relay.addDecryptionPrivateKey(ethDmKeyPair.privateKey);
|
||||
waku.relay.addDecryptionKey(ethDmKeyPair.privateKey);
|
||||
|
||||
return function cleanUp() {
|
||||
if (!waku) return;
|
||||
if (!ethDmKeyPair) return;
|
||||
|
||||
waku.relay.deleteDecryptionPrivateKey(ethDmKeyPair.privateKey);
|
||||
waku.relay.deleteDecryptionKey(ethDmKeyPair.privateKey);
|
||||
};
|
||||
}, [waku, ethDmKeyPair]);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ describe('Waku Message: Node only', function () {
|
|||
|
||||
const privateKey = generatePrivateKey();
|
||||
|
||||
waku.relay.addDecryptionPrivateKey(privateKey);
|
||||
waku.relay.addDecryptionKey(privateKey);
|
||||
|
||||
const receivedMsgPromise: Promise<WakuMessage> = new Promise(
|
||||
(resolve) => {
|
||||
|
@ -118,7 +118,7 @@ describe('Waku Message: Node only', function () {
|
|||
|
||||
const symKey = generatePrivateKey();
|
||||
|
||||
waku.relay.addDecryptionPrivateKey(symKey);
|
||||
waku.relay.addDecryptionKey(symKey);
|
||||
|
||||
const receivedMsgPromise: Promise<WakuMessage> = new Promise(
|
||||
(resolve) => {
|
||||
|
|
|
@ -67,7 +67,7 @@ export class WakuRelay extends Gossipsub {
|
|||
/**
|
||||
* Decryption private keys to use to attempt decryption of incoming messages.
|
||||
*/
|
||||
public decPrivateKeys: Set<Uint8Array>;
|
||||
public decryptionKeys: Set<Uint8Array>;
|
||||
|
||||
/**
|
||||
* observers called when receiving new message.
|
||||
|
@ -91,7 +91,7 @@ export class WakuRelay extends Gossipsub {
|
|||
|
||||
this.heartbeat = new RelayHeartbeat(this);
|
||||
this.observers = {};
|
||||
this.decPrivateKeys = new Set();
|
||||
this.decryptionKeys = new Set();
|
||||
|
||||
const multicodecs = [constants.RelayCodec];
|
||||
|
||||
|
@ -124,21 +124,21 @@ export class WakuRelay extends Gossipsub {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register a decryption private key to attempt decryption of messages of
|
||||
* the given content topic. This can either be a private key for asymmetric
|
||||
* encryption or a symmetric key. Waku relay will attempt to decrypt messages
|
||||
* using both methods.
|
||||
* Register a decryption private key or symmetric key to attempt decryption
|
||||
* of messages received on the given content topic. This can either be a
|
||||
* private key for asymmetric encryption or a symmetric key. Waku relay will
|
||||
* attempt to decrypt messages using both methods.
|
||||
*/
|
||||
addDecryptionPrivateKey(privateKey: Uint8Array): void {
|
||||
this.decPrivateKeys.add(privateKey);
|
||||
addDecryptionKey(privateKey: Uint8Array): void {
|
||||
this.decryptionKeys.add(privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a decryption private key to attempt decryption of messages of
|
||||
* the given content topic.
|
||||
* Delete a decryption key to attempt decryption of messages received on the
|
||||
* given content topic.
|
||||
*/
|
||||
deleteDecryptionPrivateKey(privateKey: Uint8Array): void {
|
||||
this.decPrivateKeys.delete(privateKey);
|
||||
deleteDecryptionKey(privateKey: Uint8Array): void {
|
||||
this.decryptionKeys.delete(privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,7 +210,7 @@ export class WakuRelay extends Gossipsub {
|
|||
subscribe(pubsubTopic: string): void {
|
||||
this.on(pubsubTopic, (event) => {
|
||||
dbg(`Message received on ${pubsubTopic}`);
|
||||
WakuMessage.decode(event.data, Array.from(this.decPrivateKeys))
|
||||
WakuMessage.decode(event.data, Array.from(this.decryptionKeys))
|
||||
.then((wakuMsg) => {
|
||||
if (!wakuMsg) {
|
||||
dbg('Failed to decode Waku Message');
|
||||
|
|
Loading…
Reference in New Issue