Skip to content

Commit f99f053

Browse files
committed
initial commit
0 parents  commit f99f053

32 files changed

+8326
-0
lines changed

.buckconfig

+6
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

.bundle/config

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

.eslintrc.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
rules: {
5+
'array-bracket-spacing': 'error',
6+
'react-native/no-inline-styles': 0,
7+
'comma-spacing': [
8+
2,
9+
{
10+
after: true,
11+
before: false
12+
}
13+
],
14+
quotes: [
15+
'error',
16+
'single',
17+
{
18+
avoidEscape: true
19+
}
20+
],
21+
semi: ['error', 'never'],
22+
'template-curly-spacing': ['error', 'always'],
23+
'valid-jsdoc': 'off',
24+
'comma-dangle': 0
25+
}
26+
}

.flowconfig

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; Flow doesn't support platforms
12+
.*/Libraries/Utilities/LoadingView.js
13+
14+
[untyped]
15+
.*/node_modules/@react-native-community/cli/.*/.*
16+
17+
[include]
18+
19+
[libs]
20+
node_modules/react-native/interface.js
21+
node_modules/react-native/flow/
22+
23+
[options]
24+
emoji=true
25+
26+
exact_by_default=true
27+
28+
format.bracket_spacing=false
29+
30+
module.file_ext=.js
31+
module.file_ext=.json
32+
module.file_ext=.ios.js
33+
34+
munge_underscores=true
35+
36+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
37+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
38+
39+
suppress_type=$FlowIssue
40+
suppress_type=$FlowFixMe
41+
suppress_type=$FlowFixMeProps
42+
suppress_type=$FlowFixMeState
43+
44+
[lints]
45+
sketchy-null-number=warn
46+
sketchy-null-mixed=warn
47+
sketchy-number=warn
48+
untyped-type-import=warn
49+
nonstrict-import=warn
50+
deprecated-type=warn
51+
unsafe-getters-setters=warn
52+
unnecessary-invariant=warn
53+
signature-verification-failure=warn
54+
55+
[strict]
56+
deprecated-type
57+
nonstrict-import
58+
sketchy-null
59+
unclear-type
60+
unsafe-getters-setters
61+
untyped-import
62+
untyped-type-import
63+
64+
[version]
65+
^0.162.0

.gitignore

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Xcode
2+
!**/*.xcodeproj
3+
!**/*.pbxproj
4+
!**/*.xcworkspacedata
5+
!**/*.xcsettings
6+
!**/*.xcscheme
7+
*.pbxuser
8+
!default.pbxuser
9+
*.mode1v3
10+
!default.mode1v3
11+
*.mode2v3
12+
!default.mode2v3
13+
*.perspectivev3
14+
!default.perspectivev3
15+
xcuserdata
16+
*.xccheckout
17+
*.moved-aside
18+
DerivedData
19+
*.hmap
20+
*.ipa
21+
*.xcuserstate
22+
project.xcworkspace
23+
24+
# Gradle
25+
/build/
26+
/packages/react-native-gradle-plugin/build/
27+
/packages/rn-tester/android/app/.cxx/
28+
/packages/rn-tester/android/app/build/
29+
/packages/rn-tester/android/app/gradle/
30+
/packages/rn-tester/android/app/gradlew
31+
/packages/rn-tester/android/app/gradlew.bat
32+
/ReactAndroid/build/
33+
/ReactAndroid/.cxx/
34+
/ReactAndroid/gradle/
35+
/ReactAndroid/gradlew
36+
/ReactAndroid/gradlew.bat
37+
/template/android/app/build/
38+
/template/android/build/
39+
40+
# Buck
41+
.buckd
42+
buck-out
43+
/.lsp.buckd
44+
/.lsp-buck-out
45+
/ReactAndroid/src/main/jni/prebuilt/lib/
46+
/ReactAndroid/src/main/gen
47+
48+
# Android Studio
49+
.project
50+
.settings
51+
.classpath
52+
53+
# Watchman
54+
.watchmanconfig
55+
56+
# Android
57+
.idea
58+
.gradle
59+
local.properties
60+
*.iml
61+
/android/
62+
63+
# Node
64+
node_modules
65+
*.log
66+
.nvm
67+
/bots/node_modules/
68+
package-lock.json
69+
70+
# OS X
71+
.DS_Store
72+
73+
# Hermes
74+
/sdks/hermes
75+
76+
# Test generated files
77+
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
78+
*.js.meta
79+
80+
/coverage
81+
/third-party
82+
83+
# Root dir shouldn't have Xcode project
84+
/*.xcodeproj
85+
86+
# ReactCommon subdir shouldn't have Xcode project
87+
/ReactCommon/**/*.xcodeproj
88+
/packages/rn-tester/build
89+
/packages/rn-tester/android/app/build/*
90+
91+
# Libs that shouldn't have Xcode project
92+
/Libraries/FBLazyVector/**/*.xcodeproj
93+
/Libraries/RCTRequired/**/*.xcodeproj
94+
/React/CoreModules/**/*.xcodeproj
95+
/React/FBReactNativeSpec/**/*.xcodeproj
96+
/packages/react-native-codegen/**/*.xcodeproj
97+
98+
# Ruby Gems (Bundler)
99+
/vendor
100+
/template/vendor
101+
102+
# iOS / CocoaPods
103+
/template/ios/build/
104+
/template/ios/Pods/
105+
/template/ios/Podfile.lock
106+
/packages/rn-tester/Gemfile.lock
107+
108+
# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here.
109+
/packages/rn-tester/Pods/*
110+
!/packages/rn-tester/Pods/__offline_mirrors__
111+
112+
# react-native-codegen
113+
/React/FBReactNativeSpec/FBReactNativeSpec
114+
/packages/react-native-codegen/lib
115+
/ReactCommon/react/renderer/components/rncore/
116+
/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec*
117+
118+
# Visual studio
119+
.vscode
120+
.vs
121+
122+
# Android memory profiler files
123+
*.hprof

.prettierrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'none',
6+
arrowParens: 'avoid',
7+
semi: false
8+
};

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.4

App.js

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
* @flow strict-local
7+
*/
8+
9+
import React, {useState} from 'react'
10+
import type {Node} from 'react'
11+
import {SafeAreaView, StyleSheet, Text, View, Button} from 'react-native'
12+
import {authorize, logout} from 'react-native-app-auth'
13+
14+
import AppBar from './components/AppBar'
15+
16+
// Get PlusAuth Config
17+
const config = require('./plusauth-env')
18+
19+
const defaultAuthState = {
20+
accessToken: '',
21+
accessTokenExpirationDate: '',
22+
refreshToken: '',
23+
idToken: ''
24+
}
25+
26+
const App: () => Node = () => {
27+
const [isLoggedIn, setIsLoggedIn] = useState(false)
28+
const [profileInfo, setProfileInfo] = useState(null)
29+
const [authState, setAuthState] = useState(defaultAuthState)
30+
31+
const login = async () => {
32+
try {
33+
// Redirect PlusAuth Login page to authenticate user
34+
const result = await authorize(config)
35+
setAuthState(result)
36+
setIsLoggedIn(true)
37+
} catch (error) {
38+
console.log(error)
39+
}
40+
}
41+
42+
const signOut = async () => {
43+
try {
44+
// Logout session from PlusAuth
45+
await logout(config, {
46+
idToken: authState.idToken,
47+
postLogoutRedirectUrl: config.postLogoutRedirectUrl
48+
})
49+
// Clear local session state
50+
setAuthState(defaultAuthState)
51+
setIsLoggedIn(false)
52+
} catch (error) {
53+
console.log(error)
54+
}
55+
}
56+
57+
const getProfileInfo = async () => {
58+
try {
59+
// Get authenticated user info
60+
const response = await fetch(
61+
'https://starters.plusauth.com/oidc/userinfo',
62+
{
63+
method: 'GET',
64+
headers: {
65+
Authorization: 'Bearer ' + authState.accessToken
66+
}
67+
}
68+
)
69+
const json = await response.json()
70+
setProfileInfo(json)
71+
} catch (error) {
72+
console.error(error)
73+
}
74+
}
75+
76+
return (
77+
<SafeAreaView>
78+
<AppBar />
79+
<View style={styles.indexContainer}>
80+
<Text style={styles.welcomeText}>
81+
Welcome to PlusAuth React Native Demo!
82+
</Text>
83+
<Text style={styles.usernameText}>
84+
Username: {profileInfo === null ? '-' : profileInfo.username}
85+
</Text>
86+
<View style={styles.buttonContainer}>
87+
{!isLoggedIn ? (
88+
<Button title="Login" color="#2196F3" onPress={() => login()} />
89+
) : (
90+
<>
91+
<Button
92+
color="#2196F3"
93+
title="Get Profile Info"
94+
onPress={() => getProfileInfo()}
95+
/>
96+
<View style={styles.profileButton}>
97+
<Button
98+
color="#D32F2F"
99+
title="Logout"
100+
onPress={() => signOut()}
101+
/>
102+
</View>
103+
<Text style={{marginTop: 16}}>
104+
{profileInfo === null ? '' : JSON.stringify(profileInfo)}
105+
</Text>
106+
</>
107+
)}
108+
</View>
109+
</View>
110+
</SafeAreaView>
111+
)
112+
}
113+
114+
const styles = StyleSheet.create({
115+
indexContainer: {
116+
textAlign: 'center'
117+
},
118+
welcomeText: {
119+
marginTop: 12,
120+
textAlign: 'center',
121+
fontSize: 18
122+
},
123+
usernameText: {
124+
marginTop: 12,
125+
textAlign: 'center',
126+
fontSize: 16
127+
},
128+
buttonContainer: {
129+
marginTop: 16,
130+
paddingHorizontal: 24
131+
},
132+
profileButton: {
133+
marginTop: 16
134+
}
135+
})
136+
137+
export default App

Gemfile

+6
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.4'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

0 commit comments

Comments
 (0)