Skip to content

feat: add passkeys support for signup and signin#1530

Open
subhankarmaiti wants to merge 1 commit into
masterfrom
feat/passkeys-support
Open

feat: add passkeys support for signup and signin#1530
subhankarmaiti wants to merge 1 commit into
masterfrom
feat/passkeys-support

Conversation

@subhankarmaiti
Copy link
Copy Markdown
Contributor

Summary

  • Adds signupWithPasskey and signinWithPasskey methods across all layers (TypeScript, iOS, Android)
  • Orchestrates the full passkey flow on each platform: challenge → OS passkey UI → token exchange
  • iOS uses ASAuthorizationController (iOS 16.6+), Android uses CredentialManager
  • Exposes via both the Auth0 class (class-based) and useAuth0 hook
  • Adds PasskeyError and PasskeyErrorCodes for type-safe error handling
  • Web platform throws PASSKEY_UNSUPPORTED_PLATFORM with a clear error message

Usage

import Auth0, { PasskeyError, PasskeyErrorCodes } from 'react-native-auth0';
                                                                                                                                               
const auth0 = new Auth0({ domain: 'YOUR_DOMAIN', clientId: 'YOUR_CLIENT_ID' });
                                                                                                                                               
// Sign up a new user with a passkey                                     
const credentials = await auth0.signupWithPasskey({                                                                                            
  email: 'user@example.com',                                                                                                                   
  realm: 'Username-Password-Authentication',                                                                                                   
});                                                                                                                                            
                                                                                                                                               
// Sign in an existing user with a passkey                                                                                                     
const credentials = await auth0.signinWithPasskey({                                                                                            
  realm: 'Username-Password-Authentication',                                                                                                   
});                                                                                                                                            
                                                                                                                                               
// Error handling                                                                                                                              
try {                                                                                                                                          
  await auth0.signinWithPasskey({ realm: 'Username-Password-Authentication' });                                                                
} catch (e) {                                                                                                                                  
  if (e instanceof PasskeyError) {                                                                                                             
    switch (e.type) {                                                                                                                          
      case PasskeyErrorCodes.USER_CANCELLED:                                                                                                   
        // User dismissed the passkey prompt                                                                                                   
        break;                                                                                                                                 
      case PasskeyErrorCodes.NOT_AVAILABLE:                                                                                                    
        // Device doesn't support passkeys                                                                                                     
        break;                                                                                                                                 
    }                                                                                                                                          
  }                                                                                                                                            
}

With Hooks

import { useAuth0, PasskeyError, PasskeyErrorCodes } from 'react-native-auth0';                                                                
                                                                                                                                               
const { signupWithPasskey, signinWithPasskey } = useAuth0();                                                                                   
                                                                                                                                               
await signupWithPasskey({ email: 'user@example.com', realm: 'Username-Password-Authentication' });                                             
await signinWithPasskey({ realm: 'Username-Password-Authentication' });  

@subhankarmaiti subhankarmaiti requested a review from a team as a code owner May 11, 2026 14:10
})
}

private fun performPasskeyRegistration(
Copy link
Copy Markdown
Contributor

@pmathew92 pmathew92 May 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the SDK to handle this operation. SDK should expose the two APIs responsible for

  1. Requesting the Challenge
  2. Exchanging the token.
    and let the user handle the end to end flow. All our docs and tutorials follow the same pattern. Both the native SDKs also follow this approach . Curious to know why you went to implement this end to end flow ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants