This commit is contained in:
Sasha 2024-04-18 23:38:27 +02:00
parent fa5cc104a1
commit 64e59328fa
No known key found for this signature in database
2 changed files with 16 additions and 10 deletions

View File

@ -47,8 +47,7 @@ export class NoiseHandshakeEncoder implements IEncoder {
public pubsubTopic: string, public pubsubTopic: string,
private hsStepResult: HandshakeStepResult, private hsStepResult: HandshakeStepResult,
public ephemeral: boolean = true public ephemeral: boolean = true
) { ) {}
}
async toWire(message: IMessage): Promise<Uint8Array | undefined> { async toWire(message: IMessage): Promise<Uint8Array | undefined> {
const protoMessage = await this.toProtoObj(message); const protoMessage = await this.toProtoObj(message);
@ -80,8 +79,7 @@ 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
*/ */
constructor(public contentTopic: string, public pubsubTopic: string) { constructor(public contentTopic: string, public pubsubTopic: string) {}
}
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> { fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
const protoMessage = WakuMessage.decode(bytes); const protoMessage = WakuMessage.decode(bytes);
@ -149,8 +147,7 @@ export class NoiseSecureTransferEncoder implements IEncoder {
private hsResult: HandshakeResult, private hsResult: HandshakeResult,
public ephemeral: boolean = true, public ephemeral: boolean = true,
public metaSetter?: IMetaSetter public metaSetter?: IMetaSetter
) { ) {}
}
async toWire(message: IMessage): Promise<Uint8Array | undefined> { async toWire(message: IMessage): Promise<Uint8Array | undefined> {
const protoMessage = await this.toProtoObj(message); const protoMessage = await this.toProtoObj(message);
@ -201,8 +198,7 @@ export class NoiseSecureTransferDecoder implements IDecoder<NoiseSecureMessage>
* @param hsResult handshake result obtained after the handshake is successful * @param hsResult handshake result obtained after the handshake is successful
*/ */
constructor(public contentTopic: string, public pubsubTopic: string, private hsResult: HandshakeResult) { constructor(public contentTopic: string, public pubsubTopic: string, private hsResult: HandshakeResult) {}
}
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> { fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
const protoMessage = WakuMessage.decode(bytes); const protoMessage = WakuMessage.decode(bytes);

View File

@ -293,7 +293,12 @@ export class WakuPairing {
this.eventEmitter.emit("pairingComplete"); this.eventEmitter.emit("pairingComplete");
return WakuPairing.getSecureCodec(this.contentTopic, this.pubsubTopic, this.handshakeResult, this.encoderParameters); return WakuPairing.getSecureCodec(
this.contentTopic,
this.pubsubTopic,
this.handshakeResult,
this.encoderParameters
);
} }
private async responderHandshake(): Promise<[NoiseSecureTransferEncoder, NoiseSecureTransferDecoder]> { private async responderHandshake(): Promise<[NoiseSecureTransferEncoder, NoiseSecureTransferDecoder]> {
@ -357,7 +362,12 @@ export class WakuPairing {
this.eventEmitter.emit("pairingComplete"); this.eventEmitter.emit("pairingComplete");
return WakuPairing.getSecureCodec(this.contentTopic, this.pubsubTopic, this.handshakeResult, this.encoderParameters); return WakuPairing.getSecureCodec(
this.contentTopic,
this.pubsubTopic,
this.handshakeResult,
this.encoderParameters
);
} }
/** /**