- Extracted libp2p component from main app - Created modular package structure with interfaces and implementations - Added dependency injection for NativeModules - Configured for IOR loading from Gitea - Added comprehensive README and documentation
55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
/**
|
|
* Shared types for libp2p implementation across platforms
|
|
*/
|
|
|
|
import type { ConnectionDirection, ConnectionStatus } from './constants';
|
|
|
|
/**
|
|
* Unified connection information structure used by both iOS and Android
|
|
*/
|
|
export interface ConnectionInfo {
|
|
peerId: string;
|
|
status: ConnectionStatus;
|
|
direction: ConnectionDirection;
|
|
multiaddr?: string;
|
|
timestamp: number; // Unix timestamp in seconds
|
|
error?: string;
|
|
}
|
|
|
|
/**
|
|
* Event payloads for consistent event handling across platforms
|
|
*/
|
|
export interface ConnectionStatusEvent {
|
|
peerId: string;
|
|
status: ConnectionStatus;
|
|
direction?: ConnectionDirection;
|
|
multiaddr?: string;
|
|
error?: string;
|
|
reason?: string;
|
|
}
|
|
|
|
export interface PeerDiscoveredEvent {
|
|
peerId: string;
|
|
addresses?: string[];
|
|
multiaddrs?: string[];
|
|
}
|
|
|
|
export interface PeerLostEvent {
|
|
peerId: string;
|
|
}
|
|
|
|
export interface LogEvent {
|
|
message: string;
|
|
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
}
|
|
|
|
export interface ErrorEvent {
|
|
message: string;
|
|
code?: string;
|
|
}
|
|
|
|
export interface PeerInfoEvent {
|
|
peerId: string;
|
|
multiaddrs: string[];
|
|
}
|