-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add example app to rn-base (#1171)
* fix: fix linting and spacing issues * feat: remove package hoisting from example project * fix: fix linting and spacing issues * feat: add signer authentication sample implementation in example app * feat: add tsx to handle server instantiation * feat: update peer-dependencies for signer package --------- Co-authored-by: Iyk Azorji <[email protected]>
- Loading branch information
Showing
21 changed files
with
668 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 16 additions & 25 deletions
41
account-kit/rn-signer/example/android/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
android:label="@string/app_name" | ||
android:icon="@mipmap/ic_launcher" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:allowBackup="false" | ||
android:theme="@style/AppTheme" | ||
android:supportsRtl="true"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" | ||
android:launchMode="singleTask" | ||
android:windowSoftInputMode="adjustResize" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:supportsRtl="true"> | ||
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<category android:name="android.intent.category.BROWSABLE"/> | ||
<data android:scheme="rn-signer-demo"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import express from "express"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
const app = express(); | ||
const port = process.env.PORT || 5500; | ||
const appScheme = process.env.APP_SCHEME || "rn-signer-demo"; | ||
|
||
app.get("/", (req, res) => { | ||
const bundle = req.query.bundle; | ||
const orgId = req.query.orgId; | ||
|
||
res.redirect(`${appScheme}://home?bundle=${bundle}&orgId=${orgId}`); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is running on port ${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,30 @@ | ||
/* eslint-disable import/extensions */ | ||
import { RNSignerClient } from "@account-kit/react-native-signer"; | ||
import type { User } from "@account-kit/signer"; | ||
import { useState } from "react"; | ||
import { Button, StyleSheet, Text, TextInput, View } from "react-native"; | ||
import Config from "react-native-config"; | ||
import { createStaticNavigation } from "@react-navigation/native"; | ||
import { createNativeStackNavigator } from "@react-navigation/native-stack"; | ||
import { SafeAreaProvider } from "react-native-safe-area-context"; | ||
|
||
export default function App() { | ||
const [email, setEmail] = useState<string>(""); | ||
const [user, setUser] = useState<User | null>(null); | ||
const [bundle, setBundle] = useState<string>(""); | ||
const [orgId, setOrgId] = useState<string>(""); | ||
const signer = new RNSignerClient({ | ||
connection: { apiKey: Config.API_KEY! }, | ||
}); | ||
import HomeScreen from "./screens/Home"; | ||
|
||
// Test the localstorage polyfill | ||
// TODO: remove this before merging | ||
localStorage.setItem("test", "This is from localstorage polyfill"); | ||
const linking = { | ||
enabled: "auto" as const /* Automatically generate paths for all screens */, | ||
prefixes: ["rn-signer-demo://"], | ||
}; | ||
|
||
const test = localStorage.getItem("test"); | ||
const RootStack = createNativeStackNavigator({ | ||
initialRouteName: "Home", | ||
screens: { | ||
Home: { | ||
screen: HomeScreen, | ||
linking: { path: "home" }, | ||
}, | ||
}, | ||
}); | ||
|
||
export default function App() { | ||
const Navigation = createStaticNavigation(RootStack); | ||
return ( | ||
<View style={styles.container}> | ||
<Text>User: {user ? JSON.stringify(user) : "none"}</Text> | ||
<TextInput | ||
placeholder="email" | ||
onChangeText={setEmail} | ||
value={email} | ||
></TextInput> | ||
<Button | ||
title="Sign in" | ||
onPress={() => { | ||
signer | ||
.initEmailAuth({ email }) | ||
.then(({ orgId }) => setOrgId(orgId)) | ||
.catch(console.error); | ||
}} | ||
></Button> | ||
<TextInput | ||
placeholder="bundle" | ||
onChangeText={setBundle} | ||
value={bundle} | ||
></TextInput> | ||
<Button | ||
title="Complete auth" | ||
onPress={() => { | ||
signer | ||
.completeAuthWithBundle({ | ||
bundle, | ||
authenticatingType: "email", | ||
connectedEventName: "connectedEmail", | ||
orgId, | ||
}) | ||
.then(setUser) | ||
.catch(console.error); | ||
}} | ||
></Button> | ||
<Text>{test}</Text> | ||
</View> | ||
<SafeAreaProvider> | ||
<Navigation linking={linking} /> | ||
</SafeAreaProvider> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}, | ||
box: { | ||
width: 60, | ||
height: 60, | ||
marginVertical: 20, | ||
}, | ||
}); |
Oops, something went wrong.