mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 17:12:33 +00:00
Rename to remoteEarlyData
This commit is contained in:
parent
9b650d5b5f
commit
7625aa8e46
@ -5,7 +5,7 @@ import PeerId from "peer-id";
|
||||
export interface IHandshake {
|
||||
session: NoiseSession;
|
||||
remotePeer: PeerId;
|
||||
earlyData: Buffer;
|
||||
remoteEarlyData: Buffer;
|
||||
encrypt(plaintext: bytes, session: NoiseSession): bytes;
|
||||
decrypt(ciphertext: bytes, session: NoiseSession): {plaintext: bytes; valid: boolean};
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export interface INoiseConnection {
|
||||
|
||||
export type SecureOutbound = {
|
||||
conn: any;
|
||||
earlyData: Buffer;
|
||||
remoteEarlyData: Buffer;
|
||||
remotePeer: PeerId;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ export class IKHandshake implements IHandshake {
|
||||
public isInitiator: boolean;
|
||||
public session: NoiseSession;
|
||||
public remotePeer!: PeerId;
|
||||
public earlyData: Buffer;
|
||||
public remoteEarlyData: Buffer;
|
||||
|
||||
private payload: bytes;
|
||||
private prologue: bytes32;
|
||||
@ -43,7 +43,7 @@ export class IKHandshake implements IHandshake {
|
||||
}
|
||||
this.ik = handshake || new IK();
|
||||
this.session = this.ik.initSession(this.isInitiator, this.prologue, this.staticKeypair, remoteStaticKey);
|
||||
this.earlyData = Buffer.alloc(0)
|
||||
this.remoteEarlyData = Buffer.alloc(0)
|
||||
}
|
||||
|
||||
public async stage0(): Promise<void> {
|
||||
|
@ -67,7 +67,7 @@ export class XXFallbackHandshake extends XXHandshake {
|
||||
this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload);
|
||||
await verifySignedPayload(this.session.hs.rs, decodedPayload, this.remotePeer);
|
||||
if(decodedPayload.data){
|
||||
this.earlyData = Buffer.from(
|
||||
this.remoteEarlyData = Buffer.from(
|
||||
decodedPayload.data.buffer,
|
||||
decodedPayload.data.byteOffset,
|
||||
decodedPayload.data.length
|
||||
|
@ -19,7 +19,7 @@ export class XXHandshake implements IHandshake {
|
||||
public isInitiator: boolean;
|
||||
public session: NoiseSession;
|
||||
public remotePeer!: PeerId;
|
||||
public earlyData: Buffer;
|
||||
public remoteEarlyData: Buffer;
|
||||
|
||||
protected payload: bytes;
|
||||
protected connection: WrappedConnection;
|
||||
@ -47,7 +47,7 @@ export class XXHandshake implements IHandshake {
|
||||
}
|
||||
this.xx = handshake || new XX();
|
||||
this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeypair);
|
||||
this.earlyData = Buffer.alloc(0)
|
||||
this.remoteEarlyData = Buffer.alloc(0)
|
||||
}
|
||||
|
||||
// stage 0
|
||||
@ -153,7 +153,7 @@ export class XXHandshake implements IHandshake {
|
||||
|
||||
private setEarlyData(data: Uint8Array|null|undefined): void {
|
||||
if(data){
|
||||
this.earlyData = Buffer.from(data.buffer, data.byteOffset, data.length);
|
||||
this.remoteEarlyData = Buffer.from(data.buffer, data.byteOffset, data.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ export class Noise implements INoiseConnection {
|
||||
|
||||
return {
|
||||
conn,
|
||||
earlyData: handshake.earlyData,
|
||||
remoteEarlyData: handshake.remoteEarlyData,
|
||||
remotePeer: handshake.remotePeer
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user