Skip to content

Commit c214cf6

Browse files
use general example
1 parent fb73d89 commit c214cf6

File tree

80 files changed

+10950
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+10950
-108
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@
1919
npm-debug.log*
2020
yarn-debug.log*
2121
yarn-error.log*
22-
types/

example_general/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example_general/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

example_general/.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
overrides: [
7+
{
8+
files: ['*.ts', '*.tsx'],
9+
rules: {
10+
'@typescript-eslint/no-shadow': ['error'],
11+
'no-shadow': 'off',
12+
'no-undef': 'off',
13+
},
14+
},
15+
],
16+
};

example_general/.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
ios/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
35+
# node.js
36+
#
37+
node_modules/
38+
npm-debug.log
39+
yarn-error.log
40+
41+
# BUCK
42+
buck-out/
43+
\.buckd/
44+
*.keystore
45+
!debug.keystore
46+
47+
# fastlane
48+
#
49+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
50+
# screenshots whenever they are needed.
51+
# For more information about the recommended setup visit:
52+
# https://docs.fastlane.tools/best-practices/source-control/
53+
54+
**/fastlane/report.xml
55+
**/fastlane/Preview.html
56+
**/fastlane/screenshots
57+
**/fastlane/test_output
58+
59+
# Bundle artifact
60+
*.jsbundle
61+
62+
# Ruby / CocoaPods
63+
/ios/Pods/
64+
/vendor/bundle/

example_general/.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

example_general/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

example_general/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example_general/App.tsx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* Generated with the TypeScript template
6+
* https://github.com/react-native-community/react-native-template-typescript
7+
*
8+
* @format
9+
*/
10+
11+
import React, {useState} from 'react';
12+
import * as WebBrowser from '@toruslabs/react-native-web-browser';
13+
import Web3Auth, {
14+
LOGIN_PROVIDER,
15+
OPENLOGIN_NETWORK,
16+
State,
17+
} from '@web3auth/react-native-sdk';
18+
19+
import {Button, StatusBar, StyleSheet, Text, View} from 'react-native';
20+
21+
import {Buffer} from 'buffer';
22+
23+
globalThis.Buffer = globalThis.Buffer || Buffer;
24+
const scheme = 'web3authexposample';
25+
const resolvedRedirectUrl = `${scheme}://auth`;
26+
27+
const App = () => {
28+
const [key, setKey] = useState('');
29+
const [errorMsg, setErrorMsg] = useState('');
30+
const [userInfo, setUserInfo] = useState<State | null>(null);
31+
const login = async () => {
32+
try {
33+
const web3auth = new Web3Auth(WebBrowser, {
34+
clientId:
35+
'BA0mVyeHATikwuXVhXWCNjAxHthlw0w84mUhLuxlC4KZKjvmBsbdbmEWTizJ26YzrbKSWbOZbtGYdVDm0ESuYSg',
36+
network: OPENLOGIN_NETWORK.TESTNET,
37+
});
38+
const state = await web3auth.login({
39+
loginProvider: LOGIN_PROVIDER.GOOGLE,
40+
redirectUrl: resolvedRedirectUrl,
41+
});
42+
setKey(state.privKey || 'no key');
43+
setUserInfo(state);
44+
} catch (e) {
45+
console.error(e);
46+
setErrorMsg(String(e));
47+
}
48+
};
49+
return (
50+
<View style={styles.container}>
51+
{key !== '' ? <Text>Key: {key}</Text> : null}
52+
{userInfo !== null ? (
53+
<Text>UserInfo: {JSON.stringify(userInfo)}</Text>
54+
) : null}
55+
{errorMsg !== '' ? <Text>Error: {errorMsg}</Text> : null}
56+
<Text>Linking URL: {resolvedRedirectUrl}</Text>
57+
<Button title="Login with Web3Auth" onPress={login} />
58+
<StatusBar />
59+
</View>
60+
);
61+
};
62+
63+
const styles = StyleSheet.create({
64+
sectionContainer: {
65+
marginTop: 32,
66+
paddingHorizontal: 24,
67+
},
68+
sectionTitle: {
69+
fontSize: 24,
70+
fontWeight: '600',
71+
},
72+
sectionDescription: {
73+
marginTop: 8,
74+
fontSize: 18,
75+
fontWeight: '400',
76+
},
77+
highlight: {
78+
fontWeight: '700',
79+
},
80+
container: {
81+
flex: 1,
82+
backgroundColor: '#fff',
83+
alignItems: 'center',
84+
justifyContent: 'center',
85+
},
86+
});
87+
88+
export default App;

example_general/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '2.7.5'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

0 commit comments

Comments
 (0)