Skip to content

Commit b7322ab

Browse files
chore: remove logs in android kotlin code
1 parent f2a8146 commit b7322ab

File tree

2 files changed

+2
-49
lines changed

2 files changed

+2
-49
lines changed

android/src/main/java/com/margelo/nitro/secureenclaveoperations/SecureEnclaveOperations.kt

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
3232

3333
// Initialize Nitro native code loader
3434
init {
35-
Log.d(logTag, "Initializing SecureEnclaveOperations")
3635
secureenclaveoperationsOnLoad.initializeNative()
3736
}
3837

@@ -54,8 +53,6 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
5453
override fun prepareIntegrityTokenAndroid(cloudProjectNumber: String): Promise<Boolean> {
5554
return Promise.async {
5655
try {
57-
Log.d(logTag, "Preparing integrity token with cloud project number: $cloudProjectNumber")
58-
5956
// Convert string to long
6057
val cpn = cloudProjectNumber.toLong()
6158

@@ -76,12 +73,10 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
7673
standardIntegrityManager.prepareIntegrityToken(prepareRequest)
7774
.addOnSuccessListener { provider ->
7875
integrityTokenProvider = provider
79-
Log.d(logTag, "Integrity token provider prepared successfully")
8076
result = true
8177
isComplete = true
8278
}
8379
.addOnFailureListener { ex ->
84-
Log.e(logTag, "Failed to prepare integrity token", ex)
8580
throw RuntimeException("Failed to prepare integrity token: ${ex.message}", ex)
8681
}
8782

@@ -92,10 +87,8 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
9287

9388
return@async result
9489
} catch (e: NumberFormatException) {
95-
Log.e(logTag, "Invalid cloud project number format", e)
9690
throw RuntimeException("Invalid cloud project number format", e)
9791
} catch (e: Exception) {
98-
Log.e(logTag, "Error preparing integrity token", e)
9992
throw RuntimeException("Error preparing integrity token: ${e.message}", e)
10093
}
10194
}
@@ -105,12 +98,9 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
10598
return Promise.async {
10699
try {
107100
if (integrityTokenProvider == null) {
108-
Log.e(logTag, "Integrity token provider not initialized")
109101
throw RuntimeException("Integrity token provider not initialized")
110102
}
111103

112-
Log.d(logTag, "Requesting integrity token with hash: $requestHash")
113-
114104
val request = StandardIntegrityManager.StandardIntegrityTokenRequest.builder()
115105
.setRequestHash(requestHash)
116106
.build()
@@ -120,12 +110,10 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
120110

121111
integrityTokenProvider?.request(request)
122112
?.addOnSuccessListener { response ->
123-
Log.d(logTag, "Integrity token received successfully")
124113
token = response.token()
125114
isComplete = true
126115
}
127116
?.addOnFailureListener { ex ->
128-
Log.e(logTag, "Failed to get integrity token", ex)
129117
throw RuntimeException("Failed to get integrity token: ${ex.message}", ex)
130118
}
131119

@@ -137,13 +125,11 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
137125
attempts++
138126
}
139127
if (!isComplete) {
140-
Log.e(logTag, "Timeout while waiting for integrity token")
141128
throw RuntimeException("Timeout while waiting for integrity token")
142129
}
143130

144131
return@async token
145132
} catch (e: Exception) {
146-
Log.e(logTag, "Error requesting integrity token", e)
147133
throw RuntimeException("Error requesting integrity token: ${e.message}", e)
148134
}
149135
}
@@ -198,7 +184,6 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
198184
val concatenatedAttestations = attestations.joinToString("|")
199185
return@async Base64.encodeToString(concatenatedAttestations.toByteArray(), Base64.NO_WRAP)
200186
} catch (e: Exception) {
201-
Log.e(logTag, "Error attesting key", e)
202187
throw RuntimeException("Error attesting key: ${e.message}", e)
203188
}
204189
}
@@ -227,13 +212,11 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
227212
return Promise.async {
228213
try {
229214
// Generate a unique key ID
230-
Log.d(logTag, "Generating key with ID: $keyId")
231215
val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }
232216

233217

234218
// Create a key pair generator for EC keys
235219
val keyPairGenerator = KeyPairGenerator.getInstance("EC", "AndroidKeyStore")
236-
Log.d(logTag, "Created key pair generator for EC/AndroidKeyStore")
237220

238221
// Configure the key pair generator with hardware-backed security
239222
val parameterSpec =
@@ -257,29 +240,22 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
257240

258241
if (securityLevel == PackageManager.FEATURE_STRONGBOX_KEYSTORE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
259242
parameterSpec.setIsStrongBoxBacked(true)
260-
Log.d(logTag, "KeyGenParameterSpec backed by hardware strongbox")
261243
}
262244

263245
val buildSpec = parameterSpec.build()
264246

265-
Log.d(logTag, "KeyGenParameterSpec built")
266-
267247
// Generate the key pair with EC algorithm
268248
keyPairGenerator.initialize(buildSpec)
269249
keyPairGenerator.generateKeyPair()
270-
Log.d(logTag, "Key pair generated")
271250

272251
val entry = keyStore.getEntry(keyId, null) as? KeyStore.PrivateKeyEntry
273252
if (entry == null) {
274-
Log.e(logTag, "Failed to retrieve key entry from KeyStore")
275253
throw RuntimeException("Failed to generate key")
276254
}
277-
Log.d(logTag, "Key successfully verified in KeyStore")
278255

279256
// Return the key ID to be used for future operations
280257
return@async keyId
281258
} catch (e: Exception) {
282-
Log.e(logTag, "Error generating key", e)
283259
throw RuntimeException("Error generating key: ${e.message}", e)
284260
}
285261
}
@@ -288,21 +264,17 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
288264
private fun isHardwareBackedKeyGenerationSupported(): Promise<Boolean> {
289265
return Promise.async {
290266
try {
291-
Log.d(logTag, "Checking if attestation is supported")
292-
293267
// Get application context from NitroModules
294268
val context = NitroModules.applicationContext ?: reactContext
295269

296270
val isStrongBoxSupported =
297271
context.packageManager.hasSystemFeature(
298272
"android.hardware.strongbox_keystore"
299273
)
300-
Log.d(logTag, "StrongBox support: $isStrongBoxSupported")
301274

302275
// We'll just check hardware features for now, without requiring Play Services
303276
return@async isStrongBoxSupported
304277
} catch (e: Exception) {
305-
Log.e(logTag, "Error checking attestation support", e)
306278
return@async false
307279
}
308280
}
@@ -311,17 +283,14 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
311283
// Helper method to check if a key is hardware-backed
312284
private fun isHardwareBacked(keyId: String): Boolean {
313285
try {
314-
Log.d(logTag, "Checking if key is hardware-backed: $keyId")
315286
val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }
316287
val entry = keyStore.getEntry(keyId, null) as? KeyStore.PrivateKeyEntry
317288
if (entry != null) {
318289
val privateKey = entry.privateKey
319290
val isHardwareBacked = privateKey.toString().contains("AndroidKeyStore")
320-
Log.d(logTag, "Key hardware backing check result: $isHardwareBacked")
321291
return isHardwareBacked
322292
}
323293
} catch (e: Exception) {
324-
Log.e(logTag, "Error checking if key is hardware-backed", e)
325294
}
326295
Log.w(logTag, "Could not determine if key is hardware-backed, assuming false")
327296
return false
@@ -330,7 +299,6 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
330299
// Check weather the device has biometric enabled
331300
private fun isBiometricEnabled(): Boolean {
332301
return try {
333-
Log.d(logTag, "Checking if biometrics are enabled")
334302
// Get application context from NitroModules
335303
val context = NitroModules.applicationContext ?: reactContext
336304

@@ -339,29 +307,24 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
339307
if (packageManager.hasSystemFeature(PackageManager.FEATURE_FACE) ||
340308
packageManager.hasSystemFeature(PackageManager.FEATURE_IRIS)
341309
) {
342-
Log.d(logTag, "Face or iris recognition hardware is available")
343310
return true
344311
}
345312
}
346313

347314
val packageManager = context.packageManager
348315
if (packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
349-
Log.d(logTag, "Fingerprint hardware is available")
350316
return true
351317
}
352318

353-
Log.d(logTag, "No biometric hardware features detected")
354319
false
355320
} catch (e: Exception) {
356-
Log.e(logTag, "Error checking biometric availability", e)
357321
false
358322
}
359323
}
360324

