Skip to content

Commit

Permalink
Merge pull request #34 from KoalaSat/better-auth
Browse files Browse the repository at this point in the history
Better relay auth
  • Loading branch information
KoalaSat authored Nov 5, 2024
2 parents 4a586ac + 091be10 commit 15b0864
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
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>

0 comments on commit 15b0864

Please sign in to comment.