From 4098358233ef518b8c6d3c689475e9b38d6a06e3 Mon Sep 17 00:00:00 2001 From: sergeych Date: Fri, 22 Nov 2024 09:18:07 +0700 Subject: [PATCH] +client.localIdentity --- .gitignore | 1 + .../kotlin/net/sergeych/kiloparsec/KiloClient.kt | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7cf10c5..9c2bce0 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ out/ # More .kotlin /.idea/workspace.xml +/.gigaide/gigaide.properties diff --git a/src/commonMain/kotlin/net/sergeych/kiloparsec/KiloClient.kt b/src/commonMain/kotlin/net/sergeych/kiloparsec/KiloClient.kt index 77ce6a9..44d79af 100644 --- a/src/commonMain/kotlin/net/sergeych/kiloparsec/KiloClient.kt +++ b/src/commonMain/kotlin/net/sergeych/kiloparsec/KiloClient.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.isActive import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import net.sergeych.crypto2.SigningKey +import net.sergeych.crypto2.VerifyingKey import net.sergeych.crypto2.VerifyingPublicKey import net.sergeych.mp_logger.LogTag import net.sergeych.mp_logger.Loggable @@ -60,6 +61,14 @@ class KiloClient( @Suppress("unused") val connectedStateFlow = _state.asStateFlow() + /** + * The verifying, or public, key identifying client sessions. It could be used to + * restore environment on reconnection. This is what remote side, e.g. server, sees as + * [KiloScope.remoteIdentity]. + */ + @Suppress("unused") + val localIdentity: VerifyingKey? = secretKey?.verifyingKey + private var deferredClient = CompletableDeferred>() private val job = @@ -141,7 +150,7 @@ class KiloClient( * a key. Connection is established either with a properly authenticated key or no key at all. */ @Suppress("unused") - suspend fun remoteId(): VerifyingPublicKey? = deferredClient.await().remoteId() + suspend fun remoteIdentity(): VerifyingPublicKey? = deferredClient.await().remoteId() companion object { class Builder() {