- Add metadata field to PeerDiscoveredEvent interface - Add metadata field to PeerInfo interface - Update event handler to forward metadata from native events - Enables proper user identification in discovery 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.2 KiB
TypeScript
61 lines
1.2 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[];
|
|
metadata?: {
|
|
userId?: string;
|
|
deviceName?: string;
|
|
source?: string;
|
|
[key: string]: any;
|
|
};
|
|
}
|
|
|
|
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[];
|
|
}
|