FormidableLabs / react-native-app-auth

React native bridge for AppAuth - an SDK for communicating with OAuth2 providers
https://commerce.nearform.com/open-source/react-native-app-auth
MIT License
2.04k stars 441 forks source link

[iOS] RN 0.74 NewArch + bridgelesssMode ON authorize, refresh, logout doesn't work, Promise Rejection #980

Closed artur-burlak closed 3 months ago

artur-burlak commented 5 months ago

Issue

On iOS 17.4 RN 0.74.1 NewArch + bridgelessMode ON(THIS IS IMPORTANT) authorize, refresh, logout are throwing promise rejection.

Possible unhandled promise rejection: RNAppAuth.authorize(): Error while converting JavaScript argument 10 to objectiove C type BOOL. Objective C type BOOL is unsupported.

Screenshot 2024-05-26 at 20 19 33 Screenshot 2024-05-26 at 20 20 03

Here useNonce = true by default

ATTENTION: This happening only on bridgelessMode ON. Looks like some turbo modules issue.


Environment

carbonrobot commented 5 months ago

We are actively working on Bridgeless support and hope to have an update soon.

steve4835 commented 5 months ago

I am having this issue as well

Johennes commented 4 months ago

If anyone else is facing this, I used patch-package with

diff --git a/node_modules/react-native-app-auth/ios/RNAppAuth.m b/node_modules/react-native-app-auth/ios/RNAppAuth.m
index eb11aa5..938c045 100644
--- a/node_modules/react-native-app-auth/ios/RNAppAuth.m
+++ b/node_modules/react-native-app-auth/ios/RNAppAuth.m
@@ -97,10 +97,10 @@ - (dispatch_queue_t)methodQueue
                  skipCodeExchange: (BOOL) skipCodeExchange
                  connectionTimeoutSeconds: (double) connectionTimeoutSeconds
                  additionalHeaders: (NSDictionary *_Nullable) additionalHeaders
-                 useNonce: (BOOL *) useNonce
-                 usePKCE: (BOOL *) usePKCE
+                 useNonce: (BOOL) useNonce
+                 usePKCE: (BOOL) usePKCE
                  iosCustomBrowser: (NSString *) iosCustomBrowser
-                 prefersEphemeralSession: (BOOL *) prefersEphemeralSession
+                 prefersEphemeralSession: (BOOL) prefersEphemeralSession
                  resolve: (RCTPromiseResolveBlock) resolve
                  reject: (RCTPromiseRejectBlock)  reject)
 {
@@ -204,7 +204,7 @@ - (dispatch_queue_t)methodQueue
                  serviceConfiguration: (NSDictionary *_Nullable) serviceConfiguration
                  additionalParameters: (NSDictionary *_Nullable) additionalParameters
                  iosCustomBrowser: (NSString *) iosCustomBrowser
-                 prefersEphemeralSession: (BOOL *) prefersEphemeralSession
+                 prefersEphemeralSession: (BOOL) prefersEphemeralSession
                  resolve:(RCTPromiseResolveBlock) resolve
                  reject: (RCTPromiseRejectBlock)  reject)
 {
@@ -325,12 +325,12 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
                           clientId: (NSString *) clientId
                       clientSecret: (NSString *) clientSecret
                             scopes: (NSArray *) scopes
-                          useNonce: (BOOL *) useNonce
-                           usePKCE: (BOOL *) usePKCE
+                          useNonce: (BOOL) useNonce
+                           usePKCE: (BOOL) usePKCE
               additionalParameters: (NSDictionary *_Nullable) additionalParameters
               skipCodeExchange: (BOOL) skipCodeExchange
                   iosCustomBrowser: (NSString *) iosCustomBrowser
-           prefersEphemeralSession: (BOOL *) prefersEphemeralSession
+           prefersEphemeralSession: (BOOL) prefersEphemeralSession
                            resolve: (RCTPromiseResolveBlock) resolve
                             reject: (RCTPromiseRejectBlock)  reject
 {
@@ -489,7 +489,7 @@ - (void)endSessionWithConfiguration: (OIDServiceConfiguration *) configuration
               postLogoutRedirectURL: (NSString *) postLogoutRedirectURL
                additionalParameters: (NSDictionary *_Nullable) additionalParameters
                    iosCustomBrowser: (NSString *) iosCustomBrowser
-            prefersEphemeralSession: (BOOL *) prefersEphemeralSession
+            prefersEphemeralSession: (BOOL) prefersEphemeralSession
                             resolve: (RCTPromiseResolveBlock) resolve
                              reject: (RCTPromiseRejectBlock) reject {

@@ -734,7 +734,7 @@ - (NSString*)getErrorMessage: (NSError*) error {
 }

 - (id<OIDExternalUserAgent>)getExternalUserAgentWithPresentingViewController: (UIViewController *)presentingViewController
-                                                     prefersEphemeralSession: (BOOL *) prefersEphemeralSession
+                                                     prefersEphemeralSession: (BOOL) prefersEphemeralSession
 {
   id<OIDExternalUserAgent> externalUserAgent;
   #if TARGET_OS_MACCATALYST

and it appears to work fine for my use case.

artur-burlak commented 4 months ago

If anyone else is facing this, I used patch-package with

Thank you, I would wait for official update, if it will not take too long

carbonrobot commented 3 months ago

Released in v8.0.0