mirror of
https://github.com/IllusionMan1212/NPS-Browser.git
synced 2026-10-24 02:12:37 +00:00
hardcode the updates HMAC key
This commit is contained in:
@@ -8,6 +8,12 @@ import androidx.datastore.preferences.preferencesDataStore
|
|||||||
import com.illusionware.npsbrowser.data.OnboardingPreferencesRepository
|
import com.illusionware.npsbrowser.data.OnboardingPreferencesRepository
|
||||||
import com.illusionware.npsbrowser.data.SettingsPreferencesRepository
|
import com.illusionware.npsbrowser.data.SettingsPreferencesRepository
|
||||||
|
|
||||||
|
@OptIn(ExperimentalUnsignedTypes::class)
|
||||||
|
val HMAC_KEY = ubyteArrayOf(
|
||||||
|
0xE5U, 0xE2U, 0x78U, 0xAAU, 0x1EU, 0xE3U, 0x40U, 0x82U, 0xA0U, 0x88U, 0x27U, 0x9CU, 0x83U, 0xF9U, 0xBBU, 0xC8U,
|
||||||
|
0x06U, 0x82U, 0x1CU, 0x52U, 0xF2U, 0xABU, 0x5DU, 0x2BU, 0x4AU, 0xBDU, 0x99U, 0x54U, 0x50U, 0x35U, 0x51U, 0x14U
|
||||||
|
)
|
||||||
|
|
||||||
private const val PREFERENCES_NAME = "preferences"
|
private const val PREFERENCES_NAME = "preferences"
|
||||||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(
|
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(
|
||||||
name = PREFERENCES_NAME
|
name = PREFERENCES_NAME
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ data class SettingsPreferences(
|
|||||||
val ps3Dlc: String,
|
val ps3Dlc: String,
|
||||||
val pspDlc: String,
|
val pspDlc: String,
|
||||||
val psvThemes: String,
|
val psvThemes: String,
|
||||||
val hmacKey: String,
|
|
||||||
val downloadDir: String,
|
val downloadDir: String,
|
||||||
val unpackDir: String,
|
val unpackDir: String,
|
||||||
val unpackInDownload: Boolean,
|
val unpackInDownload: Boolean,
|
||||||
@@ -64,7 +63,6 @@ class SettingsPreferencesRepository(
|
|||||||
private val PS3_DLC = stringPreferencesKey("ps3_dlc")
|
private val PS3_DLC = stringPreferencesKey("ps3_dlc")
|
||||||
private val PSP_DLC = stringPreferencesKey("psp_dlc")
|
private val PSP_DLC = stringPreferencesKey("psp_dlc")
|
||||||
private val PSV_THEMES = stringPreferencesKey("psv_themes")
|
private val PSV_THEMES = stringPreferencesKey("psv_themes")
|
||||||
private val HMAC_KEY = stringPreferencesKey("hmac_key")
|
|
||||||
private val DOWNLOAD_DIR = stringPreferencesKey("download_dir")
|
private val DOWNLOAD_DIR = stringPreferencesKey("download_dir")
|
||||||
private val UNPACK_DIR = stringPreferencesKey("unpack_dir")
|
private val UNPACK_DIR = stringPreferencesKey("unpack_dir")
|
||||||
private val UNPACK_IN_DOWNLOAD = booleanPreferencesKey("unpack_in_download")
|
private val UNPACK_IN_DOWNLOAD = booleanPreferencesKey("unpack_in_download")
|
||||||
@@ -108,12 +106,6 @@ class SettingsPreferencesRepository(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setHMACKey(key: String) {
|
|
||||||
dataStore.edit { prefs ->
|
|
||||||
prefs[HMAC_KEY] = key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun setDownloadDir(dir: String) {
|
suspend fun setDownloadDir(dir: String) {
|
||||||
dataStore.edit { prefs ->
|
dataStore.edit { prefs ->
|
||||||
prefs[DOWNLOAD_DIR] = dir
|
prefs[DOWNLOAD_DIR] = dir
|
||||||
@@ -207,7 +199,6 @@ class SettingsPreferencesRepository(
|
|||||||
prefs[PS3_DLC] ?: "",
|
prefs[PS3_DLC] ?: "",
|
||||||
prefs[PSP_DLC] ?: "",
|
prefs[PSP_DLC] ?: "",
|
||||||
prefs[PSV_THEMES] ?: "",
|
prefs[PSV_THEMES] ?: "",
|
||||||
prefs[HMAC_KEY] ?: "",
|
|
||||||
prefs[DOWNLOAD_DIR] ?: defaultDownloadDir,
|
prefs[DOWNLOAD_DIR] ?: defaultDownloadDir,
|
||||||
prefs[UNPACK_DIR] ?: defaultDownloadDir,
|
prefs[UNPACK_DIR] ?: defaultDownloadDir,
|
||||||
prefs[UNPACK_IN_DOWNLOAD] ?: false,
|
prefs[UNPACK_IN_DOWNLOAD] ?: false,
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ import androidx.compose.foundation.rememberScrollState
|
|||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.CheckCircle
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
import androidx.compose.material.icons.filled.ContentPaste
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.FilledTonalButton
|
import androidx.compose.material3.FilledTonalButton
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -74,20 +73,16 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.layout.Layout
|
import androidx.compose.ui.layout.Layout
|
||||||
import androidx.compose.ui.layout.layoutId
|
import androidx.compose.ui.layout.layoutId
|
||||||
import androidx.compose.ui.platform.LocalClipboardManager
|
|
||||||
import androidx.compose.ui.text.TextRange
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.Font
|
import androidx.compose.ui.text.font.Font
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.illusionware.npsbrowser.data.SettingsPreferences
|
import com.illusionware.npsbrowser.data.SettingsPreferences
|
||||||
import com.illusionware.npsbrowser.model.ConsoleType
|
import com.illusionware.npsbrowser.model.ConsoleType
|
||||||
import com.illusionware.npsbrowser.model.PackageItemType
|
import com.illusionware.npsbrowser.model.PackageItemType
|
||||||
import com.illusionware.npsbrowser.ui.components.NPSIconButton
|
|
||||||
import com.illusionware.npsbrowser.viewmodels.OnboardingViewModel
|
import com.illusionware.npsbrowser.viewmodels.OnboardingViewModel
|
||||||
import com.illusionware.npsbrowser.viewmodels.SettingsViewModel
|
import com.illusionware.npsbrowser.viewmodels.SettingsViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -626,10 +621,6 @@ fun OnBoardingSetupSettings(
|
|||||||
onboardingViewModel: OnboardingViewModel,
|
onboardingViewModel: OnboardingViewModel,
|
||||||
settingsPrefs: SettingsPreferences,
|
settingsPrefs: SettingsPreferences,
|
||||||
) {
|
) {
|
||||||
val clipboard = LocalClipboardManager.current
|
|
||||||
|
|
||||||
var hmacKey by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue("")) }
|
|
||||||
|
|
||||||
val downloadDirPicker = rememberLauncherForActivityResult(
|
val downloadDirPicker = rememberLauncherForActivityResult(
|
||||||
contract = ActivityResultContracts.OpenDocumentTree(),
|
contract = ActivityResultContracts.OpenDocumentTree(),
|
||||||
) { dirUri ->
|
) { dirUri ->
|
||||||
@@ -646,12 +637,6 @@ fun OnBoardingSetupSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setHmacKey(key: String) {
|
|
||||||
if (key.isNotEmpty()) {
|
|
||||||
settingsViewModel.setHMACKey(key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Scaffold { padding ->
|
Scaffold { padding ->
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
@@ -685,37 +670,6 @@ fun OnBoardingSetupSettings(
|
|||||||
.padding(vertical = 16.dp),
|
.padding(vertical = 16.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(24.dp),
|
verticalArrangement = Arrangement.spacedBy(24.dp),
|
||||||
) {
|
) {
|
||||||
ColumnGroup(title = "HMAC Key", modifier = Modifier.padding(horizontal = 16.dp)) {
|
|
||||||
Text(
|
|
||||||
text = "The HMAC Key is used to decrypt the PS Vita game updates' urls. We cannot provide this key since it's the property of Sony",
|
|
||||||
style = Typography.bodyMedium.copy(color = MaterialTheme.colorScheme.outline),
|
|
||||||
)
|
|
||||||
OutlinedTextField(
|
|
||||||
value = hmacKey,
|
|
||||||
onValueChange = {
|
|
||||||
hmacKey = it
|
|
||||||
setHmacKey(it.text)
|
|
||||||
},
|
|
||||||
label = { Text(text = "HMAC Key") },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
trailingIcon = {
|
|
||||||
NPSIconButton(
|
|
||||||
tooltip = "Paste",
|
|
||||||
onClick = {
|
|
||||||
val text = clipboard.getText()?.text ?: ""
|
|
||||||
hmacKey = TextFieldValue(text, selection = TextRange(text.length))
|
|
||||||
setHmacKey(text)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.ContentPaste,
|
|
||||||
contentDescription = "Paste",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
ColumnGroup(title = "Downloads", titleModifier = Modifier.padding(horizontal = 16.dp)) {
|
ColumnGroup(title = "Downloads", titleModifier = Modifier.padding(horizontal = 16.dp)) {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
|
|||||||
@@ -443,7 +443,6 @@ fun BottomSheetPreview() {
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ import androidx.compose.foundation.rememberScrollState
|
|||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.ContentPaste
|
|
||||||
import androidx.compose.material.icons.outlined.ArrowDropDown
|
import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||||
import androidx.compose.material.icons.outlined.FileDownload
|
import androidx.compose.material.icons.outlined.FileDownload
|
||||||
import androidx.compose.material.icons.outlined.Key
|
|
||||||
import androidx.compose.material.icons.outlined.Palette
|
import androidx.compose.material.icons.outlined.Palette
|
||||||
import androidx.compose.material.icons.outlined.Unarchive
|
import androidx.compose.material.icons.outlined.Unarchive
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -48,7 +46,6 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalClipboardManager
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -115,7 +112,6 @@ fun SettingsScreen(
|
|||||||
) {
|
) {
|
||||||
Appearance(viewModel, prefs)
|
Appearance(viewModel, prefs)
|
||||||
TsvFiles(viewModel, prefs)
|
TsvFiles(viewModel, prefs)
|
||||||
Updates(viewModel, prefs)
|
|
||||||
Downloads(viewModel, prefs)
|
Downloads(viewModel, prefs)
|
||||||
Pkg2Zip(viewModel, prefs)
|
Pkg2Zip(viewModel, prefs)
|
||||||
}
|
}
|
||||||
@@ -271,63 +267,7 @@ fun TSVPicker(
|
|||||||
onClick = {
|
onClick = {
|
||||||
filePicker.launch(arrayOf("text/tab-separated-values"))
|
filePicker.launch(arrayOf("text/tab-separated-values"))
|
||||||
}
|
}
|
||||||
)}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun Updates(viewModel: SettingsViewModel, prefs: SettingsPreferences) {
|
|
||||||
val clipboard = LocalClipboardManager.current
|
|
||||||
|
|
||||||
var hmacOpenDialog by remember { mutableStateOf(false) }
|
|
||||||
var dialogHmacKey by remember { mutableStateOf("") }
|
|
||||||
|
|
||||||
SideEffect {
|
|
||||||
dialogHmacKey = prefs.hmacKey
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingGroup(title = "Updates") {
|
|
||||||
DialogSetting(
|
|
||||||
title = "HMAC Key",
|
|
||||||
value = prefs.hmacKey.ifEmpty { "None" },
|
|
||||||
icon = Icons.Outlined.Key,
|
|
||||||
onClick = { hmacOpenDialog = true }
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
if (hmacOpenDialog) {
|
|
||||||
NPSAlertDialog(
|
|
||||||
onDismiss = { hmacOpenDialog = false },
|
|
||||||
title = "HMAC Key",
|
|
||||||
buttons = {
|
|
||||||
TextButton(onClick = { hmacOpenDialog = false }) {
|
|
||||||
Text(text = "Cancel")
|
|
||||||
}
|
|
||||||
TextButton(onClick = {
|
|
||||||
viewModel.setHMACKey(dialogHmacKey)
|
|
||||||
hmacOpenDialog = false
|
|
||||||
}) {
|
|
||||||
Text(text = "OK")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
OutlinedTextField(
|
|
||||||
value = dialogHmacKey,
|
|
||||||
onValueChange = { dialogHmacKey = it },
|
|
||||||
label = { Text(text = "HMAC Key") },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
trailingIcon = {
|
|
||||||
NPSIconButton(
|
|
||||||
tooltip = "Paste",
|
|
||||||
onClick = { dialogHmacKey = clipboard.getText()?.text ?: "" }
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.ContentPaste,
|
|
||||||
contentDescription = "Paste",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ class SettingsViewModel(private val settingsPrefsRepo: SettingsPreferencesReposi
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
"",
|
"",
|
||||||
@@ -85,12 +84,6 @@ class SettingsViewModel(private val settingsPrefsRepo: SettingsPreferencesReposi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setHMACKey(hmacKey: String) {
|
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
|
||||||
settingsPrefsRepo.setHMACKey(hmacKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setDownloadDir(downloadDir: String) {
|
fun setDownloadDir(downloadDir: String) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
settingsPrefsRepo.setDownloadDir(downloadDir)
|
settingsPrefsRepo.setDownloadDir(downloadDir)
|
||||||
|
|||||||
Reference in New Issue
Block a user