fix connection encryption and secio interface

This commit is contained in:
Marin Petrunić 2020-04-03 13:33:13 +02:00
parent f69df443d3
commit 3b20692fb2
No known key found for this signature in database
GPG Key ID: 834D07135E110DA5
4 changed files with 16 additions and 19 deletions

View File

@ -1,5 +1,5 @@
{
"name": "@chainsafe/libp2p-ts",
"name": "libp2p-ts",
"version": "0.1.0",
"description": "Typescript definitions that are not (yet) available on https://github.com/DefinitelyTyped/DefinitelyTyped",
"repository": "https://github.com/chainsafe/libp2p-ts.git",

View File

@ -5,9 +5,7 @@
/// <reference types="libp2p"/>
import {ConnectionEncryption} from "../libp2p";
declare type LibP2pSecio = ConnectionEncryption;
declare type LibP2pSecio = LibP2p.ConnectionEncryption;
declare module 'libp2p-secio' {
const secio: LibP2pSecio;

View File

@ -9,14 +9,12 @@
/// <reference types="libp2p-kad-dht"/>
/// <reference types="libp2p-mdns"/>
/// <reference types="libp2p-mplex"/>
/// <reference types="libp2p-secio"/>
/// <reference types="libp2p-spdy"/>
/// <reference types="peer-info"/>
/// <reference types="peer-id"/>
import * as PeerId from "peer-id";
declare namespace LibP2p {
export type OptionsConfig = {
contentRouting?: {},
dht?: {
@ -76,6 +74,17 @@ declare namespace LibP2p {
peerInfo: PeerInfo,
};
export interface ConnectionEncryption {
protocol: string,
secureInbound(localPeer: import("peer-id"), connection: LibP2pConnection, remotePeer: import("peer-id")): Promise<SecureConnection>;
secureOutbound(localPeer: import("peer-id"), connection: LibP2pConnection, remotePeer?: import("peer-id")): Promise<SecureConnection>;
}
export interface SecureConnection {
conn: LibP2pConnection,
remotePeer: import("peer-id")
}
export type Events = 'peer:connect' | 'peer:disconnect' | 'peer:discovery' | 'start' | 'stop';
}
@ -83,17 +92,6 @@ declare class PeerStore {
readonly peers: Map<string, PeerInfo>;
}
declare interface ConnectionEncryption {
protocol: string,
secureInbound(localPeer: PeerId, connection: LibP2pConnection, remotePeer: PeerId): Promise<SecureConnection>;
secureOutbound(localPeer: PeerId, connection: LibP2pConnection, remotePeer?: PeerId): Promise<SecureConnection>;
}
declare interface SecureConnection {
conn: LibP2pConnection,
remotePeer: PeerId
}
declare class Registrar {
getConnection(peerInfo: PeerInfo): LibP2pConnection;
handle: Function;

View File

@ -10,7 +10,8 @@
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true
},
"files": ["index.d.ts", "libp2p-tests.ts"]
}