authenticate method

  1. @override
Future<Principal> authenticate(
  1. Credential credential, {
  2. required Uint8List challenge,
})
override

Authenticates credential, returning the resolved Principal.

challenge is the per-connection nonce the Hub issued in its hello; public-key authenticators verify the signature against it for replay protection, while token authenticators ignore it.

Throws AuthException if the credential is unsupported, malformed, unknown or fails verification.

Implementation

@override
Future<Principal> authenticate(
  Credential credential, {
  required Uint8List challenge,
}) async {
  AuthException? last;
  for (final delegate in _delegates) {
    try {
      return await delegate.authenticate(credential, challenge: challenge);
    } on AuthException catch (e) {
      last = e;
    }
  }
  throw last ??
      const AuthException('No authenticator accepted the credential');
}