-
Notifications
You must be signed in to change notification settings - Fork 2
/
global.d.ts
45 lines (38 loc) · 1.14 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
declare module "hyperswarm" {
import { EventEmitter } from "events";
import { Peer } from "symmetry-core";
export interface Swarm {
flushed(): Promise<void>;
}
export interface JoinOptions {
client?: boolean;
server?: boolean;
}
export interface SwarmOptions {
keyPair?: { publicKey: Buffer; secretKey: Buffer };
seed?: Buffer;
maxPeers?: number;
firewall?: (remotePublicKey: string) => boolean;
dht?: unknown;
}
export default class Hyperswarm extends EventEmitter {
constructor(opts?: SwarmOptions);
join(topic: string | Buffer, opts?: JoinOptions): Swarm;
on: (key: string, cb: (data: Peer) => void) => void;
once: (key: string, cb: (data: Peer) => void) => void;
flush: () => void;
leave(topic: Buffer): void;
destroy(): Promise<void>;
peers: Map<string, Peer>;
connections: Map<string, Peer>;
connecting: boolean;
}
}
declare module "hypercore-crypto" {
const hyperCoreCrypto: {
keyPair: () => { publicKey: Buffer; secretKey: Buffer }
discoveryKey: (publicKey: Buffer) => Buffer;
sign(message, secretKey) : Buffer;
};
export = hyperCoreCrypto;
}