Back up Orbit to my phone: sealed on the TV, previewed and restored safely, with undo (0.128.0)
Companion More > Back up and restore, in both editions. The file is sealed on the TV (AES-256-GCM, key from the TV's backup code with PBKDF2) and the code is shown and typed only on the TV. No sign-in, token, PIN, phones, room keys or box switches. Versioned header bound into the seal, checksums outside and in. Restore: TV preview, this TV's data kept aside, a journal, then put in place first thing on restart; three failed starts put the old data back. Undo in Settings > Rooms and phones. Also fixes two remote-focus bugs found on the emulator: Right from Emby on the first-launch server step escaped into the hidden sign-in form, and Connect, Add a room and Bring in jumped to Settings > Channels. Report: docs/PHONE-BACKUP-2026-11-10.md (incl. the password-field accessibility finding). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,259 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.After
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
/**
|
||||
* Back up Orbit to my phone (Paul, 10 November 2026): the file, its seal and checks, what goes in and what never does, and
|
||||
* restoring, including a file cut short, a damaged one, a restore stopped part-way, and undo. Every code, name and setting
|
||||
* here is made up.
|
||||
*/
|
||||
class PhoneBackupTest {
|
||||
private lateinit var tv: File
|
||||
private lateinit var other: File
|
||||
private val code = "K7QM2XTR9HFDW3PA"
|
||||
|
||||
private class MapPrefs(val files: MutableMap<String, MutableMap<String, Any?>> = mutableMapOf()) : PrefsBox {
|
||||
override fun read(name: String): Map<String, Any?> = files[name].orEmpty().toMap()
|
||||
override fun write(name: String, values: Map<String, Any?>) { files[name] = values.toMutableMap() }
|
||||
}
|
||||
|
||||
private fun household(root: File, prefs: MapPrefs, who: String) {
|
||||
val s = File(root, "no_backup/schedule").apply { mkdirs() }
|
||||
File(s, "progress-101.json").writeText(JSONObject().put("schema", 1).put("user", "user-$who").put("channel", 101).put("enabled", true).toString())
|
||||
File(s, "progress-101.json.prev").writeText("an older copy")
|
||||
File(s, "schedule-101.json").writeText(JSONObject().put("schema", 1).put("user", "user-$who").put("channel", 101).put("plan", "$who's plan").toString())
|
||||
File(s, "yours.json").writeText(JSONArray().put(JSONObject().put("number", 701).put("name", "$who's Mysteries")).toString())
|
||||
File(s, "continue-grown.json").writeText(JSONArray().put(JSONObject().put("number", 101).put("startMs", 1).put("atMs", 2)).toString())
|
||||
File(s, "tickets-0.json").writeText(JSONObject().put("schema", 1).put("user", "user-$who").put("channel", 0).put("tickets", JSONObject().put("1794254400000", 2)).toString())
|
||||
File(s, "taste").mkdirs(); File(s, "taste/grown.events.jsonl").writeText("{\"e\":1}\n{\"e\":2}\n")
|
||||
File(s, "playback-notes.txt").writeText("diagnostics")
|
||||
File(root, "files/arcade").mkdirs(); File(root, "files/arcade/household-records.json").writeText("{\"who\":\"$who\"}")
|
||||
File(root, "files/arcade/hive-tone-v1-a.wav").writeText("generated")
|
||||
prefs.files["orbit_settings"] = mutableMapOf("look" to "Night-$who", "snake_best" to 380, "surround_to_amplifier" to (who == "A"), "provider_catalogue" to (who == "A"),
|
||||
"player_avi" to false, "subtitle_style_grown" to "1,box")
|
||||
prefs.files["orbit_profiles"] = mutableMapOf("profiles" to Profiles.encode(listOf(Profile("grown", "Adult $who", "sil-pink", ProfileKind.Grown, emptySet()))), "current" to "grown")
|
||||
prefs.files["orbit_rooms"] = mutableMapOf("name" to "Den $who", "joined" to "[]")
|
||||
prefs.files["orbit_lock"] = mutableMapOf("after_dark_pin" to "hash-$who", "after_dark_salt" to "salt")
|
||||
prefs.files["orbit_phones"] = mutableMapOf("phone-hash" to "Pixel|1")
|
||||
}
|
||||
|
||||
private val prefsA = MapPrefs(); private val prefsB = MapPrefs()
|
||||
private fun schedule(root: File) = File(root, "no_backup/schedule")
|
||||
private fun arcade(root: File) = File(root, "files/arcade")
|
||||
private fun restorer(root: File, prefs: MapPrefs) = PhoneRestore(File(root, "no_backup/phone-restore"), schedule(root), arcade(root), prefs)
|
||||
private fun backupOfA(): String = BackupFormat.seal(BackupContents.zip(schedule(tv), arcade(tv), prefsA, 1_000L, "0.127.0", 400, "household", "Den A", "server-a"),
|
||||
code, 1_000L, "0.127.0", 400, "household", iterations = 100_000)
|
||||
|
||||
@Before fun up() {
|
||||
tv = Files.createTempDirectory("orbit-backup-a").toFile(); other = Files.createTempDirectory("orbit-backup-b").toFile()
|
||||
household(tv, prefsA, "A"); household(other, prefsB, "B")
|
||||
}
|
||||
@After fun down() { tv.deleteRecursively(); other.deleteRecursively() }
|
||||
|
||||
/** Opens and unpacks [text] into [root]'s incoming folder, as the TV does once the code's typed. */
|
||||
private fun receive(text: String, root: File, typed: String = code): JSONObject {
|
||||
val (header, sealed) = BackupFormat.parse(text)
|
||||
val zip = BackupFormat.open(header, sealed, typed) ?: throw BackupFormat.Refused("wrong code")
|
||||
return BackupFormat.unpack(zip, File(root, "no_backup/phone-restore/incoming"))
|
||||
}
|
||||
|
||||
@Test fun aBackupOpensWithItsCodeAndHoldsTheHousehold() {
|
||||
val text = backupOfA()
|
||||
assertTrue(text.startsWith("ORBIT-BACKUP 1\n")); assertTrue(text.trimEnd().endsWith("END ORBIT-BACKUP"))
|
||||
val manifest = receive(text, other)
|
||||
val paths = manifest.getJSONArray("files").let { a -> (0 until a.length()).map { a.getJSONObject(it).getString("path") } }
|
||||
assertTrue(paths.containsAll(listOf("schedule/progress-101.json", "schedule/schedule-101.json", "schedule/yours.json", "schedule/continue-grown.json",
|
||||
"schedule/tickets-0.json", "schedule/taste/grown.events.jsonl", "arcade/household-records.json", "prefs/orbit_settings.json", "prefs/orbit_profiles.json", "prefs/orbit_rooms.json")))
|
||||
// Copies kept while saving, generated sounds and diagnostics stay behind.
|
||||
assertFalse(paths.any { it.endsWith(".prev") || it.endsWith(".wav") || it.endsWith("playback-notes.txt") })
|
||||
assertEquals("Den A", manifest.getString("room"))
|
||||
}
|
||||
|
||||
@Test fun noSecretEverGoesIn() {
|
||||
val text = backupOfA()
|
||||
val incoming = File(other, "no_backup/phone-restore/incoming"); receive(text, other)
|
||||
val everything = incoming.walkTopDown().filter { it.isFile }.joinToString("\n") { it.readText() }
|
||||
// No PIN, no phones, no sync keys, no sign-in, and none of this box's own switches.
|
||||
listOf("after_dark_pin", "hash-A", "phone-hash", "orbit_lock", "orbit_phones", "orbit_room_links", "surround_to_amplifier", "provider_catalogue", "player_avi", "joined")
|
||||
.forEach { assertFalse("$it travelled", everything.contains(it)) }
|
||||
// And the sealed file shows nothing readable at all.
|
||||
listOf("Den A", "Adult A", "Night-A", "Mysteries", "snake_best").forEach { assertFalse("$it readable in the file", text.contains(it)) }
|
||||
}
|
||||
|
||||
@Test fun aFileHoldingSomethingShapedLikeATokenIsLeftOut() {
|
||||
File(schedule(tv), "evidence-0.jsonl").writeText("{\"url\":\"http://x/Videos/1/stream?api_key=abc123\"}\n")
|
||||
val manifest = receive(backupOfA(), other)
|
||||
assertEquals(listOf("schedule/evidence-0.jsonl"), manifest.getJSONArray("leftOut").let { a -> (0 until a.length()).map { a.getString(it) } })
|
||||
assertFalse(File(other, "no_backup/phone-restore/incoming/schedule/evidence-0.jsonl").exists())
|
||||
}
|
||||
|
||||
@Test fun theWrongCodeOpensNothing() {
|
||||
val (header, sealed) = BackupFormat.parse(backupOfA())
|
||||
assertNull(BackupFormat.open(header, sealed, "K7QM2XTR9HFDW3PB"))
|
||||
assertNotNull(BackupFormat.open(header, sealed, code))
|
||||
}
|
||||
|
||||
@Test fun aFileCutShortIsCaughtBeforeTheCodeIsAsked() {
|
||||
val text = backupOfA()
|
||||
// Stopped part-way through the download: no end line, or the end line but bytes missing.
|
||||
val cut = text.substring(0, text.length / 2)
|
||||
assertTrue(runCatching { BackupFormat.parse(cut) }.exceptionOrNull()!!.message!!.contains("incomplete"))
|
||||
val lines = text.trimEnd('\n').split('\n')
|
||||
val missing = (lines.take(3) + lines.subList(3, lines.size - 1).dropLast(3) + lines.last()).joinToString("\n")
|
||||
assertTrue(runCatching { BackupFormat.parse(missing) }.exceptionOrNull()!!.message!!.contains("missing"))
|
||||
}
|
||||
|
||||
@Test fun aDamagedFileIsRefused() {
|
||||
val text = backupOfA(); val lines = text.trimEnd('\n').split('\n').toMutableList()
|
||||
// One character changed in the sealed part: caught by the checksum.
|
||||
val i = 5; lines[i] = lines[i].replaceRange(10, 11, if (lines[i][10] == 'A') "B" else "A")
|
||||
assertTrue(runCatching { BackupFormat.parse(lines.joinToString("\n")) }.exceptionOrNull()!!.message!!.contains("checksum"))
|
||||
// The header changed (an older format claimed, say) with the checksum left alone: the seal refuses it.
|
||||
val header = text.split('\n')[1]
|
||||
val forged = text.replace(header, header.replace("\"build\":400", "\"build\":300"))
|
||||
val (h, sealed) = BackupFormat.parse(forged)
|
||||
assertNull(BackupFormat.open(h, sealed, code))
|
||||
// Not a backup at all, and one from a newer Orbit.
|
||||
assertTrue(runCatching { BackupFormat.parse("hello") }.exceptionOrNull()!!.message!!.contains("isn't an Orbit backup"))
|
||||
assertTrue(runCatching { BackupFormat.parse(text.replaceFirst("ORBIT-BACKUP 1", "ORBIT-BACKUP 2")) }.exceptionOrNull()!!.message!!.contains("newer Orbit"))
|
||||
}
|
||||
|
||||
@Test fun aZipWithAnythingUnexpectedIsRefused() {
|
||||
fun zipOf(vararg entries: Pair<String, String>, manifest: JSONObject? = null): ByteArray = java.io.ByteArrayOutputStream().also { b ->
|
||||
java.util.zip.ZipOutputStream(b).use { z ->
|
||||
val listed = JSONArray(entries.map { (p, t) -> JSONObject().put("path", p).put("sha256", BackupFormat.sha256(t.toByteArray())) })
|
||||
z.putNextEntry(java.util.zip.ZipEntry("manifest.json")); z.write((manifest ?: JSONObject().put("format", 1).put("files", listed)).toString().toByteArray())
|
||||
entries.forEach { (p, t) -> z.putNextEntry(java.util.zip.ZipEntry(p)); z.write(t.toByteArray()) }
|
||||
} }.toByteArray()
|
||||
val into = File(other, "unpack")
|
||||
listOf("../escape.json", "schedule/../../escape.json", "prefs/orbit_lock.json", "no_backup/orbit-connection.v1", "/etc/x").forEach { bad ->
|
||||
assertTrue(bad, runCatching { BackupFormat.unpack(zipOf(bad to "{}"), into) }.exceptionOrNull() is BackupFormat.Refused)
|
||||
assertFalse(File(other, "escape.json").exists())
|
||||
}
|
||||
// A file changed after it was listed, and a file that isn't listed.
|
||||
val wrongSum = JSONObject().put("format", 1).put("files", JSONArray().put(JSONObject().put("path", "schedule/a.json").put("sha256", "0".repeat(64))))
|
||||
assertTrue(runCatching { BackupFormat.unpack(zipOf("schedule/a.json" to "{}", manifest = wrongSum), into) }.exceptionOrNull()!!.message!!.contains("checksum"))
|
||||
val unlisted = JSONObject().put("format", 1).put("files", JSONArray())
|
||||
assertTrue(runCatching { BackupFormat.unpack(zipOf("schedule/a.json" to "{}", manifest = unlisted), into) }.exceptionOrNull()!!.message!!.contains("don't match"))
|
||||
assertFalse(into.exists())
|
||||
}
|
||||
|
||||
@Test fun thePreviewSaysWhatIsInItAndWhatIsHere() {
|
||||
receive(backupOfA(), other)
|
||||
val r = restorer(other, prefsB)
|
||||
val theirs = BackupContents.summarise(File(r.incoming, "schedule"), File(r.incoming, "arcade"), r.prefsIn(r.incoming))
|
||||
assertEquals(listOf("Adult A"), theirs.profiles); assertEquals(1, theirs.channelsOn); assertEquals(listOf("A's Mysteries"), theirs.yourChannels)
|
||||
assertEquals(mapOf("Adult A" to 2), theirs.tasteEvents); assertEquals(1, theirs.continueEntries); assertEquals(1, theirs.tickets)
|
||||
assertEquals("Den A", theirs.room); assertEquals("user-A", theirs.user)
|
||||
val here = r.summariseHere()
|
||||
assertEquals(listOf("Adult B"), here.profiles); assertEquals("user-B", here.user)
|
||||
assertTrue(theirs.lines().any { it.startsWith("Profiles: Adult A") })
|
||||
}
|
||||
|
||||
@Test fun restoreReplacesTheHouseholdKeepsThisBoxAndCanBeUndone() {
|
||||
receive(backupOfA(), other)
|
||||
val r = restorer(other, prefsB)
|
||||
val before = schedule(other).walkTopDown().filter { it.isFile }.associate { it.relativeTo(schedule(other)).path to it.readText() }
|
||||
r.prepare(5_000L, 1_000L, "Pixel")
|
||||
// Nothing changes until Orbit starts again.
|
||||
assertEquals("{\"who\":\"B\"}", File(arcade(other), "household-records.json").readText())
|
||||
val done = r.finish(6_000L)!!
|
||||
assertTrue(done.optBoolean("ok"))
|
||||
assertTrue(File(schedule(other), "schedule-101.json").readText().contains("A's plan"))
|
||||
assertEquals("{\"who\":\"A\"}", File(arcade(other), "household-records.json").readText())
|
||||
assertEquals("Night-A", prefsB.files["orbit_settings"]!!["look"]); assertEquals("Den A", prefsB.files["orbit_rooms"]!!["name"])
|
||||
// This box's own: sound output and switches as they were here, and the PIN, phones and room history untouched.
|
||||
assertEquals(false, prefsB.files["orbit_settings"]!!["surround_to_amplifier"]); assertEquals(false, prefsB.files["orbit_settings"]!!["provider_catalogue"])
|
||||
assertEquals("hash-B", prefsB.files["orbit_lock"]!!["after_dark_pin"]); assertEquals("Pixel|1", prefsB.files["orbit_phones"]!!["phone-hash"])
|
||||
assertEquals("[]", prefsB.files["orbit_rooms"]!!["joined"])
|
||||
assertFalse(r.incoming.exists())
|
||||
// Undo puts back exactly what was here.
|
||||
assertEquals("restore", r.undoable()!!.getString("before"))
|
||||
r.prepareUndo(7_000L); assertTrue(r.finish(8_000L)!!.optBoolean("ok"))
|
||||
val after = schedule(other).walkTopDown().filter { it.isFile }.associate { it.relativeTo(schedule(other)).path to it.readText() }
|
||||
assertEquals(before, after)
|
||||
assertEquals("Night-B", prefsB.files["orbit_settings"]!!["look"]); assertEquals("{\"who\":\"B\"}", File(arcade(other), "household-records.json").readText())
|
||||
// And the undo can be undone, back to the backup's.
|
||||
assertEquals("undo", r.undoable()!!.getString("before"))
|
||||
}
|
||||
|
||||
@Test fun aRestoreStoppedPartWayFinishesOnTheNextStart() {
|
||||
// Stopped at every step in turn, as a power cut would, then started again: it always ends with the backup in place.
|
||||
val steps = listOf("copied schedule", "moved schedule", "schedule", "copied arcade", "moved arcade", "arcade", "prefs/orbit_settings", "prefs/orbit_profiles")
|
||||
steps.forEach { at ->
|
||||
down(); up()
|
||||
receive(backupOfA(), other)
|
||||
val r = restorer(other, prefsB); r.prepare(5_000L, 1_000L, "Pixel")
|
||||
r.step = { if (it == at) throw PowerCut() }
|
||||
assertTrue(runCatching { r.finish(6_000L) }.exceptionOrNull() is PowerCut)
|
||||
assertTrue(r.pending())
|
||||
val again = restorer(other, prefsB)
|
||||
assertTrue(at, again.finish(7_000L)!!.optBoolean("ok"))
|
||||
assertTrue(at, File(schedule(other), "schedule-101.json").readText().contains("A's plan"))
|
||||
assertEquals(at, "{\"who\":\"A\"}", File(arcade(other), "household-records.json").readText())
|
||||
assertEquals(at, "Night-A", prefsB.files["orbit_settings"]!!["look"])
|
||||
assertFalse(at, File(schedule(other).parentFile, "schedule.replaced").exists()); assertFalse(File(schedule(other).parentFile, "schedule.restoring").exists())
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aRestoreThatKeepsFailingPutsTheOldDataBack() {
|
||||
receive(backupOfA(), other)
|
||||
val r = restorer(other, prefsB); r.prepare(5_000L, 1_000L, "Pixel")
|
||||
// Three starts that each stop part-way (a restore that crashes Orbit every time): the fourth puts things back.
|
||||
repeat(3) { val again = restorer(other, prefsB); again.step = { if (it == "arcade") throw PowerCut() }; runCatching { again.finish(6_000L + it) } }
|
||||
val outcome = restorer(other, prefsB).finish(9_000L)!!
|
||||
assertFalse(outcome.optBoolean("ok")); assertTrue(outcome.optBoolean("putBack"))
|
||||
assertTrue(File(schedule(other), "schedule-101.json").readText().contains("B's plan"))
|
||||
assertEquals("{\"who\":\"B\"}", File(arcade(other), "household-records.json").readText())
|
||||
assertEquals("Night-B", prefsB.files["orbit_settings"]!!["look"])
|
||||
assertFalse(r.pending())
|
||||
}
|
||||
|
||||
@Test fun aRestoreInterruptedBeforeItWasConfirmedChangesNothing() {
|
||||
receive(backupOfA(), other)
|
||||
// Keeping the data aside stopped part-way: a .part folder and no journal. The next start clears it and changes nothing.
|
||||
File(other, "no_backup/phone-restore/aside-5000.part/schedule").mkdirs()
|
||||
val r = restorer(other, prefsB)
|
||||
assertNull(r.finish(6_000L))
|
||||
assertFalse(File(other, "no_backup/phone-restore/aside-5000.part").exists())
|
||||
// The opened backup that was never confirmed doesn't stay on the TV either.
|
||||
assertFalse(r.incoming.exists())
|
||||
assertTrue(File(schedule(other), "schedule-101.json").readText().contains("B's plan"))
|
||||
assertNull(r.undoable())
|
||||
}
|
||||
|
||||
@Test fun onlyTheLastTwoCopiesAreKeptAside() {
|
||||
repeat(4) { i ->
|
||||
receive(backupOfA(), other)
|
||||
val r = restorer(other, prefsB); r.prepare(5_000L + i, 1_000L, "Pixel"); r.finish(6_000L + i)
|
||||
}
|
||||
assertEquals(listOf("aside-5002", "aside-5003"), File(other, "no_backup/phone-restore").list()!!.filter { it.startsWith("aside-") }.sorted())
|
||||
}
|
||||
|
||||
@Test fun theCodeShowsInFoursWithTheCursorInStep() {
|
||||
val t = CodeLook.filter(androidx.compose.ui.text.AnnotatedString("k7qm2xtr9h"))
|
||||
assertEquals("K7QM-2XTR-9H", t.text.text)
|
||||
for (o in 0..10) assertEquals(o, t.offsetMapping.transformedToOriginal(t.offsetMapping.originalToTransformed(o)))
|
||||
assertEquals(12, t.offsetMapping.originalToTransformed(10)); assertEquals(4, t.offsetMapping.originalToTransformed(4)); assertEquals(6, t.offsetMapping.originalToTransformed(5))
|
||||
assertEquals("K7QM2XTR9HFDW3PA", BackupCode.normalise(CodeLook.filter(androidx.compose.ui.text.AnnotatedString("k7qm2xtr9hfdw3pa")).text.text))
|
||||
}
|
||||
|
||||
@Test fun theBackupCodeReadsAndTypesWithoutMixUps() {
|
||||
val made = BackupCode.make(); assertEquals(16, made.length); assertEquals(made, BackupCode.normalise(BackupCode.shown(made).lowercase()))
|
||||
assertEquals("K7QM2XTR9HFDW3PA", BackupCode.normalise("k7qm-2xtr 9hfd-w3pa"))
|
||||
assertEquals("01100000000000000", BackupCode.normalise("OIL0-0000-0000-0000") + "0")
|
||||
assertNull(BackupCode.normalise("K7QM-2XTR-9HFD")); assertNull(BackupCode.normalise("K7QM-2XTR-9HFD-W3PU"))
|
||||
// One per TV, kept; a restored backup's code is adopted only by a TV without one.
|
||||
val nb = File(other, "nb").apply { mkdirs() }
|
||||
val (first, fresh) = BackupCode.ofThisTv(nb); assertTrue(fresh); assertEquals(first to false, BackupCode.ofThisTv(nb))
|
||||
BackupCode.adopt(nb, code); assertEquals(first, BackupCode.existing(nb))
|
||||
val nb2 = File(other, "nb2").apply { mkdirs() }; BackupCode.adopt(nb2, code); assertEquals(code, BackupCode.existing(nb2))
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,20 @@ class PhoneLinkTest {
|
||||
assertTrue(runCatching { call("/api/channels", cookie = cookie).body.contains("Enter the code") }.getOrDefault(true))
|
||||
}
|
||||
|
||||
@Test fun backupsAreOnlyForAJoinedPhoneAndOnlyItMaySendALargeFile() {
|
||||
// Not joined: the join page, whatever is asked, and a large upload is cut off at the usual size before it's read.
|
||||
assertTrue(call("/api/backup").body.contains("Enter the code"))
|
||||
assertTrue(call("/api/backup/upload", "POST", "x".repeat(200_000)).body.contains("Enter the code"))
|
||||
val p = PhoneLink.beginPairing()
|
||||
val cookie = call("/join", "POST", "code=${p.code}", form = true).cookie!!
|
||||
// Joined: a change still needs the header a cross-site page can't send; then the backup routes answer (here, with no
|
||||
// Android behind them, that Orbit is starting up).
|
||||
assertEquals(403, call("/api/backup/make", "POST", "{}", cookie = cookie, orbit = false).status)
|
||||
assertEquals(403, call("/api/backup/upload", "POST", "ORBIT-BACKUP 1", cookie = cookie, orbit = false).status)
|
||||
assertEquals(409, call("/api/backup", cookie = cookie).status)
|
||||
assertEquals(409, call("/api/backup/upload", "POST", "x".repeat(200_000), cookie = cookie).status)
|
||||
}
|
||||
|
||||
@Test fun guessingRunsOutAndThePinIsAskedWhenThereIsOne() {
|
||||
var now = System.currentTimeMillis(); PhoneLink.clock = { now }
|
||||
val p = PhoneLink.beginPairing()
|
||||
|
||||
Reference in New Issue
Block a user