Browse Source

Specify timeout for passkey

Neeraj Gupta 1 year ago
parent
commit
5df7a2a10f
1 changed files with 4 additions and 3 deletions
  1. 4 3
      apps/accounts/src/pages/passkeys/flow/index.tsx

+ 4 - 3
apps/accounts/src/pages/passkeys/flow/index.tsx

@@ -128,19 +128,20 @@ const PasskeysFlow = () => {
     };
 
     const getCredential = async (
-        publicKey: any
+        publicKey: any,
+        timeoutMillis: number = 60000 // Default timeout of 60 seconds
     ): Promise<Credential | null> => {
         publicKey.challenge = _sodium.from_base64(
             publicKey.challenge,
             _sodium.base64_variants.URLSAFE_NO_PADDING
         );
-        publicKey.allowCredentials?.forEach(function(listItem: any) {
+        publicKey.allowCredentials?.forEach(function (listItem: any) {
             listItem.id = _sodium.from_base64(
                 listItem.id,
                 _sodium.base64_variants.URLSAFE_NO_PADDING
             );
         });
-
+        publicKey.timeout = timeoutMillis;
         const credential = await navigator.credentials.get({
             publicKey,
         });