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