mirror of
https://github.com/fluencelabs/libp2p-ts
synced 2025-05-25 19:51:19 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
// Type definitions for libp2p-crypto 0.13.0
|
|
// Project: https://github.com/libp2p/js-libp2p-crypto
|
|
// Definitions by: Jaco Greeff <https://github.com/jacogr>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
/// <reference types="node"/>
|
|
|
|
declare namespace LibP2pCrypto {
|
|
type KeyTypes = 'ed25519' | 'rsa' | 'secp256k1';
|
|
|
|
interface PublicKey {
|
|
hash(cb: (error: Error | null, hash: Buffer) => void): void;
|
|
}
|
|
|
|
interface PrivateKey {
|
|
readonly public: PublicKey;
|
|
|
|
hash(cb: (error: Error | null, hash: Buffer) => void): void;
|
|
id(cb: (error: Error | null, id: string) => void): void
|
|
}
|
|
|
|
interface KeyExports {
|
|
generateKeyPair(bits: number, cb: (error: Error | null, privKey: PrivateKey) => void): void;
|
|
}
|
|
|
|
interface Keys {
|
|
generateKeyPair(type: KeyTypes, bits: number, cb: (error: Error | null, privKey: PrivateKey) => void): void;
|
|
|
|
readonly supportedKeys: {
|
|
readonly [key in keyof KeyTypes]: KeyExports
|
|
};
|
|
}
|
|
|
|
interface Crypto {
|
|
readonly keys: Keys
|
|
}
|
|
}
|
|
|
|
declare module 'libp2p-crypto' {
|
|
const crypto: LibP2pCrypto.Crypto;
|
|
|
|
export default crypto;
|
|
}
|