Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better relay auth #34

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/src/main/java/com/koalasat/pokey/models/ExternalSigner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object ExternalSigner {
}
}

fun auth(relayUrl: String, challenge: String, onReady: (String) -> Unit) {
fun auth(relayUrl: String, challenge: String, onReady: (Event) -> Unit) {
val pubKey = Pokey.getInstance().getHexKey()
val createdAt = TimeUtils.now()
val kind = 22242
Expand All @@ -71,6 +71,24 @@ object ExternalSigner {
content = content,
sig = "",
)
externalSignerLauncher.openSigner(
event,
) {
onReady(
Event(
id = id,
pubKey = pubKey,
createdAt = createdAt,
kind = kind,
tags = tags,
content = content,
sig = it,
),
)
}
}

fun sign(event: Event, onReady: (String) -> Unit) {
externalSignerLauncher.openSigner(
event,
onReady,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class NotificationsService : Service() {
override fun onAuth(relay: Relay, challenge: String) {
Log.d("Pokey", "Relay on Auth: ${relay.url} : $challenge")
ExternalSigner.auth(relay.url, challenge) { result ->
Log.d("Pokey", "Relay on Auth response: ${relay.url} : $result")
Log.d("Pokey", "Relay on Auth response: ${relay.url} : ${result.toJson()}")
relay.send(result)
relay.renewFilters()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class RelaysFragment : Fragment() {
binding.addPrivateRelayUrl.error = getString(R.string.invalid_uri)
}
}
binding.publishPrivateRelay.setOnClickListener {
}
binding.reloadPrivateRelay.setOnClickListener {
Pokey.updateLoadingPrivateRelays(true)
reconnectRelays(privateRelaysKind)
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/res/drawable/ic_remove_red_24dp.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
<?xml version="1.1" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFDC143C"
android:pathData="M3,6h18c0.553,0 1,0.447 1,1v2h-20V7C2,6.447 2.447,6 3,6zM4,10h16v12c0,1.104 -0.896,2 -2,2H6c-1.104,0 -2,-0.896 -2,-2V10zM10,12v8h4v-8h-4z"/>
</vector>
<!-- drawable/minus_circle.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFDC143C" android:pathData="M17,13H7V11H17M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /></vector>
Loading