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 {
if (debugMode) {
await _doctor.check(request.relyingParty.id);
}
try {
await _platform.cancelCurrentAuthenticatorOperation();
_isValidChallenge(request.challenge);
_isValidUserID(request.user.id);
for (final credential in request.excludeCredentials) {
_isValidCredentialID(credential.id);
}
final r = await _platform.register(request);
return r;
} on PlatformException catch (e) {
if (debugMode) {
_doctor.recordException(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);
case 'deviceNotSupported':
throw DeviceNotSupportedException();
case 'android-passkey-unsupported':
throw PasskeyUnsupportedException(e.message);
case 'android-timeout':
throw TimeoutException(e.message);
case 'ios-security-key-timeout':
throw TimeoutException(e.message);
default:
rethrow;
}
}
}