register method

Future<RegisterResponseType> register(
  1. String challenge,
  2. RelyingPartyType relyingParty,
  3. UserType user,
  4. AuthenticatorSelectionType authSelectionType,
  5. List<PubKeyCredParamType>? pubKeyCredParams,
  6. int? timeout,
  7. String? attestation,
)

Creates a new passkey and stores it on the device. Returns a solution to the challenge from relyingParty

Implementation

Future<RegisterResponseType> register(
  String challenge,
  RelyingPartyType relyingParty,
  UserType user,
  AuthenticatorSelectionType authSelectionType,
  List<PubKeyCredParamType>? pubKeyCredParams,
  int? timeout,
  String? attestation,
) async {
  try {
    final r = await _platform.register(
      challenge,
      relyingParty,
      user,
      authSelectionType,
      pubKeyCredParams,
      timeout,
      attestation,
    );

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