Multi-Device Linking
Link multiple devices to share the same identity and OrbitDB registry over libp2p.
Overview
Device linking uses the /orbitdb/link-device/1.0.0 libp2p protocol:
Usage
Device A (Owner)
- Authenticate with passkey
- Switch to the "P2Pass" tab
- Click copy button to get peer info JSON
- Share peer info with Device B (paste, QR code, etc.)
Device B (New Device)
- Authenticate with passkey
- Switch to the "P2Pass" tab
- Paste Device A's peer info JSON
- Click "Link Device"
- Wait for Device A to approve
Programmatic Usage
import { MultiDeviceManager } from 'p2pass';
const manager = await MultiDeviceManager.createFromExisting({
credential,
orbitdb,
libp2p,
identity: { id: signingMode.did },
onPairingRequest: async (request) => {
// Show approval UI, return 'granted' or 'rejected'
return 'granted';
},
onDeviceLinked: (device) => {
console.log('New device linked:', device.device_label);
},
});
// Open existing registry
await manager.openExistingDb(registryAddress);
// Link to another device
const result = await manager.linkToDevice(peerInfoJson);
Registry Migration
When Device B links to Device A, entries from Device B's local registry are migrated to the shared registry:
- Keypair entries
- Encrypted archives
- UCAN delegations
The migration retries writes until the ACL grant propagates (up to 2 minutes).
Key Files
src/lib/registry/manager.js—MultiDeviceManagerclasssrc/lib/registry/pairing-protocol.js— libp2p protocol handlersrc/lib/registry/device-registry.js— Registry CRUD operations