react-native-nitro-auth 0.5.6 → 0.5.7
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 +8 -2
- package/android/src/main/cpp/PlatformAuth+Android.cpp +1 -1
- package/android/src/main/java/com/auth/AuthAdapter.kt +43 -21
- package/ios/AuthAdapter.swift +43 -14
- package/ios/PlatformAuth+iOS.mm +20 -1
- package/lib/commonjs/service.js +21 -17
- package/lib/commonjs/service.js.map +1 -1
- package/lib/commonjs/use-auth.js +26 -10
- package/lib/commonjs/use-auth.js.map +1 -1
- package/lib/commonjs/utils/auth-error.js +1 -1
- package/lib/commonjs/utils/auth-error.js.map +1 -1
- package/lib/module/service.js +21 -17
- package/lib/module/service.js.map +1 -1
- package/lib/module/use-auth.js +26 -10
- package/lib/module/use-auth.js.map +1 -1
- package/lib/module/utils/auth-error.js +1 -1
- package/lib/module/utils/auth-error.js.map +1 -1
- package/lib/typescript/commonjs/Auth.nitro.d.ts +2 -2
- package/lib/typescript/commonjs/Auth.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/service.d.ts.map +1 -1
- package/lib/typescript/commonjs/use-auth.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/auth-error.d.ts.map +1 -1
- package/lib/typescript/module/Auth.nitro.d.ts +2 -2
- package/lib/typescript/module/Auth.nitro.d.ts.map +1 -1
- package/lib/typescript/module/service.d.ts.map +1 -1
- package/lib/typescript/module/use-auth.d.ts.map +1 -1
- package/lib/typescript/module/utils/auth-error.d.ts.map +1 -1
- package/nitro.json +4 -1
- package/nitrogen/generated/ios/NitroAuth+autolinking.rb +2 -0
- package/package.json +4 -3
- package/src/Auth.nitro.ts +3 -1
- package/src/service.ts +22 -17
- package/src/use-auth.ts +35 -6
- package/src/utils/auth-error.ts +2 -0
package/README.md
CHANGED
|
@@ -701,6 +701,8 @@ try {
|
|
|
701
701
|
| `popup_blocked` | The browser blocked the popup window |
|
|
702
702
|
| `network_error` | A network or connectivity error occurred |
|
|
703
703
|
| `configuration_error` | Missing client IDs, invalid tenant, or misconfigured setup |
|
|
704
|
+
| `not_signed_in` | The operation requires an authenticated user/session |
|
|
705
|
+
| `operation_in_progress`| Another auth flow of the same kind is already running |
|
|
704
706
|
| `unsupported_provider` | The provider is not supported on this platform |
|
|
705
707
|
| `invalid_state` | PKCE state mismatch — possible CSRF attack |
|
|
706
708
|
| `invalid_nonce` | Nonce mismatch in token response — possible replay attack |
|
|
@@ -803,6 +805,8 @@ This is useful for scenarios where:
|
|
|
803
805
|
- You need to ensure the user can select any account they've added to their device
|
|
804
806
|
- The cached session is interfering with the expected account selection UX
|
|
805
807
|
|
|
808
|
+
On Android, `forceAccountPicker` routes through the legacy Google Sign-In chooser to guarantee the account picker appears. Credential Manager / One-Tap remains the default when the chooser is not forced.
|
|
809
|
+
|
|
806
810
|
## API Reference
|
|
807
811
|
|
|
808
812
|
### Package Exports
|
|
@@ -830,7 +834,7 @@ import {
|
|
|
830
834
|
| Type | Definition |
|
|
831
835
|
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
832
836
|
| `AuthProvider` | `"google" \| "apple" \| "microsoft"` |
|
|
833
|
-
| `AuthErrorCode` | `"cancelled" \| "timeout" \| "popup_blocked" \| "network_error" \| "configuration_error" \| "unsupported_provider" \| "invalid_state" \| "invalid_nonce" \| "token_error" \| "no_id_token" \| "parse_error" \| "refresh_failed" \| "unknown"` |
|
|
837
|
+
| `AuthErrorCode` | `"cancelled" \| "timeout" \| "popup_blocked" \| "network_error" \| "configuration_error" \| "not_signed_in" \| "operation_in_progress" \| "unsupported_provider" \| "invalid_state" \| "invalid_nonce" \| "token_error" \| "no_id_token" \| "parse_error" \| "refresh_failed" \| "unknown"` |
|
|
834
838
|
| `MicrosoftPrompt` | `"login" \| "consent" \| "select_account" \| "none"` |
|
|
835
839
|
|
|
836
840
|
### `AuthUser`
|
|
@@ -869,7 +873,7 @@ import {
|
|
|
869
873
|
| `loginHint` | `string` | All | Prefills account identifier |
|
|
870
874
|
| `useOneTap` | `boolean` | Android | Use Credential Manager/One-Tap flow |
|
|
871
875
|
| `useSheet` | `boolean` | iOS | Use native Google Sign-In sheet |
|
|
872
|
-
| `forceAccountPicker` | `boolean` | All | Always show account chooser
|
|
876
|
+
| `forceAccountPicker` | `boolean` | All | Always show account chooser; Android Google uses the legacy chooser path |
|
|
873
877
|
| `useLegacyGoogleSignIn` | `boolean` | Android | Use legacy Google Sign-In (required when you need `serverAuthCode`) |
|
|
874
878
|
| `tenant` | `string` | Microsoft | Tenant (`common`, `organizations`, `consumers`, tenant id, or full authority URL) |
|
|
875
879
|
| `prompt` | `MicrosoftPrompt` | Microsoft | Prompt behavior |
|
|
@@ -1003,6 +1007,8 @@ function toAuthErrorCode(raw: string): AuthErrorCode; // Returns "unknown" for u
|
|
|
1003
1007
|
| `popup_blocked` | Browser blocked popup opening |
|
|
1004
1008
|
| `network_error` | Network failure |
|
|
1005
1009
|
| `configuration_error` | Missing/invalid provider configuration |
|
|
1010
|
+
| `not_signed_in` | Operation requires an active authenticated user |
|
|
1011
|
+
| `operation_in_progress`| Another auth flow is already running |
|
|
1006
1012
|
| `unsupported_provider` | Provider not supported on this platform |
|
|
1007
1013
|
| `invalid_state` | PKCE state mismatch (possible CSRF) |
|
|
1008
1014
|
| `invalid_nonce` | Nonce mismatch in token response |
|
|
@@ -531,7 +531,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_auth_AuthAdapter_nativeOnLoginError(
|
|
|
531
531
|
if (loginPromise) loginPromise->reject(std::make_exception_ptr(std::runtime_error(errorStr)));
|
|
532
532
|
if (scopesPromise) scopesPromise->reject(std::make_exception_ptr(std::runtime_error(errorStr)));
|
|
533
533
|
if (silentPromise) {
|
|
534
|
-
if (errorStr == "
|
|
534
|
+
if (errorStr == "not_signed_in") silentPromise->resolve(std::nullopt);
|
|
535
535
|
else silentPromise->reject(std::make_exception_ptr(std::runtime_error(errorStr)));
|
|
536
536
|
}
|
|
537
537
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// • getLastSignedInAccount – persists session across app restarts via GMS store; no drop-in replacement
|
|
4
4
|
// • silentSignIn – AuthorizationClient.authorize() still requires an Activity for interactive fallback
|
|
5
5
|
// • revokeAccess – no equivalent in Credential Manager or Identity.getAuthorizationClient()
|
|
6
|
-
// All modern entry-points use Credential Manager (One-Tap)
|
|
6
|
+
// All modern entry-points use Credential Manager (One-Tap) unless the caller explicitly needs
|
|
7
|
+
// Android's account chooser semantics, which still require the legacy Google Sign-In flow.
|
|
7
8
|
|
|
8
9
|
package com.auth
|
|
9
10
|
|
|
@@ -40,11 +41,14 @@ import java.util.UUID
|
|
|
40
41
|
|
|
41
42
|
object AuthAdapter {
|
|
42
43
|
private const val TAG = "AuthAdapter"
|
|
44
|
+
private val defaultMicrosoftScopes =
|
|
45
|
+
listOf("openid", "email", "profile", "offline_access", "User.Read")
|
|
43
46
|
|
|
44
47
|
@Volatile
|
|
45
48
|
private var isInitialized = false
|
|
46
49
|
|
|
47
50
|
private var appContext: Context? = null
|
|
51
|
+
@Volatile
|
|
48
52
|
private var currentActivity: Activity? = null
|
|
49
53
|
private var googleSignInClient: GoogleSignInClient? = null
|
|
50
54
|
private var lifecycleCallbacks: Application.ActivityLifecycleCallbacks? = null
|
|
@@ -65,18 +69,22 @@ object AuthAdapter {
|
|
|
65
69
|
private var pendingMicrosoftClientId: String? = null
|
|
66
70
|
@Volatile
|
|
67
71
|
private var pendingMicrosoftB2cDomain: String? = null
|
|
72
|
+
@Volatile
|
|
73
|
+
private var microsoftAuthInProgress = false
|
|
68
74
|
|
|
69
75
|
@Volatile
|
|
70
76
|
private var inMemoryMicrosoftRefreshToken: String? = null
|
|
71
77
|
@Volatile
|
|
72
78
|
private var inMemoryMicrosoftScopes: List<String> =
|
|
73
|
-
|
|
79
|
+
defaultMicrosoftScopes
|
|
74
80
|
|
|
75
81
|
// Module-scoped coroutine scope — cancelled on module invalidation via dispose().
|
|
76
82
|
private var moduleScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
|
77
83
|
|
|
78
84
|
@JvmStatic
|
|
79
85
|
private external fun nativeInitialize(context: Context)
|
|
86
|
+
@JvmStatic
|
|
87
|
+
private external fun nativeDispose()
|
|
80
88
|
|
|
81
89
|
@JvmStatic
|
|
82
90
|
private external fun nativeOnLoginSuccess(
|
|
@@ -136,6 +144,8 @@ object AuthAdapter {
|
|
|
136
144
|
fun dispose() {
|
|
137
145
|
moduleScope.cancel()
|
|
138
146
|
moduleScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
|
147
|
+
runCatching { nativeDispose() }
|
|
148
|
+
.onFailure { Log.w(TAG, "Failed to dispose NitroAuth native bridge", it) }
|
|
139
149
|
|
|
140
150
|
val app = appContext as? Application
|
|
141
151
|
lifecycleCallbacks?.let { app?.unregisterActivityLifecycleCallbacks(it) }
|
|
@@ -200,7 +210,7 @@ object AuthAdapter {
|
|
|
200
210
|
val requestedScopes = scopes?.toList() ?: listOf("email", "profile")
|
|
201
211
|
pendingScopes = requestedScopes
|
|
202
212
|
|
|
203
|
-
if (useLegacyGoogleSignIn) {
|
|
213
|
+
if (useLegacyGoogleSignIn || forceAccountPicker) {
|
|
204
214
|
loginLegacy(context, clientId, requestedScopes, loginHint, forceAccountPicker, "login")
|
|
205
215
|
return
|
|
206
216
|
}
|
|
@@ -217,9 +227,21 @@ object AuthAdapter {
|
|
|
217
227
|
pendingOrigin = origin
|
|
218
228
|
|
|
219
229
|
val effectiveTenant = tenant ?: getMicrosoftTenantFromResources(ctx) ?: "common"
|
|
220
|
-
val effectiveScopes = scopes?.toList() ?:
|
|
230
|
+
val effectiveScopes = scopes?.toList() ?: defaultMicrosoftScopes
|
|
221
231
|
val effectivePrompt = prompt ?: "select_account"
|
|
222
|
-
|
|
232
|
+
|
|
233
|
+
synchronized(this) {
|
|
234
|
+
if (microsoftAuthInProgress) {
|
|
235
|
+
nativeOnLoginError(
|
|
236
|
+
origin,
|
|
237
|
+
"operation_in_progress",
|
|
238
|
+
"Microsoft authentication already in progress",
|
|
239
|
+
)
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
microsoftAuthInProgress = true
|
|
243
|
+
pendingMicrosoftScopes = effectiveScopes
|
|
244
|
+
}
|
|
223
245
|
|
|
224
246
|
val codeVerifier = generateCodeVerifier()
|
|
225
247
|
val codeChallenge = generateCodeChallenge(codeVerifier)
|
|
@@ -261,6 +283,7 @@ object AuthAdapter {
|
|
|
261
283
|
ctx.startActivity(browserIntent)
|
|
262
284
|
}
|
|
263
285
|
} catch (e: Exception) {
|
|
286
|
+
clearPkceState()
|
|
264
287
|
nativeOnLoginError(origin, "unknown", e.message)
|
|
265
288
|
}
|
|
266
289
|
}
|
|
@@ -399,16 +422,15 @@ object AuthAdapter {
|
|
|
399
422
|
|
|
400
423
|
val email = claims["preferred_username"] ?: claims["email"]
|
|
401
424
|
val name = claims["name"]
|
|
425
|
+
val grantedScopes = pendingMicrosoftScopes.ifEmpty { defaultMicrosoftScopes }
|
|
402
426
|
|
|
403
427
|
if (refreshToken.isNotEmpty()) inMemoryMicrosoftRefreshToken = refreshToken
|
|
404
|
-
inMemoryMicrosoftScopes =
|
|
405
|
-
listOf("openid", "email", "profile", "offline_access", "User.Read")
|
|
406
|
-
}
|
|
428
|
+
inMemoryMicrosoftScopes = grantedScopes
|
|
407
429
|
|
|
408
430
|
clearPkceState()
|
|
409
431
|
nativeOnLoginSuccess(
|
|
410
432
|
origin, "microsoft", email, name, null, idToken, accessToken, null,
|
|
411
|
-
|
|
433
|
+
grantedScopes.toTypedArray(), expirationTime
|
|
412
434
|
)
|
|
413
435
|
} catch (e: Exception) {
|
|
414
436
|
clearPkceState()
|
|
@@ -424,6 +446,8 @@ object AuthAdapter {
|
|
|
424
446
|
pendingMicrosoftTenant = null
|
|
425
447
|
pendingMicrosoftClientId = null
|
|
426
448
|
pendingMicrosoftB2cDomain = null
|
|
449
|
+
pendingMicrosoftScopes = emptyList()
|
|
450
|
+
microsoftAuthInProgress = false
|
|
427
451
|
}
|
|
428
452
|
|
|
429
453
|
private fun decodeJwt(token: String): Map<String, String> {
|
|
@@ -590,7 +614,7 @@ object AuthAdapter {
|
|
|
590
614
|
loginMicrosoft(ctx, mergedScopes.toTypedArray(), null, tenant, null, "scopes")
|
|
591
615
|
return
|
|
592
616
|
}
|
|
593
|
-
nativeOnLoginError("scopes", "
|
|
617
|
+
nativeOnLoginError("scopes", "not_signed_in", "No user logged in")
|
|
594
618
|
}
|
|
595
619
|
|
|
596
620
|
// refreshTokenSync uses the legacy silentSignIn because AuthorizationClient (the recommended
|
|
@@ -628,7 +652,7 @@ object AuthAdapter {
|
|
|
628
652
|
refreshMicrosoftTokenForRefresh(ctx, refreshToken)
|
|
629
653
|
return
|
|
630
654
|
}
|
|
631
|
-
nativeOnRefreshError("
|
|
655
|
+
nativeOnRefreshError("not_signed_in", "No user logged in")
|
|
632
656
|
}
|
|
633
657
|
|
|
634
658
|
@JvmStatic
|
|
@@ -659,7 +683,7 @@ object AuthAdapter {
|
|
|
659
683
|
GoogleSignIn.getClient(ctx, gso).signOut()
|
|
660
684
|
}
|
|
661
685
|
inMemoryMicrosoftRefreshToken = null
|
|
662
|
-
inMemoryMicrosoftScopes =
|
|
686
|
+
inMemoryMicrosoftScopes = defaultMicrosoftScopes
|
|
663
687
|
}
|
|
664
688
|
|
|
665
689
|
@JvmStatic
|
|
@@ -672,7 +696,7 @@ object AuthAdapter {
|
|
|
672
696
|
GoogleSignIn.getClient(ctx, gso).revokeAccess()
|
|
673
697
|
}
|
|
674
698
|
inMemoryMicrosoftRefreshToken = null
|
|
675
|
-
inMemoryMicrosoftScopes =
|
|
699
|
+
inMemoryMicrosoftScopes = defaultMicrosoftScopes
|
|
676
700
|
}
|
|
677
701
|
|
|
678
702
|
private fun getClientIdFromResources(context: Context): String? {
|
|
@@ -695,7 +719,7 @@ object AuthAdapter {
|
|
|
695
719
|
if (refreshToken != null) {
|
|
696
720
|
refreshMicrosoftToken(ctx, refreshToken)
|
|
697
721
|
} else {
|
|
698
|
-
nativeOnLoginError("silent", "
|
|
722
|
+
nativeOnLoginError("silent", "not_signed_in", "No session")
|
|
699
723
|
}
|
|
700
724
|
}
|
|
701
725
|
}
|
|
@@ -704,6 +728,7 @@ object AuthAdapter {
|
|
|
704
728
|
val clientId = getMicrosoftClientIdFromResources(context)
|
|
705
729
|
val tenant = getMicrosoftTenantFromResources(context) ?: "common"
|
|
706
730
|
val b2cDomain = getMicrosoftB2cDomainFromResources(context)
|
|
731
|
+
val effectiveScopes = inMemoryMicrosoftScopes.ifEmpty { defaultMicrosoftScopes }
|
|
707
732
|
|
|
708
733
|
if (clientId == null) {
|
|
709
734
|
nativeOnLoginError("silent", "configuration_error", "Microsoft Client ID is required for refresh")
|
|
@@ -749,14 +774,12 @@ object AuthAdapter {
|
|
|
749
774
|
val claims = decodeJwt(newIdToken)
|
|
750
775
|
|
|
751
776
|
if (newRefreshToken.isNotEmpty()) inMemoryMicrosoftRefreshToken = newRefreshToken
|
|
752
|
-
inMemoryMicrosoftScopes =
|
|
753
|
-
listOf("openid", "email", "profile", "offline_access", "User.Read")
|
|
754
|
-
}
|
|
777
|
+
inMemoryMicrosoftScopes = effectiveScopes
|
|
755
778
|
|
|
756
779
|
nativeOnLoginSuccess("silent", "microsoft",
|
|
757
780
|
claims["preferred_username"] ?: claims["email"],
|
|
758
781
|
claims["name"], null,
|
|
759
|
-
newIdToken, newAccessToken, null,
|
|
782
|
+
newIdToken, newAccessToken, null, effectiveScopes.toTypedArray(), expirationTime)
|
|
760
783
|
} else {
|
|
761
784
|
if (responseCode in 400..499) {
|
|
762
785
|
inMemoryMicrosoftRefreshToken = null // Token is invalid, clear it
|
|
@@ -787,6 +810,7 @@ object AuthAdapter {
|
|
|
787
810
|
val clientId = getMicrosoftClientIdFromResources(context)
|
|
788
811
|
val tenant = getMicrosoftTenantFromResources(context) ?: "common"
|
|
789
812
|
val b2cDomain = getMicrosoftB2cDomainFromResources(context)
|
|
813
|
+
val effectiveScopes = inMemoryMicrosoftScopes.ifEmpty { defaultMicrosoftScopes }
|
|
790
814
|
|
|
791
815
|
if (clientId == null) {
|
|
792
816
|
nativeOnRefreshError("configuration_error", "Microsoft Client ID not configured")
|
|
@@ -831,9 +855,7 @@ object AuthAdapter {
|
|
|
831
855
|
val expirationTime = if (expiresIn > 0) System.currentTimeMillis() + expiresIn * 1000 else null
|
|
832
856
|
|
|
833
857
|
if (newRefreshToken.isNotEmpty()) inMemoryMicrosoftRefreshToken = newRefreshToken
|
|
834
|
-
inMemoryMicrosoftScopes =
|
|
835
|
-
listOf("openid", "email", "profile", "offline_access", "User.Read")
|
|
836
|
-
}
|
|
858
|
+
inMemoryMicrosoftScopes = effectiveScopes
|
|
837
859
|
|
|
838
860
|
nativeOnRefreshSuccess(
|
|
839
861
|
newIdToken.ifEmpty { null },
|
package/ios/AuthAdapter.swift
CHANGED
|
@@ -25,8 +25,7 @@ public class AuthAdapter: NSObject {
|
|
|
25
25
|
let serverClientId = Bundle.main.object(forInfoDictionaryKey: "GIDServerClientID") as? String
|
|
26
26
|
|
|
27
27
|
DispatchQueue.main.async {
|
|
28
|
-
guard let
|
|
29
|
-
let rootVC = windowScene.windows.first?.rootViewController else {
|
|
28
|
+
guard let rootVC = presentingViewController() else {
|
|
30
29
|
completion(nil, "no_window")
|
|
31
30
|
return
|
|
32
31
|
}
|
|
@@ -62,8 +61,7 @@ public class AuthAdapter: NSObject {
|
|
|
62
61
|
objc_setAssociatedObject(controller, &delegateHandle, delegate, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
|
63
62
|
|
|
64
63
|
DispatchQueue.main.async {
|
|
65
|
-
guard let
|
|
66
|
-
let window = windowScene.windows.first(where: { $0.isKeyWindow }) ?? windowScene.windows.first else {
|
|
64
|
+
guard let window = activeWindow() else {
|
|
67
65
|
completion(nil, "no_window")
|
|
68
66
|
return
|
|
69
67
|
}
|
|
@@ -191,14 +189,8 @@ public class AuthAdapter: NSObject {
|
|
|
191
189
|
completion: completion
|
|
192
190
|
)
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
guard let
|
|
196
|
-
let window = windowScene.windows.first(where: { $0.isKeyWindow }) ?? windowScene.windows.first,
|
|
197
|
-
let rootVC = window.rootViewController else {
|
|
198
|
-
completion(nil, "no_window")
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
guard let window = rootVC.view.window else {
|
|
192
|
+
|
|
193
|
+
guard let window = activeWindow() else {
|
|
202
194
|
completion(nil, "no_window")
|
|
203
195
|
return
|
|
204
196
|
}
|
|
@@ -325,6 +317,7 @@ public class AuthAdapter: NSObject {
|
|
|
325
317
|
"idToken": idToken,
|
|
326
318
|
"accessToken": accessToken,
|
|
327
319
|
"serverAuthCode": "",
|
|
320
|
+
"scopes": scopes,
|
|
328
321
|
"expirationTime": expirationTime,
|
|
329
322
|
"underlyingError": ""
|
|
330
323
|
]
|
|
@@ -431,8 +424,7 @@ public class AuthAdapter: NSObject {
|
|
|
431
424
|
public static func addScopes(scopes: [String], completion: @escaping (NSDictionary?, String?) -> Void) {
|
|
432
425
|
if let currentUser = GIDSignIn.sharedInstance.currentUser {
|
|
433
426
|
DispatchQueue.main.async {
|
|
434
|
-
guard let
|
|
435
|
-
let rootVC = windowScene.windows.first?.rootViewController else {
|
|
427
|
+
guard let rootVC = presentingViewController() else {
|
|
436
428
|
completion(nil, "no_window")
|
|
437
429
|
return
|
|
438
430
|
}
|
|
@@ -512,6 +504,7 @@ public class AuthAdapter: NSObject {
|
|
|
512
504
|
private static func tryMicrosoftSilentRefresh(completion: @escaping (NSDictionary?) -> Void) {
|
|
513
505
|
tokenStoreLock.lock()
|
|
514
506
|
let refreshToken = inMemoryMicrosoftRefreshToken
|
|
507
|
+
let currentScopes = inMemoryMicrosoftScopes
|
|
515
508
|
tokenStoreLock.unlock()
|
|
516
509
|
guard let refreshToken = refreshToken else {
|
|
517
510
|
completion(nil)
|
|
@@ -592,6 +585,7 @@ public class AuthAdapter: NSObject {
|
|
|
592
585
|
"idToken": idToken,
|
|
593
586
|
"accessToken": accessToken,
|
|
594
587
|
"serverAuthCode": "",
|
|
588
|
+
"scopes": currentScopes,
|
|
595
589
|
"expirationTime": expirationTime
|
|
596
590
|
]
|
|
597
591
|
completion(resultData as NSDictionary)
|
|
@@ -697,6 +691,41 @@ public class AuthAdapter: NSObject {
|
|
|
697
691
|
inMemoryGoogleServerAuthCode = nil
|
|
698
692
|
tokenStoreLock.unlock()
|
|
699
693
|
}
|
|
694
|
+
|
|
695
|
+
private static func activeWindow() -> UIWindow? {
|
|
696
|
+
let windowScenes = UIApplication.shared.connectedScenes
|
|
697
|
+
.compactMap { $0 as? UIWindowScene }
|
|
698
|
+
.filter {
|
|
699
|
+
$0.activationState == .foregroundActive ||
|
|
700
|
+
$0.activationState == .foregroundInactive
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
for scene in windowScenes {
|
|
704
|
+
if let keyWindow = scene.windows.first(where: { $0.isKeyWindow }) {
|
|
705
|
+
return keyWindow
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return windowScenes.lazy.compactMap { $0.windows.first }.first
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
private static func presentingViewController() -> UIViewController? {
|
|
713
|
+
guard let rootViewController = activeWindow()?.rootViewController else {
|
|
714
|
+
return nil
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
var current = rootViewController
|
|
718
|
+
while let presented = current.presentedViewController {
|
|
719
|
+
current = presented
|
|
720
|
+
}
|
|
721
|
+
if let navigationController = current as? UINavigationController {
|
|
722
|
+
return navigationController.visibleViewController ?? navigationController
|
|
723
|
+
}
|
|
724
|
+
if let tabBarController = current as? UITabBarController {
|
|
725
|
+
return tabBarController.selectedViewController ?? tabBarController
|
|
726
|
+
}
|
|
727
|
+
return current
|
|
728
|
+
}
|
|
700
729
|
}
|
|
701
730
|
|
|
702
731
|
private var delegateHandle: UInt8 = 0
|
package/ios/PlatformAuth+iOS.mm
CHANGED
|
@@ -18,7 +18,23 @@ namespace margelo::nitro::NitroAuth {
|
|
|
18
18
|
|
|
19
19
|
inline std::optional<std::string> nsToStd(NSString* _Nullable ns) {
|
|
20
20
|
if (ns == nil) return std::nullopt;
|
|
21
|
-
|
|
21
|
+
std::string value([ns UTF8String]);
|
|
22
|
+
if (value.empty()) return std::nullopt;
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
inline std::optional<std::vector<std::string>> nsArrayToStd(NSArray<NSString*>* _Nullable nsArray) {
|
|
27
|
+
if (nsArray == nil || nsArray.count == 0) return std::nullopt;
|
|
28
|
+
|
|
29
|
+
std::vector<std::string> values;
|
|
30
|
+
values.reserve(nsArray.count);
|
|
31
|
+
for (NSString* value in nsArray) {
|
|
32
|
+
if (value.length == 0) continue;
|
|
33
|
+
values.emplace_back([value UTF8String]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (values.empty()) return std::nullopt;
|
|
37
|
+
return values;
|
|
22
38
|
}
|
|
23
39
|
|
|
24
40
|
std::shared_ptr<Promise<AuthUser>> PlatformAuth::login(AuthProvider provider, const std::optional<LoginOptions>& options) {
|
|
@@ -85,6 +101,7 @@ std::shared_ptr<Promise<AuthUser>> PlatformAuth::login(AuthProvider provider, co
|
|
|
85
101
|
user.idToken = nsToStd([data objectForKey:@"idToken"]);
|
|
86
102
|
if ([data objectForKey:@"accessToken"]) user.accessToken = nsToStd([data objectForKey:@"accessToken"]);
|
|
87
103
|
if ([data objectForKey:@"serverAuthCode"]) user.serverAuthCode = nsToStd([data objectForKey:@"serverAuthCode"]);
|
|
104
|
+
if ([data objectForKey:@"scopes"]) user.scopes = nsArrayToStd([data objectForKey:@"scopes"]);
|
|
88
105
|
if ([data objectForKey:@"expirationTime"]) user.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
89
106
|
if ([data objectForKey:@"underlyingError"]) user.underlyingError = nsToStd([data objectForKey:@"underlyingError"]);
|
|
90
107
|
|
|
@@ -123,6 +140,7 @@ std::shared_ptr<Promise<AuthUser>> PlatformAuth::requestScopes(const std::vector
|
|
|
123
140
|
user.idToken = nsToStd([data objectForKey:@"idToken"]);
|
|
124
141
|
if ([data objectForKey:@"accessToken"]) user.accessToken = nsToStd([data objectForKey:@"accessToken"]);
|
|
125
142
|
if ([data objectForKey:@"serverAuthCode"]) user.serverAuthCode = nsToStd([data objectForKey:@"serverAuthCode"]);
|
|
143
|
+
if ([data objectForKey:@"scopes"]) user.scopes = nsArrayToStd([data objectForKey:@"scopes"]);
|
|
126
144
|
if ([data objectForKey:@"expirationTime"]) user.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
127
145
|
if ([data objectForKey:@"underlyingError"]) user.underlyingError = nsToStd([data objectForKey:@"underlyingError"]);
|
|
128
146
|
promise->resolve(user);
|
|
@@ -168,6 +186,7 @@ std::shared_ptr<Promise<std::optional<AuthUser>>> PlatformAuth::silentRestore()
|
|
|
168
186
|
user.idToken = nsToStd([data objectForKey:@"idToken"]);
|
|
169
187
|
if ([data objectForKey:@"accessToken"]) user.accessToken = nsToStd([data objectForKey:@"accessToken"]);
|
|
170
188
|
if ([data objectForKey:@"serverAuthCode"]) user.serverAuthCode = nsToStd([data objectForKey:@"serverAuthCode"]);
|
|
189
|
+
if ([data objectForKey:@"scopes"]) user.scopes = nsArrayToStd([data objectForKey:@"scopes"]);
|
|
171
190
|
if ([data objectForKey:@"expirationTime"]) user.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
172
191
|
if ([data objectForKey:@"underlyingError"]) user.underlyingError = nsToStd([data objectForKey:@"underlyingError"]);
|
|
173
192
|
promise->resolve(user);
|
package/lib/commonjs/service.js
CHANGED
|
@@ -6,23 +6,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.AuthService = void 0;
|
|
7
7
|
var _reactNativeNitroModules = require("react-native-nitro-modules");
|
|
8
8
|
var _authError = require("./utils/auth-error.js");
|
|
9
|
-
|
|
9
|
+
let nitroAuth;
|
|
10
|
+
function getNitroAuth() {
|
|
11
|
+
nitroAuth ??= _reactNativeNitroModules.NitroModules.createHybridObject("Auth");
|
|
12
|
+
return nitroAuth;
|
|
13
|
+
}
|
|
10
14
|
const AuthService = exports.AuthService = {
|
|
11
15
|
get name() {
|
|
12
|
-
return
|
|
16
|
+
return getNitroAuth().name;
|
|
13
17
|
},
|
|
14
18
|
get currentUser() {
|
|
15
|
-
return
|
|
19
|
+
return getNitroAuth().currentUser;
|
|
16
20
|
},
|
|
17
21
|
get grantedScopes() {
|
|
18
|
-
return
|
|
22
|
+
return getNitroAuth().grantedScopes;
|
|
19
23
|
},
|
|
20
24
|
get hasPlayServices() {
|
|
21
|
-
return
|
|
25
|
+
return getNitroAuth().hasPlayServices;
|
|
22
26
|
},
|
|
23
27
|
async login(provider, options) {
|
|
24
28
|
try {
|
|
25
|
-
await
|
|
29
|
+
await getNitroAuth().login(provider, options);
|
|
26
30
|
return;
|
|
27
31
|
} catch (e) {
|
|
28
32
|
throw _authError.AuthError.from(e);
|
|
@@ -30,7 +34,7 @@ const AuthService = exports.AuthService = {
|
|
|
30
34
|
},
|
|
31
35
|
async requestScopes(scopes) {
|
|
32
36
|
try {
|
|
33
|
-
await
|
|
37
|
+
await getNitroAuth().requestScopes(scopes);
|
|
34
38
|
return;
|
|
35
39
|
} catch (e) {
|
|
36
40
|
throw _authError.AuthError.from(e);
|
|
@@ -38,7 +42,7 @@ const AuthService = exports.AuthService = {
|
|
|
38
42
|
},
|
|
39
43
|
async revokeScopes(scopes) {
|
|
40
44
|
try {
|
|
41
|
-
await
|
|
45
|
+
await getNitroAuth().revokeScopes(scopes);
|
|
42
46
|
return;
|
|
43
47
|
} catch (e) {
|
|
44
48
|
throw _authError.AuthError.from(e);
|
|
@@ -46,43 +50,43 @@ const AuthService = exports.AuthService = {
|
|
|
46
50
|
},
|
|
47
51
|
async getAccessToken() {
|
|
48
52
|
try {
|
|
49
|
-
return await
|
|
53
|
+
return await getNitroAuth().getAccessToken();
|
|
50
54
|
} catch (e) {
|
|
51
55
|
throw _authError.AuthError.from(e);
|
|
52
56
|
}
|
|
53
57
|
},
|
|
54
58
|
async refreshToken() {
|
|
55
59
|
try {
|
|
56
|
-
return await
|
|
60
|
+
return await getNitroAuth().refreshToken();
|
|
57
61
|
} catch (e) {
|
|
58
62
|
throw _authError.AuthError.from(e);
|
|
59
63
|
}
|
|
60
64
|
},
|
|
61
65
|
logout() {
|
|
62
|
-
|
|
66
|
+
getNitroAuth().logout();
|
|
63
67
|
},
|
|
64
68
|
async silentRestore() {
|
|
65
69
|
try {
|
|
66
|
-
await
|
|
70
|
+
await getNitroAuth().silentRestore();
|
|
67
71
|
return;
|
|
68
72
|
} catch (e) {
|
|
69
73
|
throw _authError.AuthError.from(e);
|
|
70
74
|
}
|
|
71
75
|
},
|
|
72
76
|
onAuthStateChanged(callback) {
|
|
73
|
-
return
|
|
77
|
+
return getNitroAuth().onAuthStateChanged(callback);
|
|
74
78
|
},
|
|
75
79
|
onTokensRefreshed(callback) {
|
|
76
|
-
return
|
|
80
|
+
return getNitroAuth().onTokensRefreshed(callback);
|
|
77
81
|
},
|
|
78
82
|
setLoggingEnabled(enabled) {
|
|
79
|
-
|
|
83
|
+
getNitroAuth().setLoggingEnabled(enabled);
|
|
80
84
|
},
|
|
81
85
|
dispose() {
|
|
82
|
-
|
|
86
|
+
getNitroAuth().dispose();
|
|
83
87
|
},
|
|
84
88
|
equals(other) {
|
|
85
|
-
return
|
|
89
|
+
return getNitroAuth().equals(other);
|
|
86
90
|
}
|
|
87
91
|
};
|
|
88
92
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","_authError","nitroAuth","NitroModules","createHybridObject","AuthService","exports","name","currentUser","grantedScopes","hasPlayServices","login","provider","options","e","AuthError","from","requestScopes","scopes","revokeScopes","getAccessToken","refreshToken","logout","silentRestore","onAuthStateChanged","callback","onTokensRefreshed","setLoggingEnabled","enabled","dispose","equals","other"],"sourceRoot":"../../src","sources":["service.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAQA,IAAAC,UAAA,GAAAD,OAAA;AAEA,
|
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","_authError","nitroAuth","getNitroAuth","NitroModules","createHybridObject","AuthService","exports","name","currentUser","grantedScopes","hasPlayServices","login","provider","options","e","AuthError","from","requestScopes","scopes","revokeScopes","getAccessToken","refreshToken","logout","silentRestore","onAuthStateChanged","callback","onTokensRefreshed","setLoggingEnabled","enabled","dispose","equals","other"],"sourceRoot":"../../src","sources":["service.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAQA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAIE,SAA2B;AAE/B,SAASC,YAAYA,CAAA,EAAS;EAC5BD,SAAS,KAAKE,qCAAY,CAACC,kBAAkB,CAAO,MAAM,CAAC;EAC3D,OAAOH,SAAS;AAClB;AAEO,MAAMI,WAAiB,GAAAC,OAAA,CAAAD,WAAA,GAAG;EAC/B,IAAIE,IAAIA,CAAA,EAAG;IACT,OAAOL,YAAY,CAAC,CAAC,CAACK,IAAI;EAC5B,CAAC;EAED,IAAIC,WAAWA,CAAA,EAAG;IAChB,OAAON,YAAY,CAAC,CAAC,CAACM,WAAW;EACnC,CAAC;EAED,IAAIC,aAAaA,CAAA,EAAG;IAClB,OAAOP,YAAY,CAAC,CAAC,CAACO,aAAa;EACrC,CAAC;EAED,IAAIC,eAAeA,CAAA,EAAG;IACpB,OAAOR,YAAY,CAAC,CAAC,CAACQ,eAAe;EACvC,CAAC;EAED,MAAMC,KAAKA,CAACC,QAAsB,EAAEC,OAAsB,EAAE;IAC1D,IAAI;MACF,MAAMX,YAAY,CAAC,CAAC,CAACS,KAAK,CAACC,QAAQ,EAAEC,OAAO,CAAC;MAC7C;IACF,CA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AC,CAAC;IACzB;EACF,CAAC;EAEDU,kBAAkBA,CAACC,QAA8C,EAAE;IACjE,OAAOvB,YAAY,CAAC,CAAC,CAACsB,kBAAkB,CAACC,QAAQ,CAAC;EACpD,CAAC;EAEDC,iBAAiBA,CAACD,QAAsC,EAAE;IACxD,OAAOvB,YAAY,CAAC,CAAC,CAACwB,iBAAiB,CAACD,QAAQ,CAAC;EACnD,CAAC;EAEDE,iBAAiBA,CAACC,OAAgB,EAAE;IAClC1B,YAAY,CAAC,CAAC,CAACyB,iBAAiB,CAACC,OAAO,CAAC;EAC3C,CAAC;EAEDC,OAAOA,CAAA,EAAG;IACR3B,YAAY,CAAC,CAAC,CAAC2B,OAAO,CAAC,CAAC;EAC1B,CAAC;EAEDC,MAAMA,CAACC,KAAoC,EAAW;IACpD,OAAO7B,YAAY,CAAC,CAAC,CAAC4B,MAAM,CAACC,KAAK,CAAC;EACrC;AACF,CAAC","ignoreList":[]}
|
package/lib/commonjs/use-auth.js
CHANGED
|
@@ -7,14 +7,25 @@ exports.useAuth = useAuth;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _service = require("./service");
|
|
9
9
|
var _authError = require("./utils/auth-error.js");
|
|
10
|
+
const EMPTY_SCOPES = [];
|
|
10
11
|
const areScopesEqual = (left, right) => {
|
|
12
|
+
if (left === right) return true;
|
|
11
13
|
if (left.length !== right.length) return false;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
let matchesInOrder = true;
|
|
15
|
+
for (let i = 0; i < left.length; i += 1) {
|
|
16
|
+
if (left[i] !== right[i]) {
|
|
17
|
+
matchesInOrder = false;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (matchesInOrder) return true;
|
|
22
|
+
const remaining = new Set(left);
|
|
23
|
+
for (const scope of right) {
|
|
24
|
+
if (!remaining.delete(scope)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
16
27
|
}
|
|
17
|
-
return
|
|
28
|
+
return remaining.size === 0;
|
|
18
29
|
};
|
|
19
30
|
function useAuth() {
|
|
20
31
|
const [state, setState] = (0, _react.useState)({
|
|
@@ -59,11 +70,16 @@ function useAuth() {
|
|
|
59
70
|
}, [syncStateFromService]);
|
|
60
71
|
const logout = (0, _react.useCallback)(() => {
|
|
61
72
|
_service.AuthService.logout();
|
|
62
|
-
setState({
|
|
63
|
-
user
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
setState(prev => {
|
|
74
|
+
if (prev.user === undefined && prev.scopes.length === 0 && prev.loading === false && prev.error === undefined) {
|
|
75
|
+
return prev;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
user: undefined,
|
|
79
|
+
scopes: EMPTY_SCOPES,
|
|
80
|
+
loading: false,
|
|
81
|
+
error: undefined
|
|
82
|
+
};
|
|
67
83
|
});
|
|
68
84
|
}, []);
|
|
69
85
|
const requestScopes = (0, _react.useCallback)(async newScopes => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_service","_authError","areScopesEqual","left","right","length","
|
|
1
|
+
{"version":3,"names":["_react","require","_service","_authError","EMPTY_SCOPES","areScopesEqual","left","right","length","matchesInOrder","i","remaining","Set","scope","delete","size","useAuth","state","setState","useState","user","AuthService","currentUser","scopes","grantedScopes","loading","error","undefined","syncStateFromService","useCallback","nextLoading","nextError","nextUser","nextScopes","prev","login","provider","options","e","AuthError","from","logout","requestScopes","newScopes","revokeScopes","scopesToRevoke","getAccessToken","refreshToken","tokens","silentRestore","useEffect","unsubscribeAuth","onAuthStateChanged","unsubscribeTokens","onTokensRefreshed","useMemo","hasPlayServices"],"sourceRoot":"../../src","sources":["use-auth.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,MAAMG,YAAsB,GAAG,EAAE;AASjC,MAAMC,c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AACH","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.AuthError = void 0;
|
|
7
7
|
exports.isAuthErrorCode = isAuthErrorCode;
|
|
8
8
|
exports.toAuthErrorCode = toAuthErrorCode;
|
|
9
|
-
const AUTH_ERROR_CODES = new Set(["cancelled", "timeout", "popup_blocked", "network_error", "configuration_error", "unsupported_provider", "invalid_state", "invalid_nonce", "token_error", "no_id_token", "parse_error", "refresh_failed", "unknown"]);
|
|
9
|
+
const AUTH_ERROR_CODES = new Set(["cancelled", "timeout", "popup_blocked", "network_error", "configuration_error", "not_signed_in", "operation_in_progress", "unsupported_provider", "invalid_state", "invalid_nonce", "token_error", "no_id_token", "parse_error", "refresh_failed", "unknown"]);
|
|
10
10
|
function isAuthErrorCode(value) {
|
|
11
11
|
return AUTH_ERROR_CODES.has(value);
|
|
12
12
|
}
|