Initial commit: libp2p-native-bridge package
- 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
This commit is contained in:
54
utils/types.ts
Normal file
54
utils/types.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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[];
|
||||
}
|
||||
Reference in New Issue
Block a user