Updated on 2026-08-14

This commit is contained in:
Tangem 2024-12-23 14:19:34 +04:00
parent 00e275b605
commit 352043ab4f
5 changed files with 90 additions and 1 deletions

View file

@ -0,0 +1,12 @@
package com.tangem.common.module
/**
[REDACTED_AUTHOR]
*/
@Deprecated("Will be removed")
object ModuleErrorCode {
const val APP = 100000
const val DOMAIN = 30000
const val ONBOARDING = 50000
}

View file

@ -0,0 +1,25 @@
package com.tangem.common.module
/**
[REDACTED_AUTHOR]
* The base object for communication between modules
*/
@Deprecated("Will be removed")
interface ModuleMessage
/**
* @property code describes what feature is the error coming from
* @property message the error description
* @property data any data that can help in the part where this error is being handled
*/
@Deprecated("Will be removed")
abstract class ModuleError : Throwable(), ModuleMessage {
abstract val code: Int
abstract override val message: String
abstract val data: Any?
}
@Deprecated("Will be removed")
interface ModuleMessageConverter<ModuleMessage, R> {
fun convert(message: ModuleMessage): R
}

View file

@ -0,0 +1,31 @@
package com.tangem.common.uri
import com.google.firebase.crashlytics.FirebaseCrashlytics
import timber.log.Timber
import java.net.URI
/**
* External url validator
*
[REDACTED_AUTHOR]
*/
object ExternalUrlValidator {
private val trustedHost: List<String> = listOf("tangem.com")
/** Check if [externalUri] is trusted */
fun isUriTrusted(externalUri: String): Boolean {
return try {
val uri = URI.create(externalUri)
uri.scheme == "https" && uri.host in trustedHost
} catch (e: Exception) {
val exception = IllegalStateException("Failed to validate URI: $externalUri", e)
Timber.e(exception)
FirebaseCrashlytics.getInstance().recordException(exception)
false
}
}
}