Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[ignore]
.*/node_modules/documentation/*

[libs]

[include]

[options]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"async": "^2.6.0",
"libp2p-crypto": "~0.11.0",
"lodash": "^4.17.4",
"multihashes": "~0.4.12"
"multihashes": "~0.4.12",
"callback.flow": "1.0.0"
},
"repository": {
"type": "git",
Expand Down
44 changes: 44 additions & 0 deletions src/index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @flow

import type { Callback } from "callback.flow"
import * as crypto from "libp2p-crypto"

const { RsaPublicKey, RsaPrivateKey } = crypto.key.rsa

export interface JSONPeerId {
id: string;
privKey: string;
pubKey: string;
}

export interface PeerId {
id: Buffer;
privKey: RsaPrivateKey;
pubKey: RsaPublicKey;

toJSON(): JSONPeerId;
toPrint(): JSONPeerId;
toB58String(): string;
toBytes(): Buffer;
toHexString(): string;
isEqual(PeerId): boolean;
marshalPubKey(): Buffer;
marshalPrivKey(): Buffer;
isValid(Callback<Error>): void;
}

export type CreateOptions = {
bits?: number
}

declare export default {
create(CreateOptions, Callback<Error, PeerId>): void,
create(Callback<Error, PeerId>): void,
createFromHexString(string): PeerId,
createFromBytes(Buffer): PeerId,
createFromB58String(string): PeerId,
createFromPubKey(string | Buffer, Callback<Error, PeerId>): void,
createFromPrivKey(string | Buffer, Callback<Error, PeerId>): void,
createFromJSON(JSONPeerId, Callback<Error, PeerId>): void,
isPeerId(mixed): boolean
}