initAuthenticateWithAutoComplete method
Initiates the authentication by asking for a challenge. Can be implemented if the relying party server provides a different endpoint for autocompleted sign ins.
Implementation
@override
Future<AuthenticationInitResponse> initAuthenticateWithAutoComplete(
AuthRequest request,
) async {
try {
final result = await UsersApi(_client).passKeyMediationStart(
PassKeyMediationStartReq(username: request.email),
);
if (result == null) {
throw Exception(
'An unknown error occurred during the Corbado API call',
);
}
if (result.data.challenge.isEmpty) {
throw NoPasskeyForDeviceException();
}
final json = jsonDecode(result.data.challenge) as Map<String, dynamic>;
final typed = CorbadoAuthenticationInitResponse.fromJson(json);
return typed.toAuthenticationInitResponse();
} on ApiException catch (e) {
throw ExceptionFactory.fromBackendMessage(
'passKeyAuthenticateStart',
e.message ?? '',
);
}
}