react-native-oauth-essentials 1.0.12 → 1.2.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.
Files changed (53) hide show
  1. package/OauthEssentials.podspec +17 -2
  2. package/README.md +385 -361
  3. package/android/build.gradle +15 -10
  4. package/android/src/main/java/com/oauthessentials/CredentialError.kt +4 -1
  5. package/android/src/main/java/com/oauthessentials/CredentialFactory.kt +24 -2
  6. package/android/src/main/java/com/oauthessentials/CustomTabsActivity.kt +14 -1
  7. package/android/src/main/java/com/oauthessentials/OauthEssentialsModule.kt +445 -187
  8. package/app.plugin.js +1 -0
  9. package/ios/AppleIdRetriever.swift +25 -26
  10. package/ios/CredentialError.swift +3 -0
  11. package/ios/CredentialFactory.swift +38 -20
  12. package/ios/CredentialsType.swift +1 -0
  13. package/ios/GoogleIdRetriever.swift +132 -56
  14. package/ios/HybridRetriever.swift +12 -18
  15. package/ios/OauthEssentials.h +0 -3
  16. package/ios/OauthEssentials.mm +45 -2
  17. package/ios/OauthEssentialsModule.swift +266 -57
  18. package/ios/PasskeyRetriever.swift +31 -49
  19. package/ios/PasswordRetriever.swift +10 -30
  20. package/ios/RCTPromiseSettler.swift +125 -0
  21. package/jest/index.js +149 -0
  22. package/lib/module/NativeOauthEssentials.js +10 -1
  23. package/lib/module/NativeOauthEssentials.js.map +1 -1
  24. package/lib/module/errors.js +38 -0
  25. package/lib/module/errors.js.map +1 -0
  26. package/lib/module/index.js +432 -58
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/oauth.js +97 -0
  29. package/lib/module/oauth.js.map +1 -0
  30. package/lib/module/platform.js +108 -0
  31. package/lib/module/platform.js.map +1 -0
  32. package/lib/module/types.js +46 -1
  33. package/lib/module/types.js.map +1 -1
  34. package/lib/typescript/src/NativeOauthEssentials.d.ts +70 -16
  35. package/lib/typescript/src/NativeOauthEssentials.d.ts.map +1 -1
  36. package/lib/typescript/src/errors.d.ts +18 -0
  37. package/lib/typescript/src/errors.d.ts.map +1 -0
  38. package/lib/typescript/src/index.d.ts +235 -40
  39. package/lib/typescript/src/index.d.ts.map +1 -1
  40. package/lib/typescript/src/oauth.d.ts +32 -0
  41. package/lib/typescript/src/oauth.d.ts.map +1 -0
  42. package/lib/typescript/src/platform.d.ts +39 -0
  43. package/lib/typescript/src/platform.d.ts.map +1 -0
  44. package/lib/typescript/src/types.d.ts +190 -2
  45. package/lib/typescript/src/types.d.ts.map +1 -1
  46. package/package.json +9 -5
  47. package/plugin/withOauthEssentials.js +291 -0
  48. package/src/NativeOauthEssentials.ts +91 -17
  49. package/src/errors.ts +49 -0
  50. package/src/index.tsx +587 -80
  51. package/src/oauth.ts +140 -0
  52. package/src/platform.ts +121 -0
  53. package/src/types.ts +200 -1
@@ -60,24 +60,29 @@ android {
60
60
  sourceCompatibility JavaVersion.VERSION_1_8
61
61
  targetCompatibility JavaVersion.VERSION_1_8
62
62
  }
63
+
64
+ // googleid 1.2.1 ships Kotlin 2.4 metadata; the Kotlin of the app (RN: 2.1) only reads up to
65
+ // 2.2. Only this module references its classes, and the bytecode is plain JVM.
66
+ kotlinOptions {
67
+ freeCompilerArgs += ["-Xskip-metadata-version-check"]
68
+ }
63
69
  }
64
70
 
65
71
  dependencies {
66
72
  implementation "com.facebook.react:react-android"
67
73
 
68
74
  // Needed oauth libraries
69
- implementation 'androidx.browser:browser:1.9.0'
70
- // androidx.credentials fixado em estável 1.5.0 com `strictly`: o
71
- // play-services-auth:21.5.0 puxa transitivamente credentials/-play-services-auth
72
- // 1.6.0-rc01 (release candidate), cujo provider GMS deixa o chooser
73
- // (SignInCredentialChooserActivity) pendurado — getCredential nunca resolve.
74
- // `strictly` faz o downgrade da transitiva e propaga pro classpath do app.
75
+ implementation 'androidx.browser:browser:1.10.0'
76
+ // androidx.credentials fixado em 1.6.0 (estável) com `strictly`, para a
77
+ // transitiva do play-services-auth não puxar um release candidate cujo
78
+ // provider GMS deixa o chooser (SignInCredentialChooserActivity) pendurado —
79
+ // getCredential nunca resolve. `strictly` propaga o pin pro classpath do app.
75
80
  implementation('androidx.credentials:credentials') {
76
- version { strictly '1.5.0' }
81
+ version { strictly '1.6.0' }
77
82
  }
78
83
  implementation('androidx.credentials:credentials-play-services-auth') {
79
- version { strictly '1.5.0' }
84
+ version { strictly '1.6.0' }
80
85
  }
81
- implementation 'com.google.android.libraries.identity.googleid:googleid:1.2.0'
82
- implementation 'com.google.android.gms:play-services-auth:21.5.0'
86
+ implementation 'com.google.android.libraries.identity.googleid:googleid:1.2.1'
87
+ implementation 'com.google.android.gms:play-services-auth:22.0.0'
83
88
  }
