react-native-oauth-essentials 1.0.9 → 1.0.10
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.
|
@@ -144,7 +144,9 @@ class OauthEssentialsModule(reactContext: ReactApplicationContext) :
|
|
|
144
144
|
try {
|
|
145
145
|
val manager = CredentialManager.create(activity)
|
|
146
146
|
val randomBytes = ByteArray(32)
|
|
147
|
-
SecureRandom
|
|
147
|
+
// Usa SecureRandom() (não-bloqueante) em vez de getInstanceStrong(),
|
|
148
|
+
// que pode bloquear esperando entropia (/dev/random) e pendurar o fluxo.
|
|
149
|
+
SecureRandom().nextBytes(randomBytes)
|
|
148
150
|
val randomNonce = Base64.getUrlEncoder().withoutPadding().encodeToString(randomBytes)
|
|
149
151
|
|
|
150
152
|
val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
|
|
@@ -159,13 +161,17 @@ class OauthEssentialsModule(reactContext: ReactApplicationContext) :
|
|
|
159
161
|
.addCredentialOption(GetPasswordOption())
|
|
160
162
|
.build()
|
|
161
163
|
|
|
164
|
+
// getCredential precisa lançar a Activity de UI (chooser), então deve
|
|
165
|
+
// rodar na Main thread — igual ao googleSignIn. Chamar em Dispatchers.IO
|
|
166
|
+
// fazia o chooser abrir sem se vincular à UI e travar (ANR na abertura).
|
|
167
|
+
val result = withContext(Dispatchers.Main) {
|
|
168
|
+
manager.getCredential(
|
|
169
|
+
request = request,
|
|
170
|
+
context = activity
|
|
171
|
+
)
|
|
172
|
+
}
|
|
162
173
|
resolveAndEmit(
|
|
163
|
-
CredentialFactory.fromCredentialResponse(
|
|
164
|
-
manager.getCredential(
|
|
165
|
-
request = request,
|
|
166
|
-
context = activity
|
|
167
|
-
)
|
|
168
|
-
), promise
|
|
174
|
+
CredentialFactory.fromCredentialResponse(result), promise
|
|
169
175
|
)
|
|
170
176
|
} catch (e: GetCredentialCancellationException) {
|
|
171
177
|
Log.d(LOG_TAG, e.toString())
|
|
@@ -301,13 +307,15 @@ class OauthEssentialsModule(reactContext: ReactApplicationContext) :
|
|
|
301
307
|
listOf(GetPasswordOption())
|
|
302
308
|
)
|
|
303
309
|
|
|
310
|
+
// getCredential lança UI: deve rodar na Main thread (ver hybridSignIn).
|
|
311
|
+
val result = withContext(Dispatchers.Main) {
|
|
312
|
+
manager.getCredential(
|
|
313
|
+
request = request,
|
|
314
|
+
context = activity
|
|
315
|
+
)
|
|
316
|
+
}
|
|
304
317
|
resolveAndEmit(
|
|
305
|
-
CredentialFactory.fromCredentialResponse(
|
|
306
|
-
manager.getCredential(
|
|
307
|
-
request = request,
|
|
308
|
-
context = activity
|
|
309
|
-
)
|
|
310
|
-
), promise
|
|
318
|
+
CredentialFactory.fromCredentialResponse(result), promise
|
|
311
319
|
)
|
|
312
320
|
} catch (e: Throwable) {
|
|
313
321
|
Log.d(LOG_TAG, e.toString())
|
|
@@ -343,10 +351,13 @@ class OauthEssentialsModule(reactContext: ReactApplicationContext) :
|
|
|
343
351
|
password = password
|
|
344
352
|
)
|
|
345
353
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
354
|
+
// createCredential lança UI: deve rodar na Main thread (ver hybridSignIn).
|
|
355
|
+
withContext(Dispatchers.Main) {
|
|
356
|
+
manager.createCredential(
|
|
357
|
+
request = request,
|
|
358
|
+
context = activity
|
|
359
|
+
)
|
|
360
|
+
}
|
|
350
361
|
promise.resolve(true)
|
|
351
362
|
} catch (e: Throwable) {
|
|
352
363
|
Log.e(LOG_TAG, e.toString())
|
|
@@ -395,10 +406,13 @@ class OauthEssentialsModule(reactContext: ReactApplicationContext) :
|
|
|
395
406
|
preferImmediatelyAvailableCredentials = preferImmediatelyAvailableCredentials,
|
|
396
407
|
isConditional = isConditional
|
|
397
408
|
)
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
409
|
+
// createCredential lança UI: deve rodar na Main thread (ver hybridSignIn).
|
|
410
|
+
val result = withContext(Dispatchers.Main) {
|
|
411
|
+
manager.createCredential(
|
|
412
|
+
request = request,
|
|
413
|
+
context = activity
|
|
414
|
+
)
|
|
415
|
+
}
|
|
402
416
|
resolveAndEmit(CredentialFactory.fromPublicKeyCredential(result), promise)
|
|
403
417
|
} catch (e: Throwable) {
|
|
404
418
|
when (e) {
|
|
@@ -454,10 +468,13 @@ class OauthEssentialsModule(reactContext: ReactApplicationContext) :
|
|
|
454
468
|
),
|
|
455
469
|
preferImmediatelyAvailableCredentials = preferImmediatelyAvailableCredentials
|
|
456
470
|
)
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
471
|
+
// getCredential lança UI: deve rodar na Main thread (ver hybridSignIn).
|
|
472
|
+
val result = withContext(Dispatchers.Main) {
|
|
473
|
+
manager.getCredential(
|
|
474
|
+
request = request,
|
|
475
|
+
context = activity
|
|
476
|
+
)
|
|
477
|
+
}
|
|
461
478
|
resolveAndEmit(CredentialFactory.fromPublicKeyCredential(result), promise)
|
|
462
479
|
} catch (e: Throwable) {
|
|
463
480
|
when (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-oauth-essentials",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Essential Auth tools for every app.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -49,14 +49,31 @@
|
|
|
49
49
|
"react-native",
|
|
50
50
|
"ios",
|
|
51
51
|
"android",
|
|
52
|
+
"expo",
|
|
52
53
|
"oauth",
|
|
54
|
+
"oauth2",
|
|
53
55
|
"auth",
|
|
56
|
+
"authentication",
|
|
57
|
+
"authorization",
|
|
58
|
+
"login",
|
|
54
59
|
"sign-in",
|
|
55
60
|
"sign",
|
|
61
|
+
"social-login",
|
|
62
|
+
"passwordless",
|
|
63
|
+
"passkey",
|
|
56
64
|
"passkeys",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"credentials"
|
|
65
|
+
"webauthn",
|
|
66
|
+
"fido2",
|
|
67
|
+
"credentials",
|
|
68
|
+
"credential-manager",
|
|
69
|
+
"apple-sign-in",
|
|
70
|
+
"sign-in-with-apple",
|
|
71
|
+
"google-sign-in",
|
|
72
|
+
"openid",
|
|
73
|
+
"openid-connect",
|
|
74
|
+
"biometric",
|
|
75
|
+
"mobile",
|
|
76
|
+
"web"
|
|
60
77
|
],
|
|
61
78
|
"repository": {
|
|
62
79
|
"type": "git",
|