Added libp2p peer-id

This commit is contained in:
Jaco Greeff 2018-06-21 13:10:14 +02:00
parent 77c1fda97f
commit e18b84e220
4 changed files with 55 additions and 0 deletions

38
peer-id/index.d.ts vendored Normal file
View File

@ -0,0 +1,38 @@
// Type definitions for peer-id 0.10.7
// Project: https://github.com/libp2p/js-peer-id
// Definitions by: Jaco Greeff <https://github.com/jacogr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
type CreateCb = (error: Error | null, peerId?: PeerId) => any;
type CreateOptions = {
bits: number
};
type JSON = {
id: string,
pubKey: string,
privKey: string
};
declare class PeerId {
constructor (id: Buffer, privKey?: any, pubKey?: any);
static create (optsOrCb: CreateOptions | CreateCb, cb?: CreateCb): PeerId;
static createFromB58String (str: string): PeerId;
static createFromBytes (buf: Buffer): PeerId;
static createFromHexString (str: string): PeerId;
static createFromJSON (json: JSON): PeerId;
static createFromPubKey (key: Buffer): PeerId;
static createFromPrivKey (key: Buffer): PeerId;
isEqual (other: PeerId | Buffer): boolean;
toB58String (): string;
toBytes (): Buffer;
toHexString (): string;
toJSON (): JSON;
}
export = PeerId;

0
peer-id/peer-id-tests.ts Normal file
View File

16
peer-id/tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "bn.js-tests.ts"]
}

1
peer-id/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }