Create NostrSignerRemote

This commit is contained in:
greenart7c3
2025-11-10 15:03:45 -03:00
parent 2c3da65063
commit df1bf82e76
@@ -0,0 +1,108 @@
/**
* Copyright (c) 2025 Vitor Pamplona
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.vitorpamplona.quartz.nip46RemoteSigner.signer
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient
import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.req
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent
import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
class NostrSignerRemote(
signer: NostrSignerInternal,
val remotePubkey: HexKey,
val relays: List<NormalizedRelayUrl>,
val client: INostrClient,
) : NostrSigner(signer.pubKey) {
val subscription =
client.req(
relays = relays,
filter =
Filter(
kinds = listOf(NostrConnectEvent.KIND),
tags = mapOf("p" to listOf(remotePubkey)),
),
) { event ->
}
fun openSubscription() {
subscription.updateFilter()
}
fun closeSubscription() {
subscription.close()
}
override fun isWriteable(): Boolean = true
override suspend fun <T : Event> sign(
createdAt: Long,
kind: Int,
tags: Array<Array<String>>,
content: String,
): T {
TODO("Not yet implemented")
}
override suspend fun nip04Encrypt(
plaintext: String,
toPublicKey: HexKey,
): String {
TODO("Not yet implemented")
}
override suspend fun nip04Decrypt(
ciphertext: String,
fromPublicKey: HexKey,
): String {
TODO("Not yet implemented")
}
override suspend fun nip44Encrypt(
plaintext: String,
toPublicKey: HexKey,
): String {
TODO("Not yet implemented")
}
override suspend fun nip44Decrypt(
ciphertext: String,
fromPublicKey: HexKey,
): String {
TODO("Not yet implemented")
}
override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent {
TODO("Not yet implemented")
}
override suspend fun deriveKey(nonce: HexKey): HexKey {
TODO("Not yet implemented")
}
override fun hasForegroundSupport(): Boolean = true
}