mirror of https://github.com/waku-org/js-noise.git
chore: duplicate PR#57 and update lock
chore: duplicate PR#57 and update lock
This commit is contained in:
commit
da1f593fb5
File diff suppressed because it is too large
Load Diff
|
@ -59,7 +59,7 @@
|
|||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||
"@typescript-eslint/parser": "^5.8.1",
|
||||
"@waku/interfaces": "0.0.12",
|
||||
"@waku/interfaces": "0.0.23",
|
||||
"app-root-path": "^3.0.0",
|
||||
"chai": "^4.3.4",
|
||||
"cspell": "^5.14.0",
|
||||
|
@ -121,8 +121,8 @@
|
|||
"@stablelib/random": "^1.0.2",
|
||||
"@stablelib/sha256": "^1.0.1",
|
||||
"@stablelib/x25519": "^1.0.1",
|
||||
"@waku/core": "0.0.17",
|
||||
"@waku/proto": "0.0.4",
|
||||
"@waku/core": "0.0.28",
|
||||
"@waku/proto": "0.0.6",
|
||||
"bn.js": "^5.2.1",
|
||||
"eventemitter3": "^5.0.0",
|
||||
"p-event": "^5.0.1",
|
||||
|
@ -130,4 +130,4 @@
|
|||
"uint8arraylist": "^2.3.2",
|
||||
"uint8arrays": "^4.0.2"
|
||||
}
|
||||
}
|
||||
}
|
22
src/codec.ts
22
src/codec.ts
|
@ -1,5 +1,13 @@
|
|||
import { DecodedMessage } from "@waku/core/lib/message/version_0";
|
||||
import type { IDecodedMessage, IDecoder, IEncoder, IMessage, IMetaSetter, IProtoMessage } from "@waku/interfaces";
|
||||
import {
|
||||
DefaultPubsubTopic,
|
||||
type IDecodedMessage,
|
||||
type IDecoder,
|
||||
type IEncoder,
|
||||
type IMessage,
|
||||
type IMetaSetter,
|
||||
type IProtoMessage,
|
||||
} from "@waku/interfaces";
|
||||
import { WakuMessage } from "@waku/proto";
|
||||
import debug from "debug";
|
||||
|
||||
|
@ -17,6 +25,8 @@ const version = 2;
|
|||
* Used internally in the pairing object to represent a handshake message
|
||||
*/
|
||||
export class NoiseHandshakeMessage extends DecodedMessage implements IDecodedMessage {
|
||||
pubSubTopic = DefaultPubsubTopic;
|
||||
|
||||
get payloadV2(): PayloadV2 {
|
||||
if (!this.payload) throw new Error("no payload available");
|
||||
return PayloadV2.deserialize(this.payload);
|
||||
|
@ -33,6 +43,8 @@ export class NoiseHandshakeEncoder implements IEncoder {
|
|||
* @param hsStepResult the result of a step executed while performing the handshake process
|
||||
* @param ephemeral makes messages ephemeral in the Waku network
|
||||
*/
|
||||
pubsubTopic = DefaultPubsubTopic;
|
||||
|
||||
constructor(
|
||||
public contentTopic: string,
|
||||
private hsStepResult: HandshakeStepResult,
|
||||
|
@ -67,6 +79,8 @@ export class NoiseHandshakeDecoder implements IDecoder<NoiseHandshakeMessage> {
|
|||
/**
|
||||
* @param contentTopic content topic on which the encoded WakuMessages were sent
|
||||
*/
|
||||
pubsubTopic = DefaultPubsubTopic;
|
||||
|
||||
constructor(public contentTopic: string) {}
|
||||
|
||||
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
||||
|
@ -101,10 +115,12 @@ export class NoiseHandshakeDecoder implements IDecoder<NoiseHandshakeMessage> {
|
|||
*/
|
||||
export class NoiseSecureMessage extends DecodedMessage implements IDecodedMessage {
|
||||
private readonly _decodedPayload: Uint8Array;
|
||||
pubsubTopic: string;
|
||||
|
||||
constructor(pubSubTopic: string, proto: WakuMessage, decodedPayload: Uint8Array) {
|
||||
super(pubSubTopic, proto);
|
||||
this._decodedPayload = decodedPayload;
|
||||
this.pubsubTopic = pubSubTopic;
|
||||
}
|
||||
|
||||
get payload(): Uint8Array {
|
||||
|
@ -125,6 +141,8 @@ export class NoiseSecureTransferEncoder implements IEncoder {
|
|||
* @param ephemeral whether messages should be tagged as ephemeral defaults to true.
|
||||
* @param metaSetter callback function that set the `meta` field.
|
||||
*/
|
||||
pubsubTopic = DefaultPubsubTopic;
|
||||
|
||||
constructor(
|
||||
public contentTopic: string,
|
||||
private hsResult: HandshakeResult,
|
||||
|
@ -179,6 +197,8 @@ export class NoiseSecureTransferDecoder implements IDecoder<NoiseSecureMessage>
|
|||
* @param contentTopic content topic on which the encoded WakuMessages were sent
|
||||
* @param hsResult handshake result obtained after the handshake is successful
|
||||
*/
|
||||
pubsubTopic = DefaultPubsubTopic;
|
||||
|
||||
constructor(public contentTopic: string, private hsResult: HandshakeResult) {}
|
||||
|
||||
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
||||
|
|
|
@ -39,7 +39,7 @@ describe("js-noise: pairing object", () => {
|
|||
const protoMsg = await encoder.toProtoObj(msg);
|
||||
msgEmitter.emit(encoder.contentTopic, protoMsg);
|
||||
return {
|
||||
recipients: [],
|
||||
successes: [],
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue