mirror of
https://github.com/logos-messaging/js-noise.git
synced 2026-01-02 13:43:08 +00:00
fix!: update to latest waku + use ISender
This commit is contained in:
commit
3201743ed7
1598
package-lock.json
generated
1598
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,7 @@
|
|||||||
"@types/uuid": "^8.3.0",
|
"@types/uuid": "^8.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
"@waku/interfaces": "^0.0.7",
|
"@waku/interfaces": "0.0.11",
|
||||||
"app-root-path": "^3.0.0",
|
"app-root-path": "^3.0.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"cspell": "^5.14.0",
|
"cspell": "^5.14.0",
|
||||||
@ -121,8 +121,8 @@
|
|||||||
"@stablelib/random": "^1.0.2",
|
"@stablelib/random": "^1.0.2",
|
||||||
"@stablelib/sha256": "^1.0.1",
|
"@stablelib/sha256": "^1.0.1",
|
||||||
"@stablelib/x25519": "^1.0.1",
|
"@stablelib/x25519": "^1.0.1",
|
||||||
"@waku/core": "^0.0.10",
|
"@waku/core": "0.0.16",
|
||||||
"@waku/proto": "^0.0.2",
|
"@waku/proto": "0.0.4",
|
||||||
"bn.js": "^5.2.1",
|
"bn.js": "^5.2.1",
|
||||||
"eventemitter3": "^5.0.0",
|
"eventemitter3": "^5.0.0",
|
||||||
"p-event": "^5.0.1",
|
"p-event": "^5.0.1",
|
||||||
|
|||||||
16
src/codec.ts
16
src/codec.ts
@ -1,4 +1,4 @@
|
|||||||
import { DecodedMessage } from "@waku/core";
|
import { DecodedMessage } from "@waku/core/lib/message/version_0";
|
||||||
import type { IDecodedMessage, IDecoder, IEncoder, IMessage, IProtoMessage } from "@waku/interfaces";
|
import type { IDecodedMessage, IDecoder, IEncoder, IMessage, IProtoMessage } from "@waku/interfaces";
|
||||||
import { WakuMessage } from "@waku/proto";
|
import { WakuMessage } from "@waku/proto";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
@ -52,6 +52,7 @@ export class NoiseHandshakeEncoder implements IEncoder {
|
|||||||
rateLimitProof: undefined,
|
rateLimitProof: undefined,
|
||||||
payload: this.hsStepResult.payload2.serialize(),
|
payload: this.hsStepResult.payload2.serialize(),
|
||||||
version: version,
|
version: version,
|
||||||
|
meta: undefined,
|
||||||
contentTopic: this.contentTopic,
|
contentTopic: this.contentTopic,
|
||||||
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
||||||
};
|
};
|
||||||
@ -74,7 +75,7 @@ export class NoiseHandshakeDecoder implements IDecoder<NoiseHandshakeMessage> {
|
|||||||
return Promise.resolve(protoMessage as IProtoMessage);
|
return Promise.resolve(protoMessage as IProtoMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fromProtoObj(proto: IProtoMessage): Promise<NoiseHandshakeMessage | undefined> {
|
async fromProtoObj(pubSubTopic: string, proto: IProtoMessage): Promise<NoiseHandshakeMessage | undefined> {
|
||||||
// https://github.com/status-im/js-waku/issues/921
|
// https://github.com/status-im/js-waku/issues/921
|
||||||
if (proto.version === undefined) {
|
if (proto.version === undefined) {
|
||||||
proto.version = 0;
|
proto.version = 0;
|
||||||
@ -90,7 +91,7 @@ export class NoiseHandshakeDecoder implements IDecoder<NoiseHandshakeMessage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NoiseHandshakeMessage(proto);
|
return new NoiseHandshakeMessage(pubSubTopic, proto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +102,8 @@ export class NoiseHandshakeDecoder implements IDecoder<NoiseHandshakeMessage> {
|
|||||||
export class NoiseSecureMessage extends DecodedMessage implements IDecodedMessage {
|
export class NoiseSecureMessage extends DecodedMessage implements IDecodedMessage {
|
||||||
private readonly _decodedPayload: Uint8Array;
|
private readonly _decodedPayload: Uint8Array;
|
||||||
|
|
||||||
constructor(proto: WakuMessage, decodedPayload: Uint8Array) {
|
constructor(pubSubTopic: string, proto: WakuMessage, decodedPayload: Uint8Array) {
|
||||||
super(proto);
|
super(pubSubTopic, proto);
|
||||||
this._decodedPayload = decodedPayload;
|
this._decodedPayload = decodedPayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +147,7 @@ export class NoiseSecureTransferEncoder implements IEncoder {
|
|||||||
rateLimitProof: undefined,
|
rateLimitProof: undefined,
|
||||||
ephemeral: this.ephemeral,
|
ephemeral: this.ephemeral,
|
||||||
version: version,
|
version: version,
|
||||||
|
meta: undefined,
|
||||||
contentTopic: this.contentTopic,
|
contentTopic: this.contentTopic,
|
||||||
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
||||||
};
|
};
|
||||||
@ -171,7 +173,7 @@ export class NoiseSecureTransferDecoder implements IDecoder<NoiseSecureMessage>
|
|||||||
return Promise.resolve(protoMessage as IProtoMessage);
|
return Promise.resolve(protoMessage as IProtoMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fromProtoObj(proto: IProtoMessage): Promise<NoiseSecureMessage | undefined> {
|
async fromProtoObj(pubSubTopic: string, proto: IProtoMessage): Promise<NoiseSecureMessage | undefined> {
|
||||||
// https://github.com/status-im/js-waku/issues/921
|
// https://github.com/status-im/js-waku/issues/921
|
||||||
if (proto.version === undefined) {
|
if (proto.version === undefined) {
|
||||||
proto.version = 0;
|
proto.version = 0;
|
||||||
@ -187,7 +189,7 @@ export class NoiseSecureTransferDecoder implements IDecoder<NoiseSecureMessage>
|
|||||||
try {
|
try {
|
||||||
const payloadV2 = PayloadV2.deserialize(proto.payload);
|
const payloadV2 = PayloadV2.deserialize(proto.payload);
|
||||||
const decryptedPayload = this.hsResult.readMessage(payloadV2);
|
const decryptedPayload = this.hsResult.readMessage(payloadV2);
|
||||||
return new NoiseSecureMessage(proto, decryptedPayload);
|
return new NoiseSecureMessage(pubSubTopic, proto, decryptedPayload);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log("could not decode message ", err);
|
log("could not decode message ", err);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import {
|
|||||||
StepHandshakeParameters,
|
StepHandshakeParameters,
|
||||||
} from "./handshake.js";
|
} from "./handshake.js";
|
||||||
import { MessageNametagBuffer } from "./messagenametag.js";
|
import { MessageNametagBuffer } from "./messagenametag.js";
|
||||||
import { InitiatorParameters, Responder, ResponderParameters, Sender, WakuPairing } from "./pairing.js";
|
import { InitiatorParameters, Responder, ResponderParameters, WakuPairing } from "./pairing.js";
|
||||||
import {
|
import {
|
||||||
HandshakePattern,
|
HandshakePattern,
|
||||||
MessageDirection,
|
MessageDirection,
|
||||||
@ -49,4 +49,4 @@ export { ChaChaPolyCipherState, NoisePublicKey };
|
|||||||
export { MessageNametagBuffer };
|
export { MessageNametagBuffer };
|
||||||
export { NoiseHandshakeDecoder, NoiseHandshakeEncoder, NoiseSecureTransferDecoder, NoiseSecureTransferEncoder };
|
export { NoiseHandshakeDecoder, NoiseHandshakeEncoder, NoiseSecureTransferDecoder, NoiseSecureTransferEncoder };
|
||||||
export { QR };
|
export { QR };
|
||||||
export { InitiatorParameters, ResponderParameters, Sender, Responder, WakuPairing };
|
export { InitiatorParameters, ResponderParameters, Responder, WakuPairing };
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { HMACDRBG } from "@stablelib/hmac-drbg";
|
import { HMACDRBG } from "@stablelib/hmac-drbg";
|
||||||
import { randomBytes } from "@stablelib/random";
|
import { randomBytes } from "@stablelib/random";
|
||||||
import type { IDecoder, IEncoder, IMessage } from "@waku/interfaces";
|
import type { IDecoder, IEncoder, IMessage, ISender } from "@waku/interfaces";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { EventEmitter } from "eventemitter3";
|
import { EventEmitter } from "eventemitter3";
|
||||||
import { pEvent } from "p-event";
|
import { pEvent } from "p-event";
|
||||||
@ -11,6 +11,8 @@ import { generateX25519KeyPair } from "./crypto";
|
|||||||
import { MessageNametagBufferSize } from "./messagenametag";
|
import { MessageNametagBufferSize } from "./messagenametag";
|
||||||
import { ResponderParameters, WakuPairing } from "./pairing";
|
import { ResponderParameters, WakuPairing } from "./pairing";
|
||||||
|
|
||||||
|
const PUBSUB_TOPIC = "default";
|
||||||
|
|
||||||
describe("js-noise: pairing object", () => {
|
describe("js-noise: pairing object", () => {
|
||||||
const rng = new HMACDRBG();
|
const rng = new HMACDRBG();
|
||||||
|
|
||||||
@ -23,10 +25,13 @@ describe("js-noise: pairing object", () => {
|
|||||||
// =================
|
// =================
|
||||||
// Simulate waku. This code is not meant to be used IRL
|
// Simulate waku. This code is not meant to be used IRL
|
||||||
const msgEmitter = new EventEmitter();
|
const msgEmitter = new EventEmitter();
|
||||||
const sender = {
|
const sender: ISender = {
|
||||||
async publish(encoder: IEncoder, msg: IMessage): Promise<void> {
|
async send(encoder: IEncoder, msg: IMessage) {
|
||||||
const protoMsg = await encoder.toProtoObj(msg);
|
const protoMsg = await encoder.toProtoObj(msg);
|
||||||
msgEmitter.emit(encoder.contentTopic, protoMsg);
|
msgEmitter.emit(encoder.contentTopic, protoMsg);
|
||||||
|
return {
|
||||||
|
recipients: [],
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const decoderMap: { [key: string]: IDecoder<NoiseHandshakeMessage> } = {};
|
const decoderMap: { [key: string]: IDecoder<NoiseHandshakeMessage> } = {};
|
||||||
@ -39,7 +44,7 @@ describe("js-noise: pairing object", () => {
|
|||||||
},
|
},
|
||||||
async nextMessage(contentTopic: string): Promise<NoiseHandshakeMessage> {
|
async nextMessage(contentTopic: string): Promise<NoiseHandshakeMessage> {
|
||||||
const msg = await pEvent(msgEmitter, contentTopic);
|
const msg = await pEvent(msgEmitter, contentTopic);
|
||||||
const decodedMessage = await decoderMap[contentTopic].fromProtoObj(msg);
|
const decodedMessage = await decoderMap[contentTopic].fromProtoObj(PUBSUB_TOPIC, msg);
|
||||||
return decodedMessage!;
|
return decodedMessage!;
|
||||||
},
|
},
|
||||||
async stop(contentTopic: string): Promise<void> {
|
async stop(contentTopic: string): Promise<void> {
|
||||||
@ -81,7 +86,7 @@ describe("js-noise: pairing object", () => {
|
|||||||
let message = randomBytes(32, rng);
|
let message = randomBytes(32, rng);
|
||||||
let encodedMsg = await aliceEncoder.toWire({ payload: message });
|
let encodedMsg = await aliceEncoder.toWire({ payload: message });
|
||||||
let readMessageProto = await bobDecoder.fromWireToProtoObj(encodedMsg!);
|
let readMessageProto = await bobDecoder.fromWireToProtoObj(encodedMsg!);
|
||||||
let readMessage = await bobDecoder.fromProtoObj(readMessageProto!);
|
let readMessage = await bobDecoder.fromProtoObj(PUBSUB_TOPIC, readMessageProto!);
|
||||||
|
|
||||||
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
||||||
|
|
||||||
@ -89,7 +94,7 @@ describe("js-noise: pairing object", () => {
|
|||||||
message = randomBytes(32, rng);
|
message = randomBytes(32, rng);
|
||||||
encodedMsg = await bobEncoder.toWire({ payload: message });
|
encodedMsg = await bobEncoder.toWire({ payload: message });
|
||||||
readMessageProto = await aliceDecoder.fromWireToProtoObj(encodedMsg!);
|
readMessageProto = await aliceDecoder.fromWireToProtoObj(encodedMsg!);
|
||||||
readMessage = await aliceDecoder.fromProtoObj(readMessageProto!);
|
readMessage = await aliceDecoder.fromProtoObj(PUBSUB_TOPIC, readMessageProto!);
|
||||||
|
|
||||||
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { HMACDRBG } from "@stablelib/hmac-drbg";
|
import { HMACDRBG } from "@stablelib/hmac-drbg";
|
||||||
import { randomBytes } from "@stablelib/random";
|
import { randomBytes } from "@stablelib/random";
|
||||||
import type { IDecoder, IEncoder, IMessage } from "@waku/interfaces";
|
import type { IDecoder, ISender } from "@waku/interfaces";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
import { EventEmitter } from "eventemitter3";
|
import { EventEmitter } from "eventemitter3";
|
||||||
import { pEvent } from "p-event";
|
import { pEvent } from "p-event";
|
||||||
@ -23,18 +23,6 @@ import { QR } from "./qr.js";
|
|||||||
|
|
||||||
const log = debug("waku:noise:pairing");
|
const log = debug("waku:noise:pairing");
|
||||||
|
|
||||||
/**
|
|
||||||
* Sender interface that an object must implement so the pairing object can publish noise messages
|
|
||||||
*/
|
|
||||||
export interface Sender {
|
|
||||||
/**
|
|
||||||
* Publish a message
|
|
||||||
* @param encoder NoiseHandshakeEncoder encoder to use to encrypt the messages
|
|
||||||
* @param msg message to broadcast
|
|
||||||
*/
|
|
||||||
publish(encoder: IEncoder, msg: IMessage): Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responder interface than an object must implement so the pairing object can receive noise messages
|
* Responder interface than an object must implement so the pairing object can receive noise messages
|
||||||
*/
|
*/
|
||||||
@ -122,7 +110,7 @@ export class WakuPairing {
|
|||||||
* @param myEphemeralKey optional ephemeral key
|
* @param myEphemeralKey optional ephemeral key
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private sender: Sender,
|
private sender: ISender,
|
||||||
private responder: Responder,
|
private responder: Responder,
|
||||||
private myStaticKey: KeyPair,
|
private myStaticKey: KeyPair,
|
||||||
pairingParameters: InitiatorParameters | ResponderParameters,
|
pairingParameters: InitiatorParameters | ResponderParameters,
|
||||||
@ -258,7 +246,9 @@ export class WakuPairing {
|
|||||||
// We prepare a message from initiator's payload2
|
// We prepare a message from initiator's payload2
|
||||||
// At this point wakuMsg is sent over the Waku network to responder content topic
|
// At this point wakuMsg is sent over the Waku network to responder content topic
|
||||||
let encoder = new NoiseHandshakeEncoder(this.contentTopic, hsStep);
|
let encoder = new NoiseHandshakeEncoder(this.contentTopic, hsStep);
|
||||||
await this.sender.publish(encoder, {});
|
await this.sender.send(encoder, {
|
||||||
|
payload: new Uint8Array(),
|
||||||
|
});
|
||||||
|
|
||||||
// We generate an authorization code using the handshake state
|
// We generate an authorization code using the handshake state
|
||||||
// this check has to be confirmed with a user interaction, comparing auth codes in both ends
|
// this check has to be confirmed with a user interaction, comparing auth codes in both ends
|
||||||
@ -294,7 +284,9 @@ export class WakuPairing {
|
|||||||
});
|
});
|
||||||
|
|
||||||
encoder = new NoiseHandshakeEncoder(this.contentTopic, hsStep);
|
encoder = new NoiseHandshakeEncoder(this.contentTopic, hsStep);
|
||||||
await this.sender.publish(encoder, {});
|
await this.sender.send(encoder, {
|
||||||
|
payload: new Uint8Array(),
|
||||||
|
});
|
||||||
|
|
||||||
// Secure Transfer Phase
|
// Secure Transfer Phase
|
||||||
this.handshakeResult = this.handshake.finalizeHandshake();
|
this.handshakeResult = this.handshake.finalizeHandshake();
|
||||||
@ -333,7 +325,9 @@ export class WakuPairing {
|
|||||||
|
|
||||||
// We prepare a Waku message from responder's payload2
|
// We prepare a Waku message from responder's payload2
|
||||||
const encoder = new NoiseHandshakeEncoder(this.contentTopic, hsStep);
|
const encoder = new NoiseHandshakeEncoder(this.contentTopic, hsStep);
|
||||||
await this.sender.publish(encoder, {});
|
await this.sender.send(encoder, {
|
||||||
|
payload: new Uint8Array(),
|
||||||
|
});
|
||||||
|
|
||||||
// 3rd step
|
// 3rd step
|
||||||
// -> sA, sAeB, sAsB {s}
|
// -> sA, sAeB, sAsB {s}
|
||||||
|
|||||||
@ -16,6 +16,8 @@ import { NoiseHandshakePatterns } from "./patterns";
|
|||||||
import { NoisePublicKey } from "./publickey";
|
import { NoisePublicKey } from "./publickey";
|
||||||
import { QR } from "./qr";
|
import { QR } from "./qr";
|
||||||
|
|
||||||
|
const PUBSUB_TOPIC = "default";
|
||||||
|
|
||||||
describe("Waku Noise Sessions", () => {
|
describe("Waku Noise Sessions", () => {
|
||||||
const rng = new HMACDRBG();
|
const rng = new HMACDRBG();
|
||||||
|
|
||||||
@ -113,12 +115,12 @@ describe("Waku Noise Sessions", () => {
|
|||||||
// We prepare a Waku message from Alice's payload2
|
// We prepare a Waku message from Alice's payload2
|
||||||
// At this point wakuMsg is sent over the Waku network and is received
|
// At this point wakuMsg is sent over the Waku network and is received
|
||||||
// We simulate this by creating the ProtoBuffer from wakuMsg
|
// We simulate this by creating the ProtoBuffer from wakuMsg
|
||||||
let wakuMsgBytes = await encoder.toWire({});
|
let wakuMsgBytes = await encoder.toWire({ payload: new Uint8Array() });
|
||||||
|
|
||||||
// We decode the WakuMessage from the ProtoBuffer
|
// We decode the WakuMessage from the ProtoBuffer
|
||||||
let decoder = new NoiseHandshakeDecoder(contentTopic);
|
let decoder = new NoiseHandshakeDecoder(contentTopic);
|
||||||
let wakuMsgProto = await decoder.fromWireToProtoObj(wakuMsgBytes!);
|
let wakuMsgProto = await decoder.fromWireToProtoObj(wakuMsgBytes!);
|
||||||
let v2Msg = await decoder.fromProtoObj(wakuMsgProto!);
|
let v2Msg = await decoder.fromProtoObj(PUBSUB_TOPIC, wakuMsgProto!);
|
||||||
|
|
||||||
expect(v2Msg!.contentTopic).to.be.equals(contentTopic);
|
expect(v2Msg!.contentTopic).to.be.equals(contentTopic);
|
||||||
expect(v2Msg?.payloadV2.equals(aliceStep.payload2)).to.be.true;
|
expect(v2Msg?.payloadV2.equals(aliceStep.payload2)).to.be.true;
|
||||||
@ -155,12 +157,12 @@ describe("Waku Noise Sessions", () => {
|
|||||||
|
|
||||||
// At this point wakuMsg is sent over the Waku network and is received
|
// At this point wakuMsg is sent over the Waku network and is received
|
||||||
// We simulate this by creating the ProtoBuffer from wakuMsg
|
// We simulate this by creating the ProtoBuffer from wakuMsg
|
||||||
wakuMsgBytes = await encoder.toWire({});
|
wakuMsgBytes = await encoder.toWire({ payload: new Uint8Array() });
|
||||||
|
|
||||||
// We decode the WakuMessage from the ProtoBuffer
|
// We decode the WakuMessage from the ProtoBuffer
|
||||||
decoder = new NoiseHandshakeDecoder(contentTopic);
|
decoder = new NoiseHandshakeDecoder(contentTopic);
|
||||||
wakuMsgProto = await decoder.fromWireToProtoObj(wakuMsgBytes!);
|
wakuMsgProto = await decoder.fromWireToProtoObj(wakuMsgBytes!);
|
||||||
v2Msg = await decoder.fromProtoObj(wakuMsgProto!);
|
v2Msg = await decoder.fromProtoObj(PUBSUB_TOPIC, wakuMsgProto!);
|
||||||
|
|
||||||
expect(v2Msg?.payloadV2.equals(bobStep.payload2)).to.be.true;
|
expect(v2Msg?.payloadV2.equals(bobStep.payload2)).to.be.true;
|
||||||
|
|
||||||
@ -192,12 +194,12 @@ describe("Waku Noise Sessions", () => {
|
|||||||
|
|
||||||
// At this point wakuMsg is sent over the Waku network and is received
|
// At this point wakuMsg is sent over the Waku network and is received
|
||||||
// We simulate this by creating the ProtoBuffer from wakuMsg
|
// We simulate this by creating the ProtoBuffer from wakuMsg
|
||||||
wakuMsgBytes = await encoder.toWire({});
|
wakuMsgBytes = await encoder.toWire({ payload: new Uint8Array() });
|
||||||
|
|
||||||
// We decode the WakuMessage from the ProtoBuffer
|
// We decode the WakuMessage from the ProtoBuffer
|
||||||
decoder = new NoiseHandshakeDecoder(contentTopic);
|
decoder = new NoiseHandshakeDecoder(contentTopic);
|
||||||
wakuMsgProto = await decoder.fromWireToProtoObj(wakuMsgBytes!);
|
wakuMsgProto = await decoder.fromWireToProtoObj(wakuMsgBytes!);
|
||||||
v2Msg = await decoder.fromProtoObj(wakuMsgProto!);
|
v2Msg = await decoder.fromProtoObj(PUBSUB_TOPIC, wakuMsgProto!);
|
||||||
|
|
||||||
expect(v2Msg?.payloadV2.equals(aliceStep.payload2)).to.be.true;
|
expect(v2Msg?.payloadV2.equals(aliceStep.payload2)).to.be.true;
|
||||||
|
|
||||||
@ -231,7 +233,7 @@ describe("Waku Noise Sessions", () => {
|
|||||||
let message = randomBytes(32, rng);
|
let message = randomBytes(32, rng);
|
||||||
let encodedMsg = await aliceEncoder.toWire({ payload: message });
|
let encodedMsg = await aliceEncoder.toWire({ payload: message });
|
||||||
let readMessageProto = await bobDecoder.fromWireToProtoObj(encodedMsg!);
|
let readMessageProto = await bobDecoder.fromWireToProtoObj(encodedMsg!);
|
||||||
let readMessage = await bobDecoder.fromProtoObj(readMessageProto!);
|
let readMessage = await bobDecoder.fromProtoObj(PUBSUB_TOPIC, readMessageProto!);
|
||||||
|
|
||||||
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
||||||
|
|
||||||
@ -239,7 +241,7 @@ describe("Waku Noise Sessions", () => {
|
|||||||
message = randomBytes(32, rng);
|
message = randomBytes(32, rng);
|
||||||
encodedMsg = await bobEncoder.toWire({ payload: message });
|
encodedMsg = await bobEncoder.toWire({ payload: message });
|
||||||
readMessageProto = await aliceDecoder.fromWireToProtoObj(encodedMsg!);
|
readMessageProto = await aliceDecoder.fromWireToProtoObj(encodedMsg!);
|
||||||
readMessage = await aliceDecoder.fromProtoObj(readMessageProto!);
|
readMessage = await aliceDecoder.fromProtoObj(PUBSUB_TOPIC, readMessageProto!);
|
||||||
|
|
||||||
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
expect(uint8ArrayEquals(message, readMessage!.payload)).to.be.true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user