mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 14:12:30 +00:00
Create skeleton
This commit is contained in:
parent
90e16e2abe
commit
b69769f8dd
@ -1,3 +0,0 @@
|
||||
export function encrypt() {
|
||||
return "Encrypt world";
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
import { encrypt } from './encrypt';
|
||||
|
||||
const tag = '/noise';
|
||||
import { Noise } from './noise';
|
||||
|
||||
export {
|
||||
tag,
|
||||
encrypt,
|
||||
Noise,
|
||||
}
|
||||
|
17
src/noise.ts
Normal file
17
src/noise.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { bytes } from "./types/basic";
|
||||
import { Connection } from "./types/libp2p";
|
||||
|
||||
export class Noise {
|
||||
constructor(privateKey: bytes, staticNoiseKey?: bytes, earlyData?: bytes) {
|
||||
|
||||
}
|
||||
|
||||
public tag() {
|
||||
return '/noise';
|
||||
}
|
||||
|
||||
public encrypt(InsecureConnection: Connection, remotePublicKey: bytes) {
|
||||
|
||||
}
|
||||
|
||||
}
|
15
src/types/libp2p.ts
Normal file
15
src/types/libp2p.ts
Normal file
@ -0,0 +1,15 @@
|
||||
type PeerId = {
|
||||
id: string,
|
||||
privKey: string,
|
||||
pubKey: string,
|
||||
};
|
||||
|
||||
type ConnectionStat = {
|
||||
direction: "inbound" | "outbound",
|
||||
}
|
||||
|
||||
export interface Connection {
|
||||
localPeer: PeerId,
|
||||
remotePeer: PeerId,
|
||||
stat: ConnectionStat,
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
import { expect } from "chai";
|
||||
import { tag, encrypt} from "../src";
|
||||
import { Noise } from "../src";
|
||||
|
||||
describe("Index", () => {
|
||||
it("should expose right tag and encrypt function", () => {
|
||||
expect(tag).to.equal('/noise');
|
||||
expect(typeof(encrypt)).to.equal('function');
|
||||
it("should expose class with tag and encrypt functions", () => {
|
||||
const noise = new Noise(Buffer.from("privatekey"));
|
||||
expect(noise.tag()).to.equal('/noise');
|
||||
expect(typeof(noise.encrypt)).to.equal('function');
|
||||
})
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user