react-native-nitro-auth 0.1.1 → 0.1.3
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/README.md +27 -50
- package/android/build.gradle +1 -0
- package/android/proguard-rules.pro +4 -0
- package/app.plugin.js +4 -1
- package/ios/AuthAdapter.swift +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
# react-native-nitro-auth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
🚀 **High-performance, JSI-powered Authentication for React Native.**
|
|
4
4
|
|
|
5
|
-
[
|
|
6
|
-
[](LICENSE)
|
|
5
|
+
Nitro Auth is a modern authentication library for React Native built on top of [Nitro Modules](https://github.com/mrousavy/nitro). It provides a unified, type-safe API for Google and Apple Sign-In with zero-bridge overhead.
|
|
7
6
|
|
|
8
|
-
## Why
|
|
7
|
+
## Why Nitro Auth?
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
Nitro Auth is designed to replace legacy modules like `@react-native-google-signin/google-signin` with a modern, high-performance architecture.
|
|
10
|
+
|
|
11
|
+
| Feature | Legacy Modules | Nitro Auth |
|
|
12
|
+
| :--- | :--- | :--- |
|
|
13
|
+
| **Performance** | Async bridge overhead (JSON) | **Direct JSI C++ (Zero-copy)** |
|
|
14
|
+
| **Persistence** | Varies / Manual | **Built-in & Automatic** |
|
|
15
|
+
| **Setup** | Manual async initialization | **Sync & declarative plugins** |
|
|
16
|
+
| **Types** | Manual / Brittle | **Fully Generated (Nitrogen)** |
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- 🏎️ **Ultra-fast**: Direct C++ calls using JSI (no JSON serialization).
|
|
21
|
+
- 🛡️ **Fully Type-Safe**: Shared types between TypeScript, C++, Swift, and Kotlin.
|
|
22
|
+
- �� **Incremental Auth**: Request additional OAuth scopes on the fly.
|
|
23
|
+
- 📦 **Expo Ready**: Comes with a powerful Config Plugin for zero-config setup.
|
|
24
|
+
- 📱 **Cross-Platform**: Unified API for iOS, Android, and Web.
|
|
25
|
+
- 🔁 **Auto-Refresh**: Synchronous access to tokens with automatic silent refresh.
|
|
19
26
|
|
|
20
27
|
## Installation
|
|
21
28
|
|
|
22
29
|
```bash
|
|
23
|
-
|
|
30
|
+
bun add react-native-nitro-auth react-native-nitro-modules
|
|
31
|
+
bun prebuild
|
|
24
32
|
```
|
|
25
33
|
|
|
26
34
|
### Expo Setup
|
|
@@ -36,6 +44,7 @@ Add the plugin to `app.json`:
|
|
|
36
44
|
{
|
|
37
45
|
"ios": {
|
|
38
46
|
"googleClientId": "YOUR_IOS_CLIENT_ID.apps.googleusercontent.com",
|
|
47
|
+
"googleServerClientId": "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com",
|
|
39
48
|
"googleUrlScheme": "com.googleusercontent.apps.YOUR_IOS_CLIENT_ID"
|
|
40
49
|
},
|
|
41
50
|
"android": {
|
|
@@ -43,24 +52,17 @@ Add the plugin to `app.json`:
|
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
]
|
|
46
|
-
]
|
|
47
|
-
"extra": {
|
|
48
|
-
"googleWebClientId": "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com",
|
|
49
|
-
"appleWebClientId": "com.yourcompany.yourapp.service"
|
|
50
|
-
}
|
|
55
|
+
]
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
```
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npx expo prebuild
|
|
59
|
-
```
|
|
60
|
+
> [!NOTE]
|
|
61
|
+
> `googleServerClientId` is only required if you need a `serverAuthCode` for backend integration.
|
|
60
62
|
|
|
61
63
|
### Bare React Native
|
|
62
64
|
|
|
63
|
-
**iOS:** Add `GIDClientID` to `Info.plist` and enable "Sign in with Apple" capability.
|
|
65
|
+
**iOS:** Add `GIDClientID` (and optionally `GIDServerClientID`) to `Info.plist` and enable "Sign in with Apple" capability.
|
|
64
66
|
|
|
65
67
|
**Android:** Add `nitro_auth_google_client_id` string resource in `res/values/strings.xml`.
|
|
66
68
|
|
|
@@ -220,31 +222,6 @@ if (user?.serverAuthCode) {
|
|
|
220
222
|
| Auto-Refresh | ✅ | ✅ | ✅ |
|
|
221
223
|
| Native C++ Performance | ✅ | ✅ | — |
|
|
222
224
|
|
|
223
|
-
## Troubleshooting
|
|
224
|
-
|
|
225
|
-
### Common Issues
|
|
226
|
-
|
|
227
|
-
- **`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`.
|
|
228
|
-
- **`cancelled`**: The user manually closed the sign-in modal. This is expected behavior and should be handled by your UI.
|
|
229
|
-
- **Android Popup not appearing**: Ensure you have configured the correct SHA-1 fingerprint in the Google Cloud Console for your Android app.
|
|
230
|
-
- **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.
|
|
231
|
-
|
|
232
|
-
### Checking Setup Status
|
|
233
|
-
|
|
234
|
-
On Android, you can use `hasPlayServices` to check if the device supports Google Sign-In before showing the button.
|
|
235
|
-
|
|
236
|
-
## Testing & Example App
|
|
237
|
-
|
|
238
|
-
The monorepo includes a full-featured example app in `apps/example`.
|
|
239
|
-
|
|
240
|
-
### Running the Example
|
|
241
|
-
|
|
242
|
-
1. **Install dependencies**: `bun install`
|
|
243
|
-
2. **Configure Client IDs**: Update `apps/example/app.json` with your Google/Apple credentials.
|
|
244
|
-
3. **Run on iOS**: `npm run example:ios`
|
|
245
|
-
4. **Run on Android**: `npm run example:android`
|
|
246
|
-
5. **Run on Web**: `npm run start -- --web`
|
|
247
|
-
|
|
248
225
|
## Architecture
|
|
249
226
|
|
|
250
227
|
`react-native-nitro-auth` is built using [Nitro Modules](https://github.com/mrousavy/nitro). Unlike traditional React Native modules, Nitro uses JSI to provide:
|
package/android/build.gradle
CHANGED
package/app.plugin.js
CHANGED
|
@@ -14,6 +14,9 @@ const withNitroAuth = (config, props = {}) => {
|
|
|
14
14
|
if (ios.googleClientId) {
|
|
15
15
|
config.modResults.GIDClientID = ios.googleClientId;
|
|
16
16
|
}
|
|
17
|
+
if (ios.googleServerClientId) {
|
|
18
|
+
config.modResults.GIDServerClientID = ios.googleServerClientId;
|
|
19
|
+
}
|
|
17
20
|
if (ios.googleUrlScheme) {
|
|
18
21
|
const existingSchemes = config.modResults.CFBundleURLTypes || [];
|
|
19
22
|
if (
|
|
@@ -60,5 +63,5 @@ const withNitroAuth = (config, props = {}) => {
|
|
|
60
63
|
module.exports = createRunOncePlugin(
|
|
61
64
|
withNitroAuth,
|
|
62
65
|
"react-native-nitro-auth",
|
|
63
|
-
"0.1.
|
|
66
|
+
"0.1.3"
|
|
64
67
|
);
|
package/ios/AuthAdapter.swift
CHANGED
|
@@ -14,6 +14,8 @@ public class AuthAdapter: NSObject {
|
|
|
14
14
|
return
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
let serverClientId = Bundle.main.object(forInfoDictionaryKey: "GIDServerClientID") as? String
|
|
18
|
+
|
|
17
19
|
DispatchQueue.main.async {
|
|
18
20
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
19
21
|
let rootVC = windowScene.windows.first?.rootViewController else {
|
|
@@ -21,6 +23,9 @@ public class AuthAdapter: NSObject {
|
|
|
21
23
|
return
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
let config = GIDConfiguration(clientID: clientId, serverClientID: serverClientId)
|
|
27
|
+
GIDSignIn.sharedInstance.configuration = config
|
|
28
|
+
|
|
24
29
|
let additionalScopes = scopes.isEmpty ? nil : scopes
|
|
25
30
|
GIDSignIn.sharedInstance.signIn(withPresenting: rootVC, hint: loginHint, additionalScopes: additionalScopes) { result, error in
|
|
26
31
|
if let error = error {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "High-performance authentication library for React Native with Google Sign-In and Apple Sign-In support, powered by Nitro Modules (JSI)",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|