361325
// Check if user has set up biometrics on the device
362326
private fun isBiometricEnrolled(): Boolean {
363327
return try {
364-
Log.d(logTag, "Checking if biometrics are enrolled")
365328
val context = NitroModules.applicationContext ?: reactContext
366329

367330
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
@@ -372,48 +335,38 @@ class SecureEnclaveOperations(private val reactContext: ReactApplicationContext)
372335
biometricManager?.canAuthenticate(android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_STRONG)
373336

374337
if (canAuthenticate == android.hardware.biometrics.BiometricManager.BIOMETRIC_SUCCESS) {
375-
Log.d(logTag, "Biometrics are enrolled and available")
376338
return true
377339
}
378-
Log.d(logTag, "Biometric status code: $canAuthenticate")
379340
} else {
380341
// For Android M (API 23) to P (API 28), check keyguard secure
381342
val keyguardManager =
382343
context.getSystemService(android.content.Context.KEYGUARD_SERVICE) as android.app.KeyguardManager
383344
if (keyguardManager.isKeyguardSecure) {
384345
// If keyguard is secure, biometric or pin/pattern is set up
385-
Log.d(logTag, "Device is secured with PIN/pattern/biometric")
386346
return true
387347
}
388348
}
389349

390-
Log.d(logTag, "No enrolled biometrics detected")
391350
false
392351
} catch (e: Exception) {
393-
Log.e(logTag, "Error checking biometric enrollment", e)
394352
false
395353
}
396354
}
397355

