### Start Metro Server for Example App Source: https://github.com/auth0/react-native-auth0/blob/master/CONTRIBUTING.md Starts the Metro bundler, which is necessary for running the example application. This command is typically used during development to serve the JavaScript bundle. ```sh yarn example start ``` -------------------------------- ### Run Example App on Android Source: https://github.com/auth0/react-native-auth0/blob/master/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. This command is used to test changes made to the library against a real application. ```sh yarn example android ``` -------------------------------- ### Run Example App on iOS Source: https://github.com/auth0/react-native-auth0/blob/master/CONTRIBUTING.md Builds and runs the example application on an iOS simulator or device. This command is used to test changes made to the library against a real application. ```sh yarn example ios ``` -------------------------------- ### Get Credentials with Basic Error Handling Source: https://github.com/auth0/react-native-auth0/blob/master/README.md A basic example of fetching credentials and logging any encountered errors. This is useful for initial integration. ```javascript try { const credentials = await auth0.credentialsManager.getCredentials(); } catch (error) { console.log(error); } ``` -------------------------------- ### Install Pods After iOS Podfile Update Source: https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md Command to navigate to the iOS directory and install the updated pods after modifying the Podfile. ```bash cd ios && pod install && cd .. ``` -------------------------------- ### Install Project Dependencies with Yarn Source: https://github.com/auth0/react-native-auth0/blob/master/CONTRIBUTING.md Installs all project dependencies using Yarn, essential for setting up the monorepo managed by Yarn workspaces. This command should be run in the root directory of the project. ```sh yarn ``` -------------------------------- ### Android Custom Scheme Callback URL Example Source: https://github.com/auth0/react-native-auth0/blob/master/README.md An example of an Android custom scheme callback URL with a package name of 'com.example.myapp' and Auth0 domain 'example.us.auth0.com'. ```text com.example.myapp.auth0://example.us.auth0.com/android/com.example.myapp/callback ``` -------------------------------- ### Manage Auth0 SDK Installation Source: https://github.com/auth0/react-native-auth0/blob/master/FAQ.md Commands to check the current version of the Auth0 SDK, update to the latest version, and reinstall iOS pods. ```bash npm list react-native-auth0 npm install react-native-auth0@latest cd ios && pod install && cd .. ``` -------------------------------- ### Managing Authentication Methods Source: https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md Examples demonstrating how to interact with authentication methods, including listing all methods, filtering by type, retrieving a specific method, updating its name, and deleting it. ```APIDOC ## Managing Authentication Methods ### List all methods ```typescript const methods = await myAccount.getAuthenticationMethods({ accessToken }); ``` ### List only passkey methods ```typescript const passkeys = await myAccount.getAuthenticationMethods({ accessToken, type: AuthenticationMethodTypes.PASSKEY, }); ``` ### Get a specific method ```typescript const method = await myAccount.getAuthenticationMethodById({ accessToken, id: 'authentication-method-id', }); ``` ### Update a method name ```typescript const updated = await myAccount.updateAuthenticationMethodById({ accessToken, id: 'authentication-method-id', name: 'My Work Phone', }); ``` ### Delete a method ```typescript await myAccount.deleteAuthenticationMethodById({ accessToken, id: 'authentication-method-id', }); ``` ``` -------------------------------- ### Using Passkeys with Auth0 Class for Signup and Login Source: https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md This example shows how to use the `Auth0` class directly for both passkey signup and login flows. It requires initializing the `Auth0` client with your domain and client ID, and then using `passkeySignupChallenge`, `passkeyLoginChallenge`, and `getTokenByPasskey`. Ensure you have `yourCredentialManagerCreate` and `yourCredentialManagerGet` functions implemented. ```typescript import Auth0, { PasskeyError } from 'react-native-auth0'; const auth0 = new Auth0({ domain: 'YOUR_AUTH0_DOMAIN', clientId: 'YOUR_AUTH0_CLIENT_ID', }); // Signup flow const signupChallenge = await auth0.passkeySignupChallenge({ email: 'user@example.com', name: 'John Doe', realm: 'Username-Password-Authentication', }); // Use your credential manager library to create the passkey // signupChallenge.authParamsPublicKey has the WebAuthn creation options const registrationJson = await yourCredentialManagerCreate( signupChallenge.authParamsPublicKey ); const signupCredentials = await auth0.getTokenByPasskey({ authSession: signupChallenge.authSession, authResponse: registrationJson, realm: 'Username-Password-Authentication', }); // Login flow const loginChallenge = await auth0.passkeyLoginChallenge({ realm: 'Username-Password-Authentication', }); // Use your credential manager library to assert the passkey // loginChallenge.authParamsPublicKey has the WebAuthn request options const assertionJson = await yourCredentialManagerGet( loginChallenge.authParamsPublicKey ); const loginCredentials = await auth0.getTokenByPasskey({ authSession: loginChallenge.authSession, authResponse: assertionJson, realm: 'Username-Password-Authentication', }); ``` -------------------------------- ### Getting Available Factors Source: https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md Demonstrates how to retrieve a list of available authentication factor types for the user. ```APIDOC ## Getting Available Factors ```typescript const factors = await myAccount.getFactors({ accessToken }); // Returns available factor types (e.g., sms, email, totp, push-notification, webauthn-platform) ``` ``` -------------------------------- ### Sign in with Passkey using useAuth0 Hook Source: https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md This example demonstrates the signin flow using the `useAuth0` hook. It involves fetching a login challenge, asserting an existing passkey via a credential manager, and exchanging the credential for Auth0 tokens. Ensure you have a `yourCredentialManagerGet` function implemented. ```tsx import { useAuth0, PasskeyError } from 'react-native-auth0'; function PasskeySigninScreen() { const { passkeyLoginChallenge, getTokenByPasskey } = useAuth0(); const handleSignin = async () => { try { // Step 1: Get the login challenge from Auth0 const challenge = await passkeyLoginChallenge({ realm: 'Username-Password-Authentication', }); // Step 2: Use the platform credential manager to assert an existing passkey // challenge.authParamsPublicKey contains the WebAuthn PublicKeyCredentialRequestOptions // Use your preferred library (e.g., react-native-passkey) or native module const credentialJson = await yourCredentialManagerGet( challenge.authParamsPublicKey ); // Step 3: Exchange the credential response for Auth0 tokens const credentials = await getTokenByPasskey({ authSession: challenge.authSession, authResponse: credentialJson, realm: 'Username-Password-Authentication', audience: 'https://api.example.com', scope: 'openid profile email offline_access', }); console.log('Signed in with passkey:', credentials.accessToken); } catch (error) { if (error instanceof PasskeyError) { console.error('Passkey signin failed:', error.type, error.message); } } }; return