mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 18:39:55 +02:00
fix(receive): harden invitation open path and cover receive loop
Tighten cold-open and in-app invitation handling so ticket acquisition is stricter and less racey across hosts, and expand automated coverage for the receive history and acquisition flow before merge.
This commit is contained in:
@@ -18,7 +18,7 @@ actual fun rememberReceiveInvitationActions(): ReceiveInvitationActions = rememb
|
||||
override fun pickInvitation(onResult: (Result<String>) -> Unit) {
|
||||
EventQueue.invokeLater {
|
||||
val dialog = FileDialog(activeFrame(), "Open VniDrop invitation", FileDialog.LOAD).apply {
|
||||
setFilenameFilter { _, name -> name.endsWith(".vnd", ignoreCase = true) }
|
||||
setFilenameFilter { _, name -> name.endsWith(".$VniDropInvitationExtension", ignoreCase = true) }
|
||||
}
|
||||
try {
|
||||
dialog.isVisible = true
|
||||
@@ -40,8 +40,9 @@ actual fun rememberReceiveInvitationActions(): ReceiveInvitationActions = rememb
|
||||
}
|
||||
|
||||
private fun readInvitation(file: File): Result<String> = runCatching {
|
||||
require(file.length() <= MaxInvitationBytes) { "The invitation is too large" }
|
||||
file.readText()
|
||||
require(file.extension.equals(VniDropInvitationExtension, ignoreCase = true)) { "This is not a VniDrop invitation" }
|
||||
val bytes = file.inputStream().use { it.readNBytes(MaxInvitationBytes + 1) }
|
||||
decodeInvitationBytes(bytes)
|
||||
}
|
||||
|
||||
private fun activeFrame(): Frame? =
|
||||
|
||||
Reference in New Issue
Block a user