Fix GreenShit: remove unnecessary x-client-hash and simplify authentication (#11408)
* corrige autenticação da extensão greenshit removendo x-client-hash desnecessário - Remove função generateToken() que gerava hash HMAC para o header x-client-hash - API funciona apenas com token Bearer, x-client-hash não é necessário - Remove imports não utilizados (Base64, Mac, SecretKeySpec) - Remove constante SECRET_KEY - Adiciona campo path ao PageDto para corresponder à resposta da API - Simplifica pageListRequestMobile para usar apenas header de autorização - Funcionalidade de login do usuário permanece intacta e automática * atualiza versionCode da extensão sussyscan e multisrc greenshit - Incrementa overrideVersionCode de 56 para 57 (sussyscan) - Incrementa versionId de 2 para 3 (SussyToons.kt) - Incrementa baseVersionCode de 5 para 6 (greenshit multisrc) * Reverter versionId * Remove variave nao utilizada * Reverte a versaoCode * remover espaços
This commit is contained in:
parent
84383a1601
commit
9f7b11fc57
@ -2,4 +2,4 @@ plugins {
|
||||
id("lib-multisrc")
|
||||
}
|
||||
|
||||
baseVersionCode = 5
|
||||
baseVersionCode = 6
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package eu.kanade.tachiyomi.multisrc.greenshit
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Base64
|
||||
import android.widget.Toast
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
@ -31,8 +30,6 @@ import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import java.io.IOException
|
||||
import javax.crypto.Mac
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
abstract class GreenShit(
|
||||
override val name: String,
|
||||
@ -196,31 +193,11 @@ abstract class GreenShit(
|
||||
private fun pageListRequestMobile(chapter: SChapter): Request {
|
||||
val pathSegment = chapter.url.replace("capitulo", "capitulo-app-token")
|
||||
val newHeaders = headers.newBuilder()
|
||||
.set("x-client-hash", generateToken(scanId, SECRET_KEY))
|
||||
.set("authorization", "Bearer $token")
|
||||
.build()
|
||||
return GET("$apiUrl$pathSegment", newHeaders)
|
||||
}
|
||||
|
||||
private fun generateToken(scanId: Long, secretKey: String): String {
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
val expiration = timestamp + 3600
|
||||
|
||||
val payload = buildJsonObject {
|
||||
put("scan_id", scanId)
|
||||
put("timestamp", timestamp)
|
||||
put("exp", expiration)
|
||||
}.toJsonString()
|
||||
|
||||
val hmac = Mac.getInstance("HmacSHA256")
|
||||
val secretKeySpec = SecretKeySpec(secretKey.toByteArray(), "HmacSHA256")
|
||||
hmac.init(secretKeySpec)
|
||||
val signatureBytes = hmac.doFinal(payload.toByteArray())
|
||||
val signature = signatureBytes.joinToString("") { "%02x".format(it) }
|
||||
|
||||
return Base64.encodeToString("$payload.$signature".toByteArray(), Base64.NO_WRAP)
|
||||
}
|
||||
|
||||
override fun pageListParse(response: Response): List<Page> =
|
||||
when (contentOrigin) {
|
||||
ContentOrigin.Mobile -> pageListParseMobile(response)
|
||||
@ -444,7 +421,5 @@ abstract class GreenShit(
|
||||
private const val TOKEN_PREF = "greenShitToken"
|
||||
private const val USERNAME_PREF = "usernamePref"
|
||||
private const val PASSWORD_PREF = "passwordPref"
|
||||
|
||||
private const val SECRET_KEY = "sua_chave_secreta_aqui_32_caracteres"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user