ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
11.31k stars 962 forks source link

[Bug]: FIDO2 package taking too much time to sign a challenge #7388

Open franelias opened 1 month ago

franelias commented 1 month ago

Capacitor Version

@capacitor/cli: 5.2.3 @capacitor/core: 5.2.3 @capacitor/ios: 5.2.3 @capacitor/android: 5.2.3

Other API Details

node --version
v18.16.0

Platforms Affected

Current Behavior

Hi, I have implemented the package com.google.android.gms:play-services-fido:20.0.1 as a plugin in my Capacitor app as it follows:

    @Override
    public void load() {
        authIntentLauncher = bridge.registerForActivityResult(new ActivityResultContracts.StartIntentSenderForResult(),
                getAuthIntentCallback());
    }

    @PluginMethod()
    public void getCredential(PluginCall call) {
        Fido2ApiClient fidoClient = Fido.getFido2ApiClient(bridge.getContext());
        PendingIntent intent = null;
        CredentialParser parser = new CredentialParser();
        JSObject credentialOptions = call.getObject("publicKey", new JSObject());

        try {
            PublicKeyCredentialRequestOptions credentials = parser.ParseLogin(credentialOptions);
            if (credentials == null) {
                call.reject("null credentials");
                return;
            }

            Task<PendingIntent> taskIntent = fidoClient.getSignPendingIntent(credentials);
            intent = Tasks.await(taskIntent);
        } catch (Exception e) {
            call.reject(e.getMessage());
            return;
        }

        if (intent != null) {
            IntentSenderRequest.Builder builder = new IntentSenderRequest.Builder(intent);

            pluginCall = call;
            authIntentLauncher.launch(builder.build());
        } else {
            call.reject("null intent");
        }
    }

My problem is that this implementation take about 5-11 seconds to show the fingerprint prompt and sign the challenge while in other frameworks, this delay doen't exist.

Expected Behavior

The biometric prompt should not take much time to appear.

Project Reproduction

It can be reproduced following the Google Codelab https://codelabs.developers.google.com/codelabs/fido2-for-android

Additional Information

No response

FernetB commented 1 month ago

I am having the same issue and i think is in the bridge.registerForActivityResult but i don't know what to do with that

FernetB commented 1 month ago

Hi! someone will see this? is a huge blocker for me