@@ -11,24 +11,19 @@ import com.auth0.android.authentication.AuthenticationAPIClient
1111import com.auth0.android.authentication.AuthenticationException
1212import com.auth0.android.callback.Callback
1313import com.auth0.android.request.internal.GsonProvider
14- import com.auth0.android.request.internal.Jwt
1514import com.auth0.android.result.APICredentials
1615import com.auth0.android.result.Credentials
1716import com.auth0.android.result.OptionalCredentials
1817import com.auth0.android.result.SSOCredentials
1918import com.auth0.android.result.UserProfile
2019import com.auth0.android.result.toAPICredentials
2120import com.google.gson.Gson
22- import kotlinx.coroutines.CoroutineScope
23- import kotlinx.coroutines.GlobalScope
24- import kotlinx.coroutines.launch
2521import kotlinx.coroutines.suspendCancellableCoroutine
2622import java.lang.ref.WeakReference
27- import java.util.*
23+ import java.util.Date
24+ import java.util.Locale
2825import java.util.concurrent.Executor
2926import java.util.concurrent.atomic.AtomicLong
30- import kotlin.collections.component1
31- import kotlin.collections.component2
3227import kotlin.coroutines.resume
3328import kotlin.coroutines.resumeWithException
3429
@@ -65,6 +60,34 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
6560 storage: Storage ,
6661 ) : this (
6762 AuthenticationAPIClient (auth0),
63+ context,
64+ auth0,
65+ storage
66+ )
67+
68+ /* *
69+ * Creates a new SecureCredentialsManager to handle Credentials with a custom AuthenticationAPIClient instance.
70+ * Use this constructor when you need to configure the API client with advanced features like DPoP.
71+ *
72+ * Example usage:
73+ * ```
74+ * val auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN")
75+ * val apiClient = AuthenticationAPIClient(auth0).useDPoP(context)
76+ * val manager = SecureCredentialsManager(apiClient, context, auth0, storage)
77+ * ```
78+ *
79+ * @param apiClient a configured AuthenticationAPIClient instance
80+ * @param context a valid context
81+ * @param auth0 the Auth0 account information to use
82+ * @param storage the storage implementation to use
83+ */
84+ public constructor (
85+ apiClient: AuthenticationAPIClient ,
86+ context: Context ,
87+ auth0: Auth0 ,
88+ storage: Storage
89+ ) : this (
90+ apiClient,
6891 storage,
6992 CryptoUtil (context, storage, KEY_ALIAS ),
7093 JWTDecoder (),
@@ -89,6 +112,50 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
89112 localAuthenticationOptions: LocalAuthenticationOptions
90113 ) : this (
91114 AuthenticationAPIClient (auth0),
115+ context,
116+ auth0,
117+ storage,
118+ fragmentActivity,
119+ localAuthenticationOptions
120+ )
121+
122+
123+ /* *
124+ * Creates a new SecureCredentialsManager to handle Credentials with biometrics Authentication
125+ * and a custom AuthenticationAPIClient instance.
126+ * Use this constructor when you need to configure the API client with advanced features like DPoP
127+ * along with biometric authentication.
128+ *
129+ * Example usage:
130+ * ```
131+ * val auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN")
132+ * val apiClient = AuthenticationAPIClient(auth0).useDPoP(context)
133+ * val manager = SecureCredentialsManager(
134+ * apiClient,
135+ * context,
136+ * auth0,
137+ * storage,
138+ * fragmentActivity,
139+ * localAuthenticationOptions
140+ * )
141+ * ```
142+ *
143+ * @param apiClient a configured AuthenticationAPIClient instance
144+ * @param context a valid context
145+ * @param auth0 the Auth0 account information to use
146+ * @param storage the storage implementation to use
147+ * @param fragmentActivity the FragmentActivity to use for the biometric authentication
148+ * @param localAuthenticationOptions the options of type [LocalAuthenticationOptions] to use for the biometric authentication
149+ */
150+ public constructor (
151+ apiClient: AuthenticationAPIClient ,
152+ context: Context ,
153+ auth0: Auth0 ,
154+ storage: Storage ,
155+ fragmentActivity: FragmentActivity ,
156+ localAuthenticationOptions: LocalAuthenticationOptions
157+ ) : this (
158+ apiClient,
92159 storage,
93160 CryptoUtil (context, storage, KEY_ALIAS ),
94161 JWTDecoder (),
@@ -270,7 +337,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
270337 if (credentials == null ) {
271338 return null
272339 }
273- return credentials.user
340+ return credentials.user
274341 }
275342
276343 /* *
@@ -1138,7 +1205,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
11381205 internal fun isBiometricSessionValid (): Boolean {
11391206 val lastAuth = lastBiometricAuthTime.get()
11401207 if (lastAuth == NO_SESSION ) return false // No session exists
1141-
1208+
11421209 return when (val policy = biometricPolicy) {
11431210 is BiometricPolicy .Session ,
11441211 is BiometricPolicy .AppLifecycle -> {
@@ -1149,6 +1216,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
11491216 } * 1000L
11501217 System .currentTimeMillis() - lastAuth < timeoutMillis
11511218 }
1219+
11521220 is BiometricPolicy .Always -> false
11531221 }
11541222 }
0 commit comments