Move symbol derivative to vParamsRaw

This commit is contained in:
Mikołaj Pich 2024-05-22 20:10:26 +02:00
parent b8ff96f5fd
commit 09f9a39550
No known key found for this signature in database
4 changed files with 16 additions and 26 deletions

View file

@ -92,9 +92,9 @@ public final class io/github/wulkanowy/sdk/scrapper/Scrapper {
public final fun getUserAgent ()Ljava/lang/String;
public final fun getUserAgentTemplate ()Ljava/lang/String;
public final fun getUserSubjects (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getVHeaders ()Ljava/util/Map;
public final fun getVParamsEvaluation ()Lkotlin/jvm/functions/Function1;
public final fun getVTokenMapping ()Ljava/util/Map;
public final fun getVTokenSchemeMapping ()Ljava/util/Map;
public final fun isEduOne ()Z
public final fun isSymbolNotExist (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun restoreMessages (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -123,9 +123,9 @@ public final class io/github/wulkanowy/sdk/scrapper/Scrapper {
public final fun setSymbol (Ljava/lang/String;)V
public final fun setUnitId (I)V
public final fun setUserAgentTemplate (Ljava/lang/String;)V
public final fun setVHeaders (Ljava/util/Map;)V
public final fun setVParamsEvaluation (Lkotlin/jvm/functions/Function1;)V
public final fun setVTokenMapping (Ljava/util/Map;)V
public final fun setVTokenSchemeMapping (Ljava/util/Map;)V
public final fun unregisterDevice (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

View file

@ -93,10 +93,9 @@ internal fun getApiKey(document: Document, fallback: String = ""): String {
}
}
internal fun getScriptFlag(name: String, content: String, fallback: Boolean = false): Boolean {
return "$name: (false|true)".toRegex().find(content).let { result ->
if (null !== result) result.groupValues[1].toBoolean() else fallback
}
private fun getSymbolSig(symbol: String): String {
if (symbol.isBlank()) return ""
return "${symbol.first()}${symbol.length}"
}
fun String.getNormalizedSymbol(): String = this
@ -301,7 +300,10 @@ internal suspend fun getModuleHeadersFromDocument(document: Document): ModuleHea
} else {
null to null
}
} + mapOf("apiKey" to getApiKey(document)),
} + mapOf(
"apiKey" to getApiKey(document),
"appCustomerDbSig" to getSymbolSig(getScriptParam("appCustomerDb", htmlContent)),
),
vParamsEvaluated = evaluatedJs,
)
}
@ -315,9 +317,10 @@ internal fun getVHeaders(moduleHost: String, url: HttpUrl, headers: ModuleHeader
domainSchema = scheme,
headers = headers,
)
if (headerValue != null) {
key to headerValue
} else null
when {
headerValue != null -> key to headerValue
else -> null
}
}.toMap()
}
@ -359,17 +362,5 @@ private fun getVToken(uuid: String, headers: ModuleHeaders?, domainSchema: Strin
.replace("{email}", headers?.email.orEmpty()),
)
val symbolSig = getSymbolSig(headers?.vParamsEvaluated.orEmpty()["appCustomerDb"] ?: headers?.symbol.orEmpty())
val vToken = vTokenEncoded
.replace("{UUID}", uuid)
.replace("{appCustomerDbSig}", symbolSig)
val vTokenMd5 = vToken.md5()
return vTokenMd5
}
private fun getSymbolSig(symbol: String): String {
return "${symbol.first()}${symbol.length}"
return vTokenEncoded.replace("{UUID}", uuid).md5()
}

View file

@ -25,7 +25,6 @@ import io.github.wulkanowy.sdk.scrapper.timetable.TimetablePlusHeader
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.HeaderMap
import retrofit2.http.POST
import retrofit2.http.Query

View file

@ -90,9 +90,9 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun getUserSubjectsFromScrapper (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getUserSubjectsFromScrapper (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun getUserSubjectsFromScrapper$default (Lio/github/wulkanowy/sdk/Sdk;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun getVHeaders ()Ljava/util/Map;
public final fun getVParamsEvaluation ()Lkotlin/jvm/functions/Function1;
public final fun getVTokenMapping ()Ljava/util/Map;
public final fun getVTokenSchemeMapping ()Ljava/util/Map;
public final fun isEduOne ()Z
public final fun isSymbolNotExist (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun restoreMessages (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -124,9 +124,9 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun setSymbol (Ljava/lang/String;)V
public final fun setUnitId (I)V
public final fun setUserAgentTemplate (Ljava/lang/String;)V
public final fun setVHeaders (Ljava/util/Map;)V
public final fun setVParamsEvaluation (Lkotlin/jvm/functions/Function1;)V
public final fun setVTokenMapping (Ljava/util/Map;)V
public final fun setVTokenSchemeMapping (Ljava/util/Map;)V
public final fun switchDiary (III)Lio/github/wulkanowy/sdk/Sdk;
public final fun switchDiary (IIII)Lio/github/wulkanowy/sdk/Sdk;
public static synthetic fun switchDiary$default (Lio/github/wulkanowy/sdk/Sdk;IIIIILjava/lang/Object;)Lio/github/wulkanowy/sdk/Sdk;