mirror of
https://github.com/logos-messaging/js-noise.git
synced 2026-01-07 16:13:08 +00:00
chore: duplicate PR#57 and update lock
This commit is contained in:
parent
dc9b7974bb
commit
4f925c6599
3458
package-lock.json
generated
3458
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.12",
|
"@waku/interfaces": "0.0.23",
|
||||||
"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.17",
|
"@waku/core": "0.0.28",
|
||||||
"@waku/proto": "0.0.4",
|
"@waku/proto": "0.0.6",
|
||||||
"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",
|
||||||
|
|||||||
22
src/codec.ts
22
src/codec.ts
@ -1,5 +1,13 @@
|
|||||||
import { DecodedMessage } from "@waku/core/lib/message/version_0";
|
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 { WakuMessage } from "@waku/proto";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
||||||
@ -17,6 +25,8 @@ const version = 2;
|
|||||||
* Used internally in the pairing object to represent a handshake message
|
* Used internally in the pairing object to represent a handshake message
|
||||||
*/
|
*/
|
||||||
export class NoiseHandshakeMessage extends DecodedMessage implements IDecodedMessage {
|
export class NoiseHandshakeMessage extends DecodedMessage implements IDecodedMessage {
|
||||||
|
pubSubTopic = DefaultPubsubTopic;
|
||||||
|
|
||||||
get payloadV2(): PayloadV2 {
|
get payloadV2(): PayloadV2 {
|
||||||
if (!this.payload) throw new Error("no payload available");
|
if (!this.payload) throw new Error("no payload available");
|
||||||
return PayloadV2.deserialize(this.payload);
|
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 hsStepResult the result of a step executed while performing the handshake process
|
||||||
* @param ephemeral makes messages ephemeral in the Waku network
|
* @param ephemeral makes messages ephemeral in the Waku network
|
||||||
*/
|
*/
|
||||||
|
pubsubTopic = DefaultPubsubTopic;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public contentTopic: string,
|
public contentTopic: string,
|
||||||
private hsStepResult: HandshakeStepResult,
|
private hsStepResult: HandshakeStepResult,
|
||||||
@ -67,6 +79,8 @@ export class NoiseHandshakeDecoder implements IDecoder<NoiseHandshakeMessage> {
|
|||||||
/**
|
/**
|
||||||
* @param contentTopic content topic on which the encoded WakuMessages were sent
|
* @param contentTopic content topic on which the encoded WakuMessages were sent
|
||||||
*/
|
*/
|
||||||
|
pubsubTopic = DefaultPubsubTopic;
|
||||||
|
|
||||||
constructor(public contentTopic: string) {}
|
constructor(public contentTopic: string) {}
|
||||||
|
|
||||||
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
||||||
@ -101,10 +115,12 @@ 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;
|
||||||
|
pubsubTopic: string;
|
||||||
|
|
||||||
constructor(pubSubTopic: string, proto: WakuMessage, decodedPayload: Uint8Array) {
|
constructor(pubSubTopic: string, proto: WakuMessage, decodedPayload: Uint8Array) {
|
||||||
super(pubSubTopic, proto);
|
super(pubSubTopic, proto);
|
||||||
this._decodedPayload = decodedPayload;
|
this._decodedPayload = decodedPayload;
|
||||||
|
this.pubsubTopic = pubSubTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
get payload(): Uint8Array {
|
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 ephemeral whether messages should be tagged as ephemeral defaults to true.
|
||||||
* @param metaSetter callback function that set the `meta` field.
|
* @param metaSetter callback function that set the `meta` field.
|
||||||
*/
|
*/
|
||||||
|
pubsubTopic = DefaultPubsubTopic;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public contentTopic: string,
|
public contentTopic: string,
|
||||||
private hsResult: HandshakeResult,
|
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 contentTopic content topic on which the encoded WakuMessages were sent
|
||||||
* @param hsResult handshake result obtained after the handshake is successful
|
* @param hsResult handshake result obtained after the handshake is successful
|
||||||
*/
|
*/
|
||||||
|
pubsubTopic = DefaultPubsubTopic;
|
||||||
|
|
||||||
constructor(public contentTopic: string, private hsResult: HandshakeResult) {}
|
constructor(public contentTopic: string, private hsResult: HandshakeResult) {}
|
||||||
|
|
||||||
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user