forAuth static method

RelayConnectionKey? forAuth(
  1. String url,
  2. AuthPolicy? auth
)

The connection a request under auth must use towards url (NIP-42).

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? forAuth(String url, AuthPolicy? auth) =>
    switch (auth) {
      AuthPolicyRequire(:final account) =>
        account.signer.canSign()
            ? RelayConnectionKey.authenticated(url, account.pubkey)
            : null,
      null ||
      AuthPolicyNever() ||
      AuthPolicyAllow() => RelayConnectionKey.anonymous(url),
    };