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

react-native-passkey

v3.0.0

Published

Passkey implementation for React Native

Downloads

76,758

Readme

react-native-passkey

Build Version License

Native Passkeys on iOS 15.0+ and Android API 28+ using React Native.

Installation

Javascript

For the javascript part of the installation you need to run

npm install react-native-passkey

or

yarn add react-native-passkey

Native

For the native part of the installation you need to run

cd ios && pod install

in the root of your React Native project.


Configuration

iOS

There are iOS specific steps you need to go through in order to configure Passkey support. If you have already set up an associated domain for your application you can skip this step.

Set up an associated domain for your application (More info)

  • You need to associate a domain with your application. On your webserver set up this route:

    GET https://<yourdomain>/.well-known/apple-app-site-association
  • This route should serve a static JSON object containing your team id and bundle identifier. Example (replace XXXXXXXXXX with your team identifier and the rest with your bundle id, e.g. "H123456789.com.mtrx0.passkeyExample"):

    {
      "applinks": {},
      "webcredentials": {
        "apps": ["XXXXXXXXXX.YYY.YYYYY.YYYYYYYYYYYYYY"]
      },
      "appclips": {}
    }
  • In XCode under Signing & Capabilities add a new Capability of type Associated Domains. Now add this and replace XXXXXX with your domain (e.g. apple.com)

    webcredentials:XXXXXX

Android

The Android specific configuration is similar to iOS. If you have already set up Digital Asset Links for your application you can skip this step.

Associate your app with a domain (More info)

  • You need to associate a domain with your application. On your webserver set up this route:

    GET https://<yourdomain>/.well-known/assetlinks.json
  • This route should serve a static JSON object containing the following information. Example (replace with your data, replace SHA_HEX_VALUE with the SHA256 fingerprints of your Android signing certificate)

    [{
      "relation": ["delegate_permission/common.get_login_creds"],
      "target": {
        "namespace": "android_app",
        "package_name": "com.example",
        "sha256_cert_fingerprints": [
          SHA_HEX_VALUE
        ]
      }
    }]

Usage

Check if Passkeys are supported

import { Passkey } from 'react-native-passkey';

// Use this method to check if passkeys are supported on the device

const isSupported: boolean = Passkey.isSupported();

Creating a new Passkey

import { Passkey, PasskeyRegistrationResult } from 'react-native-passkey';

// Retrieve a valid FIDO2 attestation request from your server
// The challenge inside the request needs to be a base64URL encoded string
// There are plenty of libraries which can be used for this (e.g. fido2-lib)

try {
  // Call the `create` method with the retrieved request in JSON format
  // A native overlay will be displayed
  const result: PasskeyRegistrationResult = await Passkey.create(requestJson);

  // The `create` method returns a FIDO2 attestation result
  // Pass it to your server for verification
} catch (error) {
  // Handle Error...
}

Authenticating with existing Passkey

import { Passkey, PasskeyAuthenticationResult } from 'react-native-passkey';

// Retrieve a valid FIDO2 assertion request from your server 
// The challenge inside the request needs to be a base64URL encoded string
// There are plenty of libraries which can be used for this (e.g. fido2-lib)

try {
  // Call the `get` method with the retrieved request in JSON format 
  // A native overlay will be displayed
  const result: PasskeyAuthResult = await Passkey.get(requestJson);

  // The `get` method returns a FIDO2 assertion result
  // Pass it to your server for verification
} catch (error) {
  // Handle Error...
}

Force Platform or Security Key (iOS-specific)

You can force users to register and authenticate using either a platform key, a security key (like Yubikey) or allow both using the following methods. This only works on iOS, Android will ignore these instructions.

Create Passkey

  • Passkey.create() - Allow the user to choose between platform and security passkey
  • Passkey.createPlatformKey() - Force the user to create a platform passkey
  • Passkey.createSecurityKey() - Force the user to create a security passkey

Get Passkey

  • Passkey.get() - Allow the user to choose between platform and security passkey
  • Passkey.getPlatformKey() - Force the user to authenticate using a platform passkey
  • Passkey.getSecurityKey() - Force the user to authenticate using a security passkey

Extensions

largeBlob

As of version 3.0 the newly added largeBlob extension should work out of the box for iOS only.

PRF

As of version 3.0 the newly added largeBlob extension should work out of the box for Android only.


Contributing

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


License

MIT