fix(devices): keep the existing device name on re-pair and re-login

A dedupe-keyed client re-mint (QR rescan, password/passkey re-login) replaces
the stored record, which also reset the operator-visible name to the app's
hardcoded default ('OpenChamber Mobile'). The app-reported name is now only a
fallback: an explicit pairing label wins, otherwise the replaced record's
label is kept, and the default applies only to a first-ever pairing.
This commit is contained in:
Bohdan Triapitsyn
2026-08-24 14:03:18 +03:00
parent 5fa6f2c159
commit 3aa45805bc
6 changed files with 43 additions and 13 deletions
@@ -262,14 +262,15 @@ export const createClientPairingRuntime = ({
if (!constantTimeEqual(session.secretHash, hashSecret(normalizedSecret), crypto)) throw redeemError();
// The operator's typed pairing label is THIS server's name for the device
// (shown in the device list). It wins over the device's self-reported
// label; fall back to that only when no pairing label was set.
const label = normalizeOptionalString(session.label)
|| normalizeOptionalString(clientLabel)
|| normalizeOptionalString(deviceName)
|| 'Remote client';
// (shown in the device list) and wins outright. The device's self-reported
// label is only a fallback: on a re-pair with the same dedupeKey,
// createClient keeps the replaced record's label over it, so a rescan
// without a typed name does not reset the device to the app default.
const result = await remoteClientAuthRuntime.createClient({
label,
label: normalizeOptionalString(session.label),
fallbackLabel: normalizeOptionalString(clientLabel)
|| normalizeOptionalString(deviceName)
|| 'Remote client',
clientKind: normalizedKind,
dedupeKey: normalizeOptionalString(dedupeKey) || `pairing:${session.id}`,
authMethod: 'pairing',