Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ object WalletIntentProcessor {
val intentAction = intent.action
val packageName = intent.`package`
val callingPackage = activity.callingPackage
val extraText = intent.getStringExtra(Intent.EXTRA_TEXT)

WalletLogger.d(TAG, "🔍 [CENTRAL] Processando intent - Action: $intentAction, Package: $packageName, CallingPackage: $callingPackage")
WalletLogger.d(TAG, "🔍 [CENTRAL] EXTRA_TEXT: ${if (extraText.isNullOrEmpty()) "vazio/null" else "${extraText.length} caracteres - ${extraText.take(100)}${if (extraText.length > 100) "..." else ""}"}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

A expressão para formatar a mensagem de log é um pouco complexa. Usar o safe call operator (?.let) com o elvis operator (?:) pode tornar o código mais idiomático e um pouco mais legível, evitando o if/else aninhado dentro da string template.

Suggested change
WalletLogger.d(TAG, "🔍 [CENTRAL] EXTRA_TEXT: ${if (extraText.isNullOrEmpty()) "vazio/null" else "${extraText.length} caracteres - ${extraText.take(100)}${if (extraText.length > 100) "..." else ""}"}")
WalletLogger.d(TAG, "🔍 [CENTRAL] EXTRA_TEXT: ${extraText?.let { "${it.length} caracteres - ${it.take(100)}${if (it.length > 100) "..." else ""}" } ?: "vazio/null"}")

WalletLogger.d(TAG, "🔍 [CENTRAL] Extras: ${intent.extras}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Fazer o log do objeto intent.extras completo pode expor informações sensíveis (PII) nos logs, o que representa um risco de segurança, especialmente em uma aplicação de carteira digital. É recomendado fazer o log apenas de chaves específicas e conhecidas que não contenham dados sensíveis, ou remover completamente este log se não for estritamente necessário para depuração.


// Verificar se há extras na intent (usando safe call operator, mais idiomático em Kotlin)
val hasExtras = intent.extras?.isEmpty() == false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.Callback
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.builders.wallet.samsungpay.util.PartnerInfoHolder
import com.builders.wallet.samsungpay.util.ErrorCode
Expand Down Expand Up @@ -185,8 +186,14 @@ class SamsungWalletImplementation(private val reactContext: ReactApplicationCont
val listener = object : GetCardListener {
override fun onSuccess(cardList: List<Card>) {
WalletLogger.d(TAG, "onSuccess callback is called, list.size= ${cardList.size}")
val result = cardList.map { it.toSerializable() }
WalletLogger.i(TAG, "- cards - $result")

// Converter lista de WritableMap para WritableArray (React Native requer WritableArray para arrays)
val result: WritableArray = Arguments.createArray()
cardList.forEach { card ->
result.pushMap(card.toSerializable())
}
Comment on lines +191 to +194

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

A conversão da lista de cartões para WritableArray está correta. É possível tornar este bloco de código mais conciso.

        val result = Arguments.createArray()
        cardList.forEach { result.pushMap(it.toSerializable()) }


WalletLogger.i(TAG, "- cards - ${cardList.size} cards retornados")
promise.resolve(result)
}

Expand Down
5 changes: 5 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
android:allowBackup="false"
android:theme="@style/AppTheme"
android:supportsRtl="true">

<meta-data
android:name="spay_sdk_api_level"
android:value="2.22" />

<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down