react-native-nitro-auth 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +254 -0
- package/android/CMakeLists.txt +37 -0
- package/android/build.gradle +99 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/cpp/JniOnLoad.cpp +7 -0
- package/android/src/main/cpp/PlatformAuth+Android.cpp +293 -0
- package/android/src/main/java/com/auth/AuthAdapter.kt +286 -0
- package/android/src/main/java/com/auth/GoogleSignInActivity.kt +73 -0
- package/android/src/main/java/com/auth/NitroAuthModule.kt +19 -0
- package/android/src/main/java/com/auth/NitroAuthPackage.kt +16 -0
- package/app.plugin.js +64 -0
- package/cpp/AuthCache.cpp +105 -0
- package/cpp/AuthCache.hpp +20 -0
- package/cpp/HybridAuth.cpp +213 -0
- package/cpp/HybridAuth.hpp +47 -0
- package/cpp/JSONSerializer.hpp +57 -0
- package/cpp/PlatformAuth.hpp +25 -0
- package/ios/AuthAdapter.swift +200 -0
- package/ios/PlatformAuth+iOS.mm +119 -0
- package/lib/commonjs/Auth.nitro.js +6 -0
- package/lib/commonjs/Auth.nitro.js.map +1 -0
- package/lib/commonjs/Auth.web.js +256 -0
- package/lib/commonjs/Auth.web.js.map +1 -0
- package/lib/commonjs/global.d.js +6 -0
- package/lib/commonjs/global.d.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/index.web.js +52 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/service.js +9 -0
- package/lib/commonjs/service.js.map +1 -0
- package/lib/commonjs/service.web.js +13 -0
- package/lib/commonjs/service.web.js.map +1 -0
- package/lib/commonjs/ui/social-button.js +103 -0
- package/lib/commonjs/ui/social-button.js.map +1 -0
- package/lib/commonjs/ui/social-button.web.js +102 -0
- package/lib/commonjs/ui/social-button.web.js.map +1 -0
- package/lib/commonjs/use-auth.js +144 -0
- package/lib/commonjs/use-auth.js.map +1 -0
- package/lib/module/Auth.nitro.js +4 -0
- package/lib/module/Auth.nitro.js.map +1 -0
- package/lib/module/Auth.web.js +252 -0
- package/lib/module/Auth.web.js.map +1 -0
- package/lib/module/global.d.js +4 -0
- package/lib/module/global.d.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.web.js +7 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/service.js +5 -0
- package/lib/module/service.js.map +1 -0
- package/lib/module/service.web.js +4 -0
- package/lib/module/service.web.js.map +1 -0
- package/lib/module/ui/social-button.js +97 -0
- package/lib/module/ui/social-button.js.map +1 -0
- package/lib/module/ui/social-button.web.js +96 -0
- package/lib/module/ui/social-button.web.js.map +1 -0
- package/lib/module/use-auth.js +140 -0
- package/lib/module/use-auth.js.map +1 -0
- package/lib/typescript/Auth.nitro.d.ts +38 -0
- package/lib/typescript/Auth.nitro.d.ts.map +1 -0
- package/lib/typescript/Auth.web.d.ts +32 -0
- package/lib/typescript/Auth.web.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/index.web.d.ts +5 -0
- package/lib/typescript/index.web.d.ts.map +1 -0
- package/lib/typescript/service.d.ts +3 -0
- package/lib/typescript/service.d.ts.map +1 -0
- package/lib/typescript/service.web.d.ts +2 -0
- package/lib/typescript/service.web.d.ts.map +1 -0
- package/lib/typescript/ui/social-button.d.ts +17 -0
- package/lib/typescript/ui/social-button.d.ts.map +1 -0
- package/lib/typescript/ui/social-button.web.d.ts +17 -0
- package/lib/typescript/ui/social-button.web.d.ts.map +1 -0
- package/lib/typescript/use-auth.d.ts +15 -0
- package/lib/typescript/use-auth.d.ts.map +1 -0
- package/nitro.json +15 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroAuth+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroAuth+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroAuthOnLoad.cpp +44 -0
- package/nitrogen/generated/android/NitroAuthOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/auth/NitroAuthOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroAuth+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/NitroAuthAutolinking.mm +35 -0
- package/nitrogen/generated/ios/NitroAuthAutolinking.swift +12 -0
- package/nitrogen/generated/shared/c++/AuthProvider.hpp +76 -0
- package/nitrogen/generated/shared/c++/AuthTokens.hpp +84 -0
- package/nitrogen/generated/shared/c++/AuthUser.hpp +107 -0
- package/nitrogen/generated/shared/c++/HybridAuthSpec.cpp +30 -0
- package/nitrogen/generated/shared/c++/HybridAuthSpec.hpp +85 -0
- package/nitrogen/generated/shared/c++/LoginOptions.hpp +81 -0
- package/package.json +113 -0
- package/react-native-nitro-auth.podspec +40 -0
- package/src/Auth.nitro.ts +50 -0
- package/src/Auth.web.ts +310 -0
- package/src/global.d.ts +38 -0
- package/src/index.ts +4 -0
- package/src/index.web.ts +4 -0
- package/src/service.ts +4 -0
- package/src/service.web.ts +1 -0
- package/src/ui/social-button.tsx +129 -0
- package/src/ui/social-button.web.tsx +128 -0
- package/src/use-auth.ts +157 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 João Paulo C. Marra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# react-native-nitro-auth
|
|
2
|
+
|
|
3
|
+
🔐 **The fastest authentication library for React Native** — Google & Apple Sign-In with native C++/JSI performance. No bridge overhead. Full feature parity across iOS, Android, and Web.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/react-native-nitro-auth)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Why react-native-nitro-auth?
|
|
9
|
+
|
|
10
|
+
- ⚡ **Zero bridge overhead** — Built on [Nitro Modules](https://github.com/mrousavy/nitro) (C++/JSI), authentication calls are synchronous where possible
|
|
11
|
+
- 🔐 **Google & Apple Sign-In** — Production-ready implementation for iOS, Android, and Web
|
|
12
|
+
- 📦 **Session persistence** — Users stay logged in across app restarts automatically
|
|
13
|
+
- 🎯 **Custom OAuth scopes** — Request only the permissions you need
|
|
14
|
+
- 🔄 **Incremental authorization** — Add scopes later without re-authentication
|
|
15
|
+
- 🔑 **Predictable Error Handling** — Standardized error codes across all platforms
|
|
16
|
+
- 🔁 **Automatic Token Refresh** — Seamlessly handles background token rotation
|
|
17
|
+
- 🎨 **Ready-to-use UI** — Pre-built `SocialButton` with loading states
|
|
18
|
+
- 📱 **Expo & bare RN** — Works with both, config plugin included
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install react-native-nitro-auth react-native-nitro-modules
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Expo Setup
|
|
27
|
+
|
|
28
|
+
Add the plugin to `app.json`:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"expo": {
|
|
33
|
+
"plugins": [
|
|
34
|
+
[
|
|
35
|
+
"react-native-nitro-auth",
|
|
36
|
+
{
|
|
37
|
+
"ios": {
|
|
38
|
+
"googleClientId": "YOUR_IOS_CLIENT_ID.apps.googleusercontent.com",
|
|
39
|
+
"googleUrlScheme": "com.googleusercontent.apps.YOUR_IOS_CLIENT_ID"
|
|
40
|
+
},
|
|
41
|
+
"android": {
|
|
42
|
+
"googleClientId": "YOUR_ANDROID_CLIENT_ID.apps.googleusercontent.com"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
],
|
|
47
|
+
"extra": {
|
|
48
|
+
"googleWebClientId": "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com",
|
|
49
|
+
"appleWebClientId": "com.yourcompany.yourapp.service"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then run:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx expo prebuild
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Bare React Native
|
|
62
|
+
|
|
63
|
+
**iOS:** Add `GIDClientID` to `Info.plist` and enable "Sign in with Apple" capability.
|
|
64
|
+
|
|
65
|
+
**Android:** Add `nitro_auth_google_client_id` string resource in `res/values/strings.xml`.
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
### Using the Hook
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { useAuth, SocialButton } from "react-native-nitro-auth";
|
|
73
|
+
|
|
74
|
+
function LoginScreen() {
|
|
75
|
+
const { user, loading, error, login, logout, hasPlayServices } = useAuth();
|
|
76
|
+
|
|
77
|
+
if (user) {
|
|
78
|
+
return (
|
|
79
|
+
<View>
|
|
80
|
+
<Image source={{ uri: user.photo }} />
|
|
81
|
+
<Text>{user.name}</Text>
|
|
82
|
+
<Button title="Sign Out" onPress={logout} />
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<View>
|
|
89
|
+
{error && <Text style={{ color: "red" }}>{error.message}</Text>}
|
|
90
|
+
{!hasPlayServices && <Text>Please install Google Play Services</Text>}
|
|
91
|
+
|
|
92
|
+
<SocialButton
|
|
93
|
+
provider="google"
|
|
94
|
+
onPress={() => login("google")}
|
|
95
|
+
disabled={loading || !hasPlayServices}
|
|
96
|
+
/>
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Advanced Features
|
|
103
|
+
|
|
104
|
+
### Global Auth State Listener
|
|
105
|
+
|
|
106
|
+
Subscribe to authentication changes outside of React components:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { AuthService } from "react-native-nitro-auth";
|
|
110
|
+
|
|
111
|
+
const unsubscribe = AuthService.onAuthStateChanged((user) => {
|
|
112
|
+
if (user) {
|
|
113
|
+
console.log("Logged in:", user.email);
|
|
114
|
+
} else {
|
|
115
|
+
console.log("Logged out");
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Later...
|
|
120
|
+
unsubscribe();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Standardized Error Codes
|
|
124
|
+
|
|
125
|
+
Handle failures reliably with predictable error strings:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
try {
|
|
129
|
+
await login("google");
|
|
130
|
+
} catch (e) {
|
|
131
|
+
if (e.message === "cancelled") {
|
|
132
|
+
// User closed the popup/picker
|
|
133
|
+
} else if (e.message === "network_error") {
|
|
134
|
+
// Connection issues
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Code | Description |
|
|
140
|
+
| ---------------------- | ---------------------------------------------- |
|
|
141
|
+
| `cancelled` | The user cancelled the sign-in flow |
|
|
142
|
+
| `network_error` | A network error occurred |
|
|
143
|
+
| `configuration_error` | Missing client IDs or invalid setup |
|
|
144
|
+
| `unsupported_provider` | The provider is not supported on this platform |
|
|
145
|
+
|
|
146
|
+
### Automatic Token Refresh
|
|
147
|
+
|
|
148
|
+
The `getAccessToken()` method automatically checks if the current token is expired (or about to expire) and triggers a silent refresh if possible:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const { getAccessToken } = useAuth();
|
|
152
|
+
|
|
153
|
+
// This will silently refresh if needed!
|
|
154
|
+
const token = await getAccessToken();
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Incremental Authorization
|
|
158
|
+
|
|
159
|
+
Add more scopes after initial login — no need to re-authenticate:
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
const { requestScopes, revokeScopes, scopes } = useAuth();
|
|
163
|
+
|
|
164
|
+
// Request additional scope
|
|
165
|
+
await requestScopes(["https://www.googleapis.com/auth/calendar.readonly"]);
|
|
166
|
+
|
|
167
|
+
// Check granted scopes
|
|
168
|
+
console.log("Granted:", scopes);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Manual Token Refresh
|
|
172
|
+
|
|
173
|
+
While `getAccessToken()` handles auto-refresh, you can manually trigger a refresh to get fresh `idToken` or `expirationTime`:
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
const tokens = await refreshToken();
|
|
177
|
+
console.log("New Expiry:", tokens.expirationTime);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## API Reference
|
|
181
|
+
|
|
182
|
+
### useAuth Hook
|
|
183
|
+
|
|
184
|
+
| Property | Type | Description |
|
|
185
|
+
| ----------------- | --------------------------------- | ----------------------------------------- |
|
|
186
|
+
| `user` | `AuthUser \| undefined` | Current authenticated user |
|
|
187
|
+
| `scopes` | `string[]` | Currently granted OAuth scopes |
|
|
188
|
+
| `loading` | `boolean` | True during auth operations |
|
|
189
|
+
| `error` | `Error \| undefined` | Last error that occurred |
|
|
190
|
+
| `hasPlayServices` | `boolean` | (Android) True if Play Services available |
|
|
191
|
+
| `login` | `(provider, options?) => Promise` | Start login flow |
|
|
192
|
+
| `logout` | `() => void` | Clear session (synchronous) |
|
|
193
|
+
| `requestScopes` | `(scopes) => Promise` | Request additional OAuth scopes |
|
|
194
|
+
| `getAccessToken` | `() => Promise<string?>` | Get current access token (auto-refreshes) |
|
|
195
|
+
| `refreshToken` | `() => Promise<AuthTokens>` | Explicitly refresh and return new tokens |
|
|
196
|
+
|
|
197
|
+
### SocialButton Props
|
|
198
|
+
|
|
199
|
+
| Prop | Type | Default | Description |
|
|
200
|
+
| ----------- | ---------------------------------------------- | ----------- | -------------------------------- |
|
|
201
|
+
| `provider` | `"google" \| "apple"` | required | Authentication provider |
|
|
202
|
+
| `variant` | `"primary" \| "outline" \| "white" \| "black"` | `"primary"` | Button style variant |
|
|
203
|
+
| `onSuccess` | `(user: AuthUser) => void` | — | Called with user data on success |
|
|
204
|
+
| `onError` | `(error: Error) => void` | — | Called on failure |
|
|
205
|
+
|
|
206
|
+
## Platform Support
|
|
207
|
+
|
|
208
|
+
| Feature | iOS | Android | Web |
|
|
209
|
+
| ------------------------- | --- | ------- | --- |
|
|
210
|
+
| Google Sign-In | ✅ | ✅ | ✅ |
|
|
211
|
+
| Apple Sign-In | ✅ | ❌ | ✅ |
|
|
212
|
+
| Custom OAuth Scopes | ✅ | ✅ | ✅ |
|
|
213
|
+
| Incremental Authorization | ✅ | ✅ | ✅ |
|
|
214
|
+
| Token Refresh | ✅ | ✅ | ✅ |
|
|
215
|
+
| Session Persistence | ✅ | ✅ | ✅ |
|
|
216
|
+
| Auto-Refresh | ✅ | ✅ | ✅ |
|
|
217
|
+
| Native C++ Performance | ✅ | ✅ | — |
|
|
218
|
+
|
|
219
|
+
## Troubleshooting
|
|
220
|
+
|
|
221
|
+
### Common Issues
|
|
222
|
+
|
|
223
|
+
- **`configuration_error`**: This usually means the `googleClientId` or `GIDClientID` is missing from your native configuration. Double-check your `app.json` or `Info.plist`/`strings.xml`.
|
|
224
|
+
- **`cancelled`**: The user manually closed the sign-in modal. This is expected behavior and should be handled by your UI.
|
|
225
|
+
- **Android Popup not appearing**: Ensure you have configured the correct SHA-1 fingerprint in the Google Cloud Console for your Android app.
|
|
226
|
+
- **Web Popup blocked**: Browsers may block popups if they aren't triggered by a user gesture. Ensure `login()` is called directly from an `onPress` or `onClick` handler.
|
|
227
|
+
|
|
228
|
+
### Checking Setup Status
|
|
229
|
+
|
|
230
|
+
On Android, you can use `hasPlayServices` to check if the device supports Google Sign-In before showing the button.
|
|
231
|
+
|
|
232
|
+
## Testing & Example App
|
|
233
|
+
|
|
234
|
+
The monorepo includes a full-featured example app in `apps/example`.
|
|
235
|
+
|
|
236
|
+
### Running the Example
|
|
237
|
+
|
|
238
|
+
1. **Install dependencies**: `bun install`
|
|
239
|
+
2. **Configure Client IDs**: Update `apps/example/app.json` with your Google/Apple credentials.
|
|
240
|
+
3. **Run on iOS**: `npm run example:ios`
|
|
241
|
+
4. **Run on Android**: `npm run example:android`
|
|
242
|
+
5. **Run on Web**: `npm run start -- --web`
|
|
243
|
+
|
|
244
|
+
## Architecture
|
|
245
|
+
|
|
246
|
+
`react-native-nitro-auth` is built using [Nitro Modules](https://github.com/mrousavy/nitro). Unlike traditional React Native modules, Nitro uses JSI to provide:
|
|
247
|
+
|
|
248
|
+
- **Zero-bridge overhead**: Calls are made directly from JS to C++.
|
|
249
|
+
- **Type safety**: TypeScript types are automatically kept in sync with native C++ and Swift/Kotlin code.
|
|
250
|
+
- **Synchronous access**: Properties like `currentUser` are accessible synchronously without async overhead.
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
MIT
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18.0)
|
|
2
|
+
|
|
3
|
+
project(NitroAuth)
|
|
4
|
+
|
|
5
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
7
|
+
|
|
8
|
+
# 1. Define source files (Manual implementation)
|
|
9
|
+
file(GLOB SOURCES
|
|
10
|
+
"../cpp/*.cpp"
|
|
11
|
+
"./src/main/cpp/*.cpp"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# 2. Create the library target
|
|
15
|
+
add_library(
|
|
16
|
+
NitroAuth
|
|
17
|
+
SHARED
|
|
18
|
+
${SOURCES}
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# 3. Include directories for manual sources
|
|
22
|
+
target_include_directories(
|
|
23
|
+
NitroAuth
|
|
24
|
+
PRIVATE
|
|
25
|
+
"../cpp"
|
|
26
|
+
"./src/main/cpp"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# 4. Include Nitrogen Autolinking (adds generated sources, finding packages, linking libs)
|
|
30
|
+
include("../nitrogen/generated/android/NitroAuth+autolinking.cmake")
|
|
31
|
+
|
|
32
|
+
# 5. Link standard Android libraries
|
|
33
|
+
target_link_libraries(
|
|
34
|
+
NitroAuth
|
|
35
|
+
android
|
|
36
|
+
log
|
|
37
|
+
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.10.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def reactNativeArchitectures() {
|
|
13
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
14
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
23
|
+
|
|
24
|
+
apply from: "../nitrogen/generated/android/NitroAuth+autolinking.gradle"
|
|
25
|
+
|
|
26
|
+
if (isNewArchitectureEnabled()) {
|
|
27
|
+
apply plugin: "com.facebook.react"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def getExtOrDefault(name) {
|
|
31
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NitroAuth_" + name]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def getExtOrIntegerDefault(name) {
|
|
35
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NitroAuth_" + name]).toInteger()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
android {
|
|
39
|
+
namespace "com.auth"
|
|
40
|
+
|
|
41
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
42
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
43
|
+
|
|
44
|
+
defaultConfig {
|
|
45
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
46
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
47
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
48
|
+
|
|
49
|
+
externalNativeBuild {
|
|
50
|
+
cmake {
|
|
51
|
+
cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
|
|
52
|
+
arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
53
|
+
abiFilters (*reactNativeArchitectures())
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
externalNativeBuild {
|
|
59
|
+
cmake {
|
|
60
|
+
path "CMakeLists.txt"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
buildFeatures {
|
|
65
|
+
buildConfig true
|
|
66
|
+
prefab true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
compileOptions {
|
|
70
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
71
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
sourceSets {
|
|
75
|
+
main {
|
|
76
|
+
java.srcDirs += ["src/main/java"]
|
|
77
|
+
if (isNewArchitectureEnabled()) {
|
|
78
|
+
java.srcDirs += ["${project.buildDir}/generated/source/codegen/java"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
repositories {
|
|
85
|
+
mavenCentral()
|
|
86
|
+
google()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dependencies {
|
|
90
|
+
implementation "com.facebook.react:react-native:+"
|
|
91
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
|
|
92
|
+
implementation project(":react-native-nitro-modules")
|
|
93
|
+
|
|
94
|
+
// Google Sign-In SDK (full scope support)
|
|
95
|
+
implementation "com.google.android.gms:play-services-auth:21.3.0"
|
|
96
|
+
|
|
97
|
+
// Activity result APIs
|
|
98
|
+
implementation "androidx.activity:activity-ktx:1.9.3"
|
|
99
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
4
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
5
|
+
|
|
6
|
+
<application>
|
|
7
|
+
<activity
|
|
8
|
+
android:name="com.auth.GoogleSignInActivity"
|
|
9
|
+
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
|
10
|
+
android:exported="false" />
|
|
11
|
+
</application>
|
|
12
|
+
</manifest>
|