keyFor static method

RelayConnectionKey? keyFor(
  1. String url,
  2. RelayAuth? auth
)

The connection a request under auth must use towards url.

Null means no connection can satisfy it and nothing may be sent to that relay: falling back to the anonymous one is exactly what the caller ruled out. A null auth keeps the historical default.

Implementation

static RelayConnectionKey? keyFor(String url, RelayAuth? auth) =>
    switch (auth) {
      RelayAuthRequire(:final account) => account.signer.canSign()
          ? RelayConnectionKey.authenticated(url, account.pubkey)
          : null,
      null ||
      RelayAuthNever() ||
      RelayAuthAllow() =>
        RelayConnectionKey.anonymous(url),
    };