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

@secux/transport-reactnative

v3.3.0

Published

SecuX Hardware Wallet react native API for communication layer

Downloads

11

Readme

@secux/transport-reactnative

SecuX Hardware Wallet react native API for communication layer

Installation

npm install @secux/transport-reactnative react-native-ble-plx react-native-settings

Configuration

IOS

  1. Enter ios folder and run pod update
  2. Add NSBluetoothAlwaysUsageDescription in info.plist file. (it is a requirement since iOS 13)

Android

  1. Enter android folder, open build.gradle make sure that min SDK version is at least 18:
buildscript {
    ext {
        ...
        minSdkVersion = 18
        ...
  1. In build.gradle make sure to add jitpack repository to known repositories:
allprojects {
    repositories {
      ...
      maven { url 'https://www.jitpack.io' }
    }
}
  1. In build.gradle make sure that gradle version is at least 4.1.0:
buildscript {
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")
        ...
  1. In AndroidManifest.xml, add Bluetooth permissions:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
    ...

Bluetooth connection flow

  1. Scanning SecuX devices by bluetooth to get MAC_ADDRESS/UUID. If use given MAC_ADDRESS/UUID, you can skip step 1.
  2. Connect to SecuX device with MAC_ADDRESS/UUID.
  3. Do OTP authentication that showing on SecuX device.
  4. Bluetooth connection finished.

Example

In below example, we use react-native-dialog npm package to do OTP process.

import React from 'react';
import { StyleSheet, Text, View, Button, FlatList } from 'react-native';
import Dialog from 'react-native-dialog';
import { SecuxReactNativeBLE } from "@secux/transport-reactnative";


export default function App() {
    const [scanning, SetScanning] = React.useState(false);
    const [dialog, ShowDialog] = React.useState(false);
    const [otp, SetOTP] = React.useState();
    const [devices, SetDevices] = React.useState([]);
    const [transport, SetTransport] = React.useState();


    const AddDevice = (device) => {
        device.clicked = false;
        SetDevices(x => [...x, device]);
    };

    const DeleteDevice = (device) => {
        SetDevices(x => x.filter(item => item.id !== device.id));
    };

    const scan = () => {
        SecuxReactNativeBLE.StartScan(AddDevice, DeleteDevice);
        SetScanning(true);
    };

    const connect = async (uid) => {
        SecuxReactNativeBLE.StopScan();

        const device = await SecuxReactNativeBLE.Create(
            uid,
            () => console.log("connected"),
            () => console.log("disconnected")
        );
        SetTransport(device);

        await device.Connect();

        ShowDialog(true);

        // device is connected
    };

    const otp_processing = async () => {
        const success = await transport.SendOTP(otp);

        if (success) ShowDialog(false);
    };

    return (
        <View style={styles.container}>
            <View style={{ flex: 1, alignItems: "center" }}>
                <Text>Sample Project</Text>
                <Button>
                    title="BLE Connect" 
                    onPress={scan} disabled={scanning} 
                <Button/>
                <FlatList> 
                    data={devices} 
                    renderItem={
                        ({ item }) => 
                        <Button> 
                            style={styles.item} 
                            title={item.name} 
                            disabled={item.clicked} 
                            onPress={
                                async () => { 
                                    item.clicked = true; 
                                    await connect(item.id); 
                                }
                            } 
                        <Button/>
                    }
                <FlatList/>
            </View>

            <View>
                <Dialog.Container visible={dialog}>
                    <Dialog.Title>OTP Authentication</Dialog.Title>
                    <Dialog.Input value={otp} onChangeText={SetOTP} />
                    <Dialog.Button label="OK" onPress={otp_processing} />
                </Dialog.Container>
            </View>
        </View >
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        paddingTop: 22,
    },
    item: {
        padding: 10,
        fontSize: 18,
        height: 44,
    },
});

Notes

  1. For android, location services should be turned on when scanning devices.
  2. After call .StartScan(), remember to call .StopScan().