Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

express-torus-react-native

This library enables cross-platform (Android/iOS/Web/Expo) ethereum-login for React Native using Tor.us, a service which provides a simple and seamless way to onboard users from their social login into the world of Web3 and DeFi.

It works by navigating from your application to the interface hosted by your specified providerUri, i.e. where your instance of express-torus is being served. Upon successful auth with one of the many supported authentication providers, your app will returned to using Deep Linking with the authentication result, which is accessed via a hook. This includes standard authentication data (such as username and profile photo) in addition to Ethereum wallet credentials that can be used in transactions.

This project was created as part of the Gitcoin KERNEL Genesis Block.

πŸš€ Getting Started

Using npm:

npm install --save express-torus-react-native

Using yarn:

yarn add express-torus-react-native

Deep Linking

πŸ”— Configuring Deep Linking on Expo

Update your app.json to include your application's scheme to match the configuration consumed by the backend's linking prop:

{
  "expo": {
+   "scheme": "myapp"
  }
}

πŸ”— Configuring Deep Linking for iOS

Firstly, you'll need to register your app's deep link scheme (i.e. myapp) as a supported URL Type with a role of Viewer in your App's Info.plist.

Finally, append the following lines in the iOS AppDelegate.m:

+ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
+   if ([RCTLinkingManager application:application openURL:url sourceApplication:nil annotation:nil]) {
+     return YES;
+   }
+   return NO;
+ }

✍️ Usage

import React from "react";
import {Platform, SafeAreaView, TouchableOpacity, ActivityIndicator, Text} from "react-native";

import Torus, {useTorus} from "express-torus-react-native";

const SimpleTorusLogin = ({...extraProps}) => {
  const {loading, error, result, login} = useTorus();
  if (loading) {
    return (
      <ActivityIndicator />
    );
  } else if (error) {
    return (
      <Text style={styles.error} children={error.toString()} />
    );
  } else if (result) {
    return (
      <Text children={JSON.stringify(result)} />
    );
  }
  return (
    <TouchableOpacity onPress={() => login(Platform.OS === "web" ? "http://localhost:19006" : "myapp://")}>
      <Text children="Login" />
    </TouchableOpacity>
  );
};

export default function App() {
  return (
    <Torus providerUri="http://localhost:3000">
      <SafeAreaView>
        <SimpleTorusLogin />
      </SafeAreaView>
    </Torus>
  );
}

You can view the full list of supported authentication providers here.

✌️ License

MIT

About

πŸ” βš›οΈ A React Native hook for simple decentralized key management using Tor.us, which serves as a combined social login and ethereum wallet!

Topics

Resources

License

Releases

No releases published
You can’t perform that action at this time.