diff --git a/implementations/Libp2pComponent.ts b/implementations/Libp2pComponent.ts index 0bd9974..be2c310 100644 --- a/implementations/Libp2pComponent.ts +++ b/implementations/Libp2pComponent.ts @@ -135,13 +135,14 @@ export class Libp2pComponent implements ILibp2pComponent { // Peer discovery this.eventEmitter.addListener( 'onPeerDiscovered', - ({ peerId, addresses, multiaddrs }: PeerDiscoveredEvent) => { + ({ peerId, addresses, multiaddrs, metadata }: PeerDiscoveredEvent) => { const addrs = (multiaddrs || addresses || []).map( (addr: string) => new SimpleMultiaddr(addr), ); this.emit('peer:discovery', { id: new SimplePeerId(peerId), multiaddrs: addrs, + metadata: metadata, // Pass metadata through }); }, ); diff --git a/interfaces/ILibp2pComponent.ts b/interfaces/ILibp2pComponent.ts index 44f4f87..3af2867 100644 --- a/interfaces/ILibp2pComponent.ts +++ b/interfaces/ILibp2pComponent.ts @@ -33,6 +33,12 @@ export interface Connection { export interface PeerInfo { id: PeerId; multiaddrs: Multiaddr[]; + metadata?: { + userId?: string; + deviceName?: string; + source?: string; + [key: string]: any; + }; } export interface ProtocolHandler { diff --git a/package.json b/package.json index a1702bf..61ce547 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "@metatrom/libp2p-native-bridge", - "version": "1.0.0", + "version": "1.2.0-beta.1", "main": "index.ts", "type": "module", "description": "Native libp2p bridge for React Native applications", "metatrom": { - "ior": "com.metatrom.libp2p-native-bridge@1.0.0", + "ior": "com.metatrom.libp2p-native-bridge@1.2.0-beta.1", "capabilities": { "p2p": true, "contracts": false, diff --git a/utils/types.ts b/utils/types.ts index 2f0d241..90dbb91 100644 --- a/utils/types.ts +++ b/utils/types.ts @@ -32,6 +32,12 @@ export interface PeerDiscoveredEvent { peerId: string; addresses?: string[]; multiaddrs?: string[]; + metadata?: { + userId?: string; + deviceName?: string; + source?: string; + [key: string]: any; + }; } export interface PeerLostEvent {