Skip to content
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
14 changes: 11 additions & 3 deletions app/src/main/kotlin/io/privkey/keep/nip55/Nip55Activity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.privkey.keep.uniffi.Nip55RequestType
import io.privkey.keep.uniffi.Nip55RelayAuthGate
import io.privkey.keep.uniffi.Nip55Response
import io.privkey.keep.uniffi.nip55ExtractRelayHost
import io.privkey.keep.uniffi.nip55MaxBatchSize
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -60,7 +61,9 @@ class Nip55Activity : FragmentActivity() {
// pending list, the displayed snapshot the decision binds to, and the commit lock,
// and enforces the three TOCTOU guards so a late-racing request can never be folded
// into the signed set (gh #372).
private val gate = BatchConsentGate<PendingNip55Request, DisplayedCaller>(MAX_BATCH_SIZE) { it.request.requestType }
private val gate by lazy {
BatchConsentGate<PendingNip55Request, DisplayedCaller>(MAX_BATCH_SIZE) { it.request.requestType }
}

private class PendingNip55Request(
val request: Nip55Request,
Expand Down Expand Up @@ -103,8 +106,13 @@ class Nip55Activity : FragmentActivity() {
private const val MAX_CONTENT_LENGTH = 1024 * 1024
private const val MAX_PUBKEY_LENGTH = 128
private const val MAX_EXTRA_LENGTH = 2048
// Mirrors keep-mobile MAX_BATCH_SIZE; bounds accumulation against a spammy caller.
private const val MAX_BATCH_SIZE = 20
// keep-mobile owns the batch cap; read it rather than duplicate the value and
// risk drift across the RMP boundary. Bounds accumulation against a spammy caller.
// Computed (not a stored val) so the FFI call happens at the use site during
// request handling rather than at class-init: in the degraded state where
// initializeKeepMobile() failed, a NIP-55 intent then fails on the signing path
// as a handled error rather than an opaque ExceptionInInitializerError at load.
private val MAX_BATCH_SIZE: Int get() = nip55MaxBatchSize().toInt()
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
2 changes: 1 addition & 1 deletion keep.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3a6aa55094d48465583ac653438c5f86460497c3
750d8f5f44304b009ef1c45313999447020dbd9a