| 1 | import type { PeerId } from '@libp2p/interface' |
| 2 | import type { Multiaddr } from '@multiformats/multiaddr' |
| 3 | |
| 4 | /** |
| 5 | * - pending - just discovered |
| 6 | * - connecting - we are connecting to this node |
| 7 | * - ready - node is compatible & ready to be connected to |
| 8 | * - failed - failed to connect to this node |
| 9 | * - incompatible - node is running an incompatible version of inspector-metrics |
| 10 | * - connected - we have connected to this node |
| 11 | */ |
| 12 | export type InspectTargetStatus = 'pending' | 'ready' | 'failed' | 'incompatible' | 'connecting' | 'connected' |
| 13 | |
| 14 | export interface InspectTarget { |
| 15 | id: PeerId |
| 16 | multiaddrs: Multiaddr[] |
| 17 | status: InspectTargetStatus |
| 18 | error?: string |
| 19 | name: string |
| 20 | version: string |
| 21 | userAgent: string |
| 22 | inspector: string |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * The IPC API defined in ./preload.ts |
| 27 | */ |
| 28 | export interface InspectorIPC { |
| 29 | onTargets(callback: (targets: InspectTarget[]) => void): void |
| 30 | onConnected(callback: (err: Error | undefined) => void): void |
| 31 | onRPC(callback: (message: Uint8Array) => void): void |
| 32 | |
| 33 | connect(address: string | PeerId): void |
| 34 | cancelConnect(): void |
| 35 | disconnect(): void |
| 36 | sendRPC(message: Uint8Array): void |
| 37 | } |