mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-26 02:22:23 +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 {
|
export interface IHandshake {
|
||||||
session: NoiseSession;
|
session: NoiseSession;
|
||||||
remotePeer: PeerId;
|
remotePeer: PeerId;
|
||||||
earlyData: Buffer;
|
remoteEarlyData: Buffer;
|
||||||
encrypt(plaintext: bytes, session: NoiseSession): bytes;
|
encrypt(plaintext: bytes, session: NoiseSession): bytes;
|
||||||
decrypt(ciphertext: bytes, session: NoiseSession): {plaintext: bytes; valid: boolean};
|
decrypt(ciphertext: bytes, session: NoiseSession): {plaintext: bytes; valid: boolean};
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export interface INoiseConnection {
|
|||||||
|
|
||||||
export type SecureOutbound = {
|
export type SecureOutbound = {
|
||||||
conn: any;
|
conn: any;
|
||||||
earlyData: Buffer;
|
remoteEarlyData: Buffer;
|
||||||
remotePeer: PeerId;
|
remotePeer: PeerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export class IKHandshake implements IHandshake {
|
|||||||
public isInitiator: boolean;
|
public isInitiator: boolean;
|
||||||
public session: NoiseSession;
|
public session: NoiseSession;
|
||||||
public remotePeer!: PeerId;
|
public remotePeer!: PeerId;
|
||||||
public earlyData: Buffer;
|
public remoteEarlyData: Buffer;
|
||||||
|
|
||||||
private payload: bytes;
|
private payload: bytes;
|
||||||
private prologue: bytes32;
|
private prologue: bytes32;
|
||||||
@ -43,7 +43,7 @@ export class IKHandshake implements IHandshake {
|
|||||||
}
|
}
|
||||||
this.ik = handshake || new IK();
|
this.ik = handshake || new IK();
|
||||||
this.session = this.ik.initSession(this.isInitiator, this.prologue, this.staticKeypair, remoteStaticKey);
|
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> {
|
public async stage0(): Promise<void> {
|
||||||
|
@ -67,7 +67,7 @@ export class XXFallbackHandshake extends XXHandshake {
|
|||||||
this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload);
|
this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload);
|
||||||
await verifySignedPayload(this.session.hs.rs, decodedPayload, this.remotePeer);
|
await verifySignedPayload(this.session.hs.rs, decodedPayload, this.remotePeer);
|
||||||
if(decodedPayload.data){
|
if(decodedPayload.data){
|
||||||
this.earlyData = Buffer.from(
|
this.remoteEarlyData = Buffer.from(
|
||||||
decodedPayload.data.buffer,
|
decodedPayload.data.buffer,
|
||||||
decodedPayload.data.byteOffset,
|
decodedPayload.data.byteOffset,
|
||||||
decodedPayload.data.length
|
decodedPayload.data.length
|
||||||
|
@ -19,7 +19,7 @@ export class XXHandshake implements IHandshake {
|
|||||||
public isInitiator: boolean;
|
public isInitiator: boolean;
|
||||||
public session: NoiseSession;
|
public session: NoiseSession;
|
||||||
public remotePeer!: PeerId;
|
public remotePeer!: PeerId;
|
||||||
public earlyData: Buffer;
|
public remoteEarlyData: Buffer;
|
||||||
|
|
||||||
protected payload: bytes;
|
protected payload: bytes;
|
||||||
protected connection: WrappedConnection;
|
protected connection: WrappedConnection;
|
||||||
@ -47,7 +47,7 @@ export class XXHandshake implements IHandshake {
|
|||||||
}
|
}
|
||||||
this.xx = handshake || new XX();
|
this.xx = handshake || new XX();
|
||||||
this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeypair);
|
this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeypair);
|
||||||
this.earlyData = Buffer.alloc(0)
|
this.remoteEarlyData = Buffer.alloc(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// stage 0
|
// stage 0
|
||||||
@ -153,7 +153,7 @@ export class XXHandshake implements IHandshake {
|
|||||||
|
|
||||||
private setEarlyData(data: Uint8Array|null|undefined): void {
|
private setEarlyData(data: Uint8Array|null|undefined): void {
|
||||||
if(data){
|
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 {
|
return {
|
||||||
conn,
|
conn,
|
||||||
earlyData: handshake.earlyData,
|
remoteEarlyData: handshake.remoteEarlyData,
|
||||||
remotePeer: handshake.remotePeer
|
remotePeer: handshake.remotePeer
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user