pair method

Future<AgentIdentity> pair(
  1. String url
)

Verify a tibane://pair?agent=...&token=... URL by handshaking with the agent over Spot, and return the agent's verified identity.

Throws a typed PairingException subclass on failure — see that file for the catalogue. Catch PairingException for a single "pair failed" branch in the UI, or switch on the runtime type for per-error messaging.

Idempotent in name only: pairing tokens are single-use, so a second call with the same URL throws PairingTokenConsumedException. Each retry needs a fresh URL from clawdwallet pair.

Implementation

Future<AgentIdentity> pair(String url) async {
  try {
    final data = await _conn
        .request('ClawdWallet:pair', 'POST', {'url': url});
    return AgentIdentity.fromJson(Map<String, dynamic>.from(data as Map));
  } on LibwalletException catch (e) {
    throw _toPairingException(e);
  }
}