add client authentication, change message when encrypt or decrypt data

This commit is contained in:
greenart7c3
2023-08-25 11:58:06 -03:00
parent ef2ec1a386
commit 30c3ce4dcc
2 changed files with 10 additions and 19 deletions
@@ -138,7 +138,7 @@ fun MainScreen(account: Account, accountStateViewModel: AccountStateViewModel, j
SignerType.NIP04_DECRYPT, SignerType.NIP04_ENCRYPT -> {
EncryptDecryptData(
appName,
it.data,
it.type,
{
val sig = if (it.type == SignerType.NIP04_DECRYPT) {
CryptoUtils.decrypt(
@@ -181,7 +181,6 @@ fun MainScreen(account: Account, accountStateViewModel: AccountStateViewModel, j
val event = IntentUtils.getIntent(it.data, account.keyPair)
EventData(
it.type,
appName,
event,
event.toJson(),
@@ -271,7 +270,7 @@ fun AcceptRejectButtons(
@Composable
fun EncryptDecryptData(
appName: String,
data: String,
type: SignerType,
onAccept: () -> Unit,
onReject: () -> Unit
) {
@@ -287,21 +286,11 @@ fun EncryptDecryptData(
.fillMaxWidth()
) {
Column(Modifier.padding(6.dp)) {
val message = if (type == SignerType.NIP04_ENCRYPT) "encrypt" else "decrypt"
Text(
"wants you to encrypt/decrypt data",
"wants you to $message data",
fontWeight = FontWeight.Bold
)
EventRow(
Icons.Default.ContentPaste,
"Content ",
data
)
Divider(
modifier = Modifier.padding(top = 15.dp),
thickness = Dp.Hairline
)
}
}
@@ -353,7 +342,6 @@ fun LoginWithPubKey(
@Composable
fun EventData(
type: SignerType,
appName: String,
event: Event,
rawJson: String,
@@ -377,8 +365,13 @@ fun EventData(
.fillMaxWidth()
) {
Column(Modifier.padding(6.dp)) {
val message = if (event.kind == 22242) {
"client authentication"
} else {
eventDescription
}
Text(
if (type == SignerType.NIP04_DECRYPT) "wants you to decrypt a message" else "wants you to sign a $eventDescription",
"wants you to sign a $message",
fontWeight = FontWeight.Bold
)
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import com.greenart7c3.nostrsigner.models.SignerType
import com.greenart7c3.nostrsigner.models.TimeUtils
import com.greenart7c3.nostrsigner.service.model.Event
import com.greenart7c3.nostrsigner.ui.EventData
@@ -20,7 +19,6 @@ fun EventDataPreview() {
NostrSignerTheme(darkTheme = true) {
Scaffold {
EventData(
SignerType.SIGN_EVENT,
"App",
event,
data,