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

@idpass/smartshare-react-native

v0.2.3-beta.2

Published

A Secure Communications Library For Sharing Credentials

Downloads

8

Readme

SmartShare React Native

A Secure Communications Library For Sharing Credentials

Installation

# Using npm
npm install @idpass/smartshare-react-native

# Using yarn
yarn add @idpass/smartshare-react-native

Usage

Import in main app:

import IdpassSmartshare from '@idpass/smartshare-react-native';

Development

The use of Java version 1.8 is recommended and has been tested to be smoothly compatible for this project. This project was generated using create-react-native-library to bootstrap the project structure and settings.

git clone https://github.com/idpass/smartshare-react-native
cd smartshare-react-native
yarn
yarn example start

# In a separate terminal window:
cd smartshare-react-native
yarn example android

Bluetooth API Description

First, a connection code or params needs to be communicated out-of-band and not via this library. This connection code specifies the intended peer to connect to. The mechanism to communicate the params connection code is up to the application. Such mechanism would include, but is not limited to, through a QR code for example.

The app that displays the QR code shall generate the ephemeral connection parameters:

import IdpassSmartshare from '@idpass/smartshare-react-native';

const params = IdpassSmartshare.getConnectionParameters();
console.log(params);

// Use any out-of-band mechanism to communicate the value of params to the peer device.
// For example, you can use a QR code generator library to visually display params.

The connection code or params looks like:

{
  "cid": "1ejpu",
  "pk": "819176777955C098B78BAF949084A4484AEC5A769CED2307D59E46DC85A0F758"
}

The app that scans the QR code shall set its connection parameters:

// Use any out-of-band mechanism to get the value of params from the peer device.
// For example, you can use a QR code scanning library to get params.

IdpassSmartshare.setConnectionParameters(params);

Both apps create the connection:

IdpassSmartshare.createConnection('dual', () => {
  // A secure Bluetooth connection is created
  // Anytime, either app may call IdpassSmartshare.send()
});

Once the connection is created, either app can send a string message.

IdpassSmartshare.send(message, () => {
  // message sent
});

The app can intentionally destroy the connection.

IdpassSmartshare.destroyConnection();

The app must handle Nearby events in order to receive messages, to monitor transfer status of incoming/outgoing messages, or to monitor connection related events:

IdpassSmartshare.handleNearbyEvents((event) => {
  switch (event.type) {
    case 'msg':
      console.log(event.data);
      break;

    case 'onDisconnected':
      console.log('onDisconnected: ' + event.data);
      break;

    case 'transferupdate':
      console.log('transferupdate: ' + event.data);
      break;

    default:
      break;
  }
});

The React Native app can print native debug logs for debugging, by:

IdpassSmartshare.handleLogEvents(event => {
  console.log(event.log);
});

Non-dual Bluetooth Connection Creation Mode

The above example snippets illustrated the use of the dual Bluetooth connection creation mode, wherein both devices will actively attempt to connect to each other and depending on who does it first, a connection is thereby created. The dual mode is a more robust mechanism to create a connection. However, an application may opt to configure one device as the advertiser and the other as the discoverer. For example, the first app that displays the QR code will advertise its presence and waits for a connection by:

IdpassSmartshare.createConnection('advertiser', () => {
  // A secure Bluetooth connection is created
  // Anytime, either app may call IdpassSmartshare.send()
});

and the other app that scans the QR code will attempt to discover the first app by:

IdpassSmartshare.createConnection('discoverer', () => {
  // A secure Bluetooth connection is created
  // Anytime, either app may call IdpassSmartshare.send()
});

This secure Bluetooth communication library needs to be used with another mechanism, for example a QR code, for the exchange of a connection parameters (params). This library uses asymmetric cryptography with ephemeral keys to secure the payload with Authenticated Encryption.

Open source dependencies

License

Apache-2.0 License