register method

Creates a new passkey and stores it on the device. Returns RegisterResponseType which must be sent to the relying party server.

Implementation

Future<RegisterResponseType> register(RegisterRequestType request) async {
  try {
    await _platform.cancelCurrentAuthenticatorOperation();
    final r = await _platform.register(request);

    return r;
  } on PlatformException catch (e) {
    switch (e.code) {
      case 'cancelled':
        throw PasskeyAuthCancelledException();
      case 'exclude-credentials-match':
        throw ExcludeCredentialsCanNotBeRegisteredException();
      case 'android-missing-google-sign-in':
        throw MissingGoogleSignInException();
      case 'android-sync-account-not-available':
        throw SyncAccountNotAvailableException();
      case 'domain-not-associated':
        throw DomainNotAssociatedException(e.message);
      default:
        rethrow;
    }
  }
}