npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@passageidentity/passage-flex-react-native

v0.1.2

Published

Native passkey authentication for your React Native and Expo apps.

Downloads

322

Readme

passage-flex-react-native

npm version

Passkey Flex provides passkey support for existing authentication systems. It abstracts the complexities of native passkey APIs and provides a simple, clean solution to take your authentication to the next level.

Use the passage-flex-react-native SDK in your React Native app to implement passkey registration, authentication, or additional step-up or multifactor authentication (MFA).

For full documentation, including setting up a backend SDK, visit the Passkey Flex documentation here.

Prerequisites

A Passkey Flex app

  1. Create a Passkey Flex app in the Passage Console at https://console.passage.id
  2. Add an Android and/or iOS app in the Native Apps section
  3. When you add your Native App info, you can generate the associated domain file for that app if you haven’t already created it yourself, as shown below: Passage Native Apps screenshot

Hosted associated domains files

In order for passkeys to work, you’ll need to associate your native app(s) with the public web domain you assigned to your Passkey Flex app.

Android requires an assetlinks.json file configured and hosted (learn more here).

Apple requires an apple-app-site-association file configured and hosted (learn more here).

Installation

Install this package using npm:

npm i --save @passageidentity/passage-flex-react-native

App configuration

Expo

  • Add plugin in app.json:

    "plugins": [
          "@passageidentity/passage-flex-react-native"
    ]
  • Add ASSOCIATED_DOMAIN value to your app's .env file:

    ASSOCIATED_DOMAIN=example.com
  • Run npx expo prebuild

Bare React Native

See our Passkey Complete documentation for setting up a React Native app for passkeys and Passage.

Usage

Import PassageFlex:

import { PassageFlex } from '@passageidentity/passage-flex-react-native';

Initialize a Passage Flex instance using your appId found in Passage Console:

const passageFlex = new PassageFlex('YOUR_APP_ID');

passageFlex.passkey.register

To register a new user passkey, use the passageFlex.passkey.register method.

This is a three step process:

  1. Your app should POST a user identifier (like an email) to your backend, which should request a transaction id from the Passage server to return to your app.
  2. Your app should then call passageFlex.passkey.register(transactionId) to prompt your user to create a passkey. On success, the register method will return a nonce.
  3. Lastly, your app should send this nonce to your backend to verify the user has been registered successfully. At this point, your backend could return an access token.

Example:

const onPressRegister = async () => {
  // 1. Get transaction id string from your backend.
  const transactionId = await getRegisterTransactionId("[email protected]");
  // 2. Prompt user to create a passkey and get a Passage nonce value on success.
  const nonce = await passageFlex.passkey.register(transactionId);
  // 3. You can send this nonce to your backend to complete user registration.
  const accessToken = await getAccessToken(nonce);
};

passageFlex.passkey.authenticate

To log in a user using a passkey, use the passageFlex.passkey.authenticate method.

This is a three step process:

  1. Your app should POST a user identifier (like an email) to your backend, which should request a transaction id from the Passage server to return to your app.
  2. Your app should then call passageFlex.passkey.authenticate(transactionId) to prompt your user to log in with a passkey. On success, the authenticate method will return a nonce.
  3. Lastly, your app should send this nonce to your backend to verify the user has been authenticated successfully. At this point, your backend could return an access token.

Example:

const onPressLogIn = async () => {
  // 1. Get transaction id string from your backend.
  const transactionId = await getLogInTransactionId("[email protected]");
  // 2. Prompt user to create a passkey and get a Passage nonce value on success.
  const nonce = await passageFlex.passkey.authenticate(transactionId);
  // 3. You can send this nonce to your backend to complete user authentication.
  const accessToken = await getAccessToken(nonce);
};

passageFlex.passkey.isSupported

You can check if a user’s device supports passkeys by calling passageFlex.passkey.isSupported:

const deviceSupportsPasskeys = passageFlex.passkey.isSupported();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT