mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
change sign type to sign_message, fix content provider
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
<provider
|
||||
android:name=".SignerProvider"
|
||||
android:authorities="${applicationId}.SIGN_EVENT;${applicationId}.NIP04_ENCRYPT;${applicationId}.NIP04_DECRYPT;${applicationId}.NIP44_ENCRYPT;${applicationId}.NIP44_DECRYPT;${applicationId}.GET_PUBLIC_KEY;${applicationId}.DECRYPT_ZAP_EVENT"
|
||||
android:authorities="${applicationId}.SIGN_MESSAGE;${applicationId}.SIGN_EVENT;${applicationId}.NIP04_ENCRYPT;${applicationId}.NIP04_DECRYPT;${applicationId}.NIP44_ENCRYPT;${applicationId}.NIP44_DECRYPT;${applicationId}.GET_PUBLIC_KEY;${applicationId}.DECRYPT_ZAP_EVENT"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class SignerProvider : ContentProvider() {
|
||||
): Cursor? {
|
||||
val appId = BuildConfig.APPLICATION_ID
|
||||
return when (uri.toString()) {
|
||||
"content://$appId.SIGN" -> {
|
||||
"content://$appId.SIGN_MESSAGE" -> {
|
||||
val packageName = callingPackage ?: return null
|
||||
val message = projection?.first() ?: return null
|
||||
if (!LocalPreferences.containsAccount(projection[2])) return null
|
||||
@@ -60,8 +60,7 @@ class SignerProvider : ContentProvider() {
|
||||
.applicationDao()
|
||||
.getPermission(
|
||||
sortOrder ?: packageName,
|
||||
"SIGN",
|
||||
null,
|
||||
"SIGN_MESSAGE",
|
||||
)
|
||||
if (currentSelection == "1") {
|
||||
val isRemembered = permission?.acceptable ?: return null
|
||||
@@ -104,7 +103,7 @@ class SignerProvider : ContentProvider() {
|
||||
HistoryEntity(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
"SIGN",
|
||||
"SIGN_MESSAGE",
|
||||
null,
|
||||
TimeUtils.now(),
|
||||
true,
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.greenart7c3.nostrsigner.models
|
||||
|
||||
enum class SignerType {
|
||||
CONNECT,
|
||||
SIGN,
|
||||
SIGN_MESSAGE,
|
||||
SIGN_EVENT,
|
||||
NIP04_ENCRYPT,
|
||||
NIP04_DECRYPT,
|
||||
|
||||
@@ -77,7 +77,7 @@ object IntentUtils {
|
||||
if (parameter == "type") {
|
||||
type =
|
||||
when (parameterData) {
|
||||
"sign" -> SignerType.SIGN
|
||||
"sign_message" -> SignerType.SIGN_MESSAGE
|
||||
"sign_event" -> SignerType.SIGN_EVENT
|
||||
"get_public_key" -> SignerType.GET_PUBLIC_KEY
|
||||
"nip04_encrypt" -> SignerType.NIP04_ENCRYPT
|
||||
@@ -198,7 +198,7 @@ object IntentUtils {
|
||||
),
|
||||
)
|
||||
}
|
||||
SignerType.SIGN -> {
|
||||
SignerType.SIGN_MESSAGE -> {
|
||||
onReady(
|
||||
IntentData(
|
||||
localData,
|
||||
@@ -227,7 +227,7 @@ object IntentUtils {
|
||||
|
||||
fun getTypeFromBunker(bunkerRequest: BunkerRequest): SignerType {
|
||||
return when (bunkerRequest.method) {
|
||||
"sign" -> SignerType.SIGN
|
||||
"sign_message" -> SignerType.SIGN_MESSAGE
|
||||
"connect" -> SignerType.CONNECT
|
||||
"sign_event" -> SignerType.SIGN_EVENT
|
||||
"get_public_key" -> SignerType.GET_PUBLIC_KEY
|
||||
@@ -241,7 +241,7 @@ object IntentUtils {
|
||||
|
||||
fun getDataFromBunker(bunkerRequest: BunkerRequest): String {
|
||||
return when (bunkerRequest.method) {
|
||||
"sign" -> bunkerRequest.params.first()
|
||||
"sign_message" -> bunkerRequest.params.first()
|
||||
"connect" -> "ack"
|
||||
"sign_event" -> {
|
||||
val amberEvent = AmberEvent.fromJson(bunkerRequest.params.first())
|
||||
@@ -450,7 +450,7 @@ object IntentUtils {
|
||||
),
|
||||
)
|
||||
}
|
||||
SignerType.SIGN -> {
|
||||
SignerType.SIGN_MESSAGE -> {
|
||||
onReady(
|
||||
IntentData(
|
||||
data,
|
||||
@@ -484,7 +484,7 @@ object IntentUtils {
|
||||
) {
|
||||
val type =
|
||||
when (intent.extras?.getString("type")) {
|
||||
"sign" -> SignerType.SIGN
|
||||
"sign_message" -> SignerType.SIGN_MESSAGE
|
||||
"sign_event" -> SignerType.SIGN_EVENT
|
||||
"nip04_encrypt" -> SignerType.NIP04_ENCRYPT
|
||||
"nip04_decrypt" -> SignerType.NIP04_DECRYPT
|
||||
@@ -613,6 +613,28 @@ object IntentUtils {
|
||||
),
|
||||
)
|
||||
}
|
||||
SignerType.SIGN_MESSAGE -> {
|
||||
onReady(
|
||||
IntentData(
|
||||
data,
|
||||
name,
|
||||
type,
|
||||
pubKey,
|
||||
id,
|
||||
intent.extras?.getString("callbackUrl"),
|
||||
compressionType,
|
||||
returnType,
|
||||
permissions,
|
||||
intent.extras?.getString("current_user") ?: Hex.decode(pubKey).toNpub(),
|
||||
mutableStateOf(true),
|
||||
mutableStateOf(false),
|
||||
null,
|
||||
route,
|
||||
null,
|
||||
null,
|
||||
),
|
||||
)
|
||||
}
|
||||
else -> onReady(null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ fun MultiEventHomeScreen(
|
||||
),
|
||||
)
|
||||
}
|
||||
} else if (intentData.type == SignerType.SIGN) {
|
||||
} else if (intentData.type == SignerType.SIGN_MESSAGE) {
|
||||
if (intentData.rememberMyChoice.value) {
|
||||
AmberUtils.acceptOrRejectPermission(
|
||||
key,
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ fun SingleEventHomeScreen(
|
||||
)
|
||||
}
|
||||
|
||||
SignerType.SIGN -> {
|
||||
SignerType.SIGN_MESSAGE -> {
|
||||
val permission =
|
||||
applicationEntity?.permissions?.firstOrNull {
|
||||
it.pkKey == key && it.type == intentData.type.toString()
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<provider
|
||||
android:name=".SignerProvider"
|
||||
android:authorities="${applicationId}.SIGN_EVENT;${applicationId}.NIP04_ENCRYPT;${applicationId}.NIP04_DECRYPT;${applicationId}.NIP44_ENCRYPT;${applicationId}.NIP44_DECRYPT;${applicationId}.GET_PUBLIC_KEY;${applicationId}.DECRYPT_ZAP_EVENT"
|
||||
android:authorities="${applicationId}.SIGN_MESSAGE;${applicationId}.SIGN_EVENT;${applicationId}.NIP04_ENCRYPT;${applicationId}.NIP04_DECRYPT;${applicationId}.NIP44_ENCRYPT;${applicationId}.NIP44_DECRYPT;${applicationId}.GET_PUBLIC_KEY;${applicationId}.DECRYPT_ZAP_EVENT"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user