398356
// Helper method to get the security level
399357
private fun getSecurityLevel(): String {
400358
return try {
401-
Log.d(logTag, "Getting security level")
402359
// Get application context from NitroModules
403360
val context = NitroModules.applicationContext ?: reactContext
404361

405362
if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
406-
Log.d(logTag, "StrongBox is available")
407363
PackageManager.FEATURE_STRONGBOX_KEYSTORE
408364
} else if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_HARDWARE_KEYSTORE) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
409-
Log.d(logTag, "TEE is available")
410365
PackageManager.FEATURE_HARDWARE_KEYSTORE
411366
} else {
412-
Log.d(logTag, "No hardware security features detected")
413367
"Software"
414368
}
415369
} catch (e: Exception) {
416-
Log.e(logTag, "Error determining security level", e)
417370
"Unknown"
418371
}
419372
}

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ PODS:
15481548
- React-logger (= 0.78.0)
15491549
- React-perflogger (= 0.78.0)
15501550
- React-utils (= 0.78.0)
1551-
- SecureEnclaveOperations (0.1.0):
1551+
- SecureEnclaveOperations (0.0.3):
15521552
- DoubleConversion
15531553
- glog
15541554
- hermes-engine
@@ -1855,7 +1855,7 @@ SPEC CHECKSUMS:
18551855
ReactAppDependencyProvider: f2e81d80afd71a8058589e19d8a134243fa53f17
18561856
ReactCodegen: a63a0ab6ae824aef2e8c744981edd718b16eb9f2
18571857
ReactCommon: 3d39389f8e2a2157d5c999f8fba57bd1c8f226f0
1858-
SecureEnclaveOperations: f8e29cc329af5847c42ad2a84afe444d5a2a9cb2
1858+
SecureEnclaveOperations: f77a72c13ba5aacab088861f3d6fb7c7a633bf51
18591859
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
18601860
Yoga: afd04ff05ebe0121a00c468a8a3c8080221cb14c
18611861

0 commit comments

Comments
 (0)