@@ -3,5 +3,8 @@ package com.oauthessentials
3
3
  enum class CredentialError(val code: String) {
4
4
  NO_ACTIVITY_ERROR("NO_ACTIVITY_ERROR"),
5
5
  INVALID_RESULT_ERROR("INVALID_RESULT_ERROR"),
6
- NOT_SUPPORTED_ERROR("NOT_SUPPORTED")
6
+ NOT_SUPPORTED_ERROR("NOT_SUPPORTED_ERROR"),
7
+ NO_SIGN_IN_AVAILABLE("NO_SIGN_IN_AVAILABLE"),
8
+ BROWSER_UNAVAILABLE("BROWSER_UNAVAILABLE"),
9
+ CONFIGURATION_ERROR("CONFIGURATION_ERROR")
7
10
  }
@@ -9,6 +9,7 @@ import androidx.credentials.PasswordCredential
9
9
  import androidx.credentials.PublicKeyCredential
10
10
  import com.facebook.react.bridge.Arguments
11
11
  import com.facebook.react.bridge.WritableMap
12
+ import com.google.android.gms.auth.api.identity.AuthorizationResult
12
13
  import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential
13
14
 
14
15
  object CredentialFactory {
@@ -19,7 +20,8 @@ object CredentialFactory {
19
20
  APPLE_ID("APPLE_ID"),
20
21
  WEB_APPLE_ID("WEB_APPLE_ID"),
21
22
  CANCELLED("CANCELLED"),
22
- PASSKEY("PASSKEY")
23
+ PASSKEY("PASSKEY"),
24
+ REDIRECT("REDIRECT")
23
25
  }
24
26
 
25
27
 
@@ -48,7 +50,10 @@ object CredentialFactory {
48
50
  /**
49
51
  * Creates from a response.
50
52
  */
51
- fun fromCredentialResponse(result: GetCredentialResponse): WritableMap {
53
+ fun fromCredentialResponse(
54
+ result: GetCredentialResponse,
55
+ authorization: AuthorizationResult? = null
56
+ ): WritableMap {
52
57
  return Arguments.createMap().apply {
53
58
  val data = Arguments.createMap()
54
59
  when (val credential = result.credential) {
@@ -73,7 +78,15 @@ object CredentialFactory {
73
78
  data.putString("familyName", googleCred.familyName)
74
79
  data.putString("profilePictureUri", googleCred.profilePictureUri?.toString())
75
80
  data.putString("phoneNumber", googleCred.phoneNumber)
81
+ data.putString("email", googleCred.id)
76
82
  data.putBoolean("legacy", false)
83
+ data.putString("accessToken", authorization?.accessToken)
84
+ data.putString("serverAuthCode", authorization?.serverAuthCode)
85
+ if (authorization != null) {
86
+ data.putArray("grantedScopes", Arguments.fromList(authorization.grantedScopes))
87
+ } else {
88
+ data.putNull("grantedScopes")
89
+ }
77
90
  }
78
91
 
79
92
  else -> {
@@ -89,6 +102,15 @@ object CredentialFactory {
89
102
  }
90
103
  }
91
104
 
105
+ fun fromRedirect(url: String): WritableMap {
106
+ return Arguments.createMap().apply {
107
+ putString("type", CredentialsType.REDIRECT.code)
108
+ putMap("data", Arguments.createMap().apply {
109
+ putString("url", url)
110
+ })
111
+ }
112
+ }
113
+
92
114
  fun fromCancelled(): WritableMap {
93
115
  return Arguments.createMap().apply {
94
116
  putString("type", CredentialsType.CANCELLED.code)
@@ -1,6 +1,7 @@
1
1
  package com.oauthessentials
2
2
 
3
3
  import android.app.Activity
4
+ import android.content.ActivityNotFoundException
4
5
  import android.content.Intent
5
6
  import android.content.Intent.FLAG_ACTIVITY_NO_HISTORY
6
7
  import android.os.Bundle
@@ -10,6 +11,7 @@ import com.oauthessentials.OauthEssentialsModule.Companion.DISPLAY_CUSTOM_TABS_I
10
11
  import com.oauthessentials.OauthEssentialsModule.Companion.LOG_TAG
11
12
  import com.oauthessentials.OauthEssentialsModule.Companion.WEB_APPLE_DEEP_LINK_RECEIVED_INTENT
12
13
  import com.oauthessentials.OauthEssentialsModule.Companion.WEB_APPLE_CANCELLED_INTENT
14
+ import com.oauthessentials.OauthEssentialsModule.Companion.WEB_BROWSER_UNAVAILABLE_INTENT
13
15
 
14
16
  class CustomTabsActivity : Activity() {
15
17
  private var deepLinkReceived = false
@@ -108,7 +110,18 @@ class CustomTabsActivity : Activity() {
108
110
  val tabIntent =
109
111
  CustomTabsIntent.Builder().setShowTitle(true).setUrlBarHidingEnabled(true).build()
110
112
  tabIntent.intent.addFlags(FLAG_ACTIVITY_NO_HISTORY)
111
- tabIntent.launchUrl(this, uri)
113
+ try {
114
+ tabIntent.launchUrl(this, uri)
115
+ } catch (e: ActivityNotFoundException) {
116
+ Log.e(LOG_TAG, "No browser available to open $uri")
117
+ resultProcessed = true
118
+ sendBroadcast(
119
+ Intent(WEB_BROWSER_UNAVAILABLE_INTENT).apply {
120
+ setPackage(applicationContext.packageName)
121
+ }
122
+ )
123
+ finish()
124
+ }
112
125
  }
113
126
  }
114
127