libp2p-ts/peer-id/index.d.ts
2018-06-22 15:43:18 +02:00

41 lines
1.1 KiB
TypeScript

// 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"/>
declare module 'peer-id' {
type CreateCb = (error: Error | null, peerId?: PeerId) => any;
type CreateOptions = {
bits: number
};
type JSON = {
id: string,
pubKey: string,
privKey: string
};
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;
}