feat(session): appareils de confiance, retour sans lien par clé Ed25519
CI / Formatting, tests and builds (push) Successful in 6m57s
CI / Formatting, tests and builds (push) Successful in 6m57s
Le viewer tire une clé Ed25519 gardée dans le localStorage de l'hôte et annonce sa clé publique dans le hello. Depuis l'interface, l'hôte fait confiance à un spectateur connecté; l'appareil revient ensuite, avec ou sans lien, en signant un nonce neuf à chaque connexion. La révocation le renvoie aussitôt avec not_trusted et lui fait oublier la confiance. La signature se fait en JavaScript (@noble/ed25519): le viewer servi en HTTP sur le LAN n'a pas crypto.subtle. Un vecteur de test commun garde le Rust et le TypeScript d'accord. Décision écrite dans l'ADR 0011. Refs #34 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e51864251
commit
8c36876989
41 files changed
+1422
-133
No files matched your search
@@ -14,7 +14,8 @@ dépendent pas d'un service en ligne.
|
||||
Ce qui tourne: capture Linux réelle (portail et PipeWire sous Wayland, X11 en repli, chaque
|
||||
moniteur RandR, une fenêtre seule), écran virtuel par le portail (GNOME 46, KDE), conversion BGRA
|
||||
vers I420, encodage VP8 ou VP9 temps réel qui suit les changements de résolution, session str0m par
|
||||
spectateur, serveur local avec jeton qui expire et code court, viewer React qui reprend seul après
|
||||
spectateur, serveur local avec jeton qui expire et code court, appareils de confiance qui reviennent sans lien
|
||||
par une clé Ed25519 (ADR 0011), viewer React qui reprend seul après
|
||||
une coupure ou une veille, tourne l'image et suit le thème, coque desktop Tauri avec icône de
|
||||
barre système, réglages persistants, interface en français et en anglais, inhibition de veille,
|
||||
journal JSON local et archive de diagnostics.
|
||||
@@ -191,7 +192,8 @@ Le journal JSON (`~/.local/state/rustscreen/logs`) nomme les étapes d'une sessi
|
||||
(avec `cause`), `capture_revoked`, `capture_failed`, `encode_failed`, et côté hôte `share_started`,
|
||||
`share_ended`, `share_interrupted`, `viewer_disconnected`, `resolution_changed`, `sleep_inhibited`,
|
||||
`sleep_released`, `wake_detected`, `capture_restarted`, `address_changed`, `settings_changed`,
|
||||
`access_regenerated`, `code_accepted`, `code_rejected`. Avant la 0.6, ces noms étaient en français
|
||||
`access_regenerated`, `code_accepted`, `code_rejected`, `trust_changed`, et côté serveur
|
||||
`trusted_device_admitted`. Avant la 0.6, ces noms étaient en français
|
||||
(champ `evenement`). Ne jamais y écrire un titre de fenêtre ni une image (ADR 0008).
|
||||
|
||||
Le spike historique `spikes/str0m-mire` reste pour comparer les mesures:
|
||||
|
||||
Generated
+78
-1
@@ -541,6 +541,32 @@ dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "5.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures 0.3.1",
|
||||
"curve25519-dalek-derive",
|
||||
"digest 0.11.3",
|
||||
"fiat-crypto",
|
||||
"rustc_version",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek-derive"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.11.1"
|
||||
@@ -630,7 +656,7 @@ dependencies = [
|
||||
"rand 0.9.5",
|
||||
"rcgen",
|
||||
"sec1",
|
||||
"signature",
|
||||
"signature 2.2.0",
|
||||
"spki",
|
||||
"subtle",
|
||||
"time",
|
||||
@@ -654,6 +680,27 @@ version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
|
||||
[[package]]
|
||||
name = "ed25519"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a"
|
||||
dependencies = [
|
||||
"signature 3.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519-dalek"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"ed25519",
|
||||
"sha2",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.19.0"
|
||||
@@ -706,6 +753,12 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fiat-crypto"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24"
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.15"
|
||||
@@ -1725,7 +1778,9 @@ name = "rs-session"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"ed25519-dalek",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"png",
|
||||
"rs-capture",
|
||||
"rs-codec",
|
||||
@@ -1750,6 +1805,7 @@ version = "0.5.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-server",
|
||||
"ed25519-dalek",
|
||||
"hex",
|
||||
"image",
|
||||
"qrcode",
|
||||
@@ -1787,6 +1843,15 @@ version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusticata-macros"
|
||||
version = "4.1.0"
|
||||
@@ -1883,6 +1948,12 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.229"
|
||||
@@ -2039,6 +2110,12 @@ version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.10"
|
||||
|
||||
Generated
+62
-1
@@ -858,6 +858,32 @@ dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "5.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures 0.3.1",
|
||||
"curve25519-dalek-derive",
|
||||
"digest 0.11.3",
|
||||
"fiat-crypto",
|
||||
"rustc_version",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek-derive"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.24.1"
|
||||
@@ -1047,7 +1073,7 @@ dependencies = [
|
||||
"rand 0.9.5",
|
||||
"rcgen",
|
||||
"sec1",
|
||||
"signature",
|
||||
"signature 2.2.0",
|
||||
"spki",
|
||||
"subtle",
|
||||
"time",
|
||||
@@ -1172,6 +1198,27 @@ version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
|
||||
|
||||
[[package]]
|
||||
name = "ed25519"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a"
|
||||
dependencies = [
|
||||
"signature 3.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519-dalek"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"ed25519",
|
||||
"sha2 0.11.1",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.19.0"
|
||||
@@ -1255,6 +1302,12 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fiat-crypto"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24"
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.6"
|
||||
@@ -3550,6 +3603,7 @@ version = "0.5.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-server",
|
||||
"ed25519-dalek",
|
||||
"hex",
|
||||
"qrcode",
|
||||
"rand 0.10.3",
|
||||
@@ -3564,6 +3618,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tower-http 0.7.1",
|
||||
"tracing",
|
||||
"ts-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4050,6 +4105,12 @@ version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.10"
|
||||
|
||||
@@ -81,6 +81,16 @@ fn regenerate_access(host: State<'_, Host>) -> bool {
|
||||
host.regenerate_access()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn trust_device(host: State<'_, Host>, connection: u64) -> Result<(), String> {
|
||||
host.trust_device(connection).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn revoke_device(host: State<'_, Host>, key: String) -> Result<(), String> {
|
||||
host.revoke_device(&key).await
|
||||
}
|
||||
|
||||
/// The texts of the system tray menu, in the language of the interface.
|
||||
#[tauri::command]
|
||||
fn translate_tray(
|
||||
@@ -251,6 +261,8 @@ fn main() {
|
||||
stop,
|
||||
disconnect,
|
||||
regenerate_access,
|
||||
trust_device,
|
||||
revoke_device,
|
||||
translate_tray,
|
||||
quit,
|
||||
settings,
|
||||
|
||||
@@ -139,6 +139,7 @@ function Shell({ host, onLanguage }: { host: Host; onLanguage: (code: string | n
|
||||
share={state.share}
|
||||
onDisconnect={(connection) => send(() => host.disconnect(connection))}
|
||||
onNewCode={() => send(() => host.regenerateAccess())}
|
||||
onTrust={(connection) => send(() => host.trustDevice(connection))}
|
||||
/>
|
||||
) : (
|
||||
<SourcePicker
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
/**
|
||||
* Why a connection was refused, as the host interface names it (#35).
|
||||
*/
|
||||
export type RefusalCause = "bad_token" | "token_used" | "expired_token" | "kicked" | "room_full";
|
||||
export type RefusalCause = "bad_token" | "token_used" | "expired_token" | "kicked" | "room_full" | "not_trusted";
|
||||
@@ -2,7 +2,18 @@
|
||||
import type { DeviceId } from "../../../viewer/src/proto/DeviceId";
|
||||
|
||||
/**
|
||||
* A device allowed to come back without scanning again (#34). The storage
|
||||
* exists already so that the format does not need a new version that day.
|
||||
* A device allowed to come back without scanning again (#34).
|
||||
*
|
||||
* The host keeps the public key only: the device proves it holds the private
|
||||
* one by signing a challenge, and the private key never leaves it.
|
||||
*/
|
||||
export type TrustedDevice = { id: DeviceId, name: string, };
|
||||
export type TrustedDevice = { id: DeviceId, name: string,
|
||||
/**
|
||||
* Ed25519 public key, 64 lowercase hex digits. Empty in a file written
|
||||
* before #34: such an entry lets nobody in.
|
||||
*/
|
||||
key: string,
|
||||
/**
|
||||
* When the host started trusting it, in milliseconds since the Unix epoch.
|
||||
*/
|
||||
added_ms: number, };
|
||||
@@ -11,4 +11,13 @@ connection: number, name: string, platform: string | null, address: string,
|
||||
/**
|
||||
* Arrival, in Unix milliseconds.
|
||||
*/
|
||||
since_ms: number, };
|
||||
since_ms: number,
|
||||
/**
|
||||
* The host trusts its key: it comes back without a link (#34).
|
||||
*/
|
||||
trusted: boolean,
|
||||
/**
|
||||
* It announced a key the host could trust. A browser without storage, or
|
||||
* too old to sign, has none.
|
||||
*/
|
||||
can_trust: boolean, };
|
||||
@@ -67,6 +67,21 @@ export function SettingsDialog({ host, autostart, onClose, onSaved }: Props) {
|
||||
}
|
||||
};
|
||||
|
||||
// Revoking acts at once, without waiting for "Save": a device must lose
|
||||
// its access within the second (#34).
|
||||
const revoke = async (key: string) => {
|
||||
try {
|
||||
await host.revokeDevice(key);
|
||||
setSettings({
|
||||
...settings,
|
||||
trusted_devices: settings.trusted_devices.filter((d) => d.key !== key),
|
||||
});
|
||||
setRejections((r) => r.filter((x) => x.field !== 'trusted_devices'));
|
||||
} catch (e) {
|
||||
setRejections([{ field: 'trusted_devices', message: String(e) }]);
|
||||
}
|
||||
};
|
||||
|
||||
const exportDiagnostics = async () => {
|
||||
try {
|
||||
setMessage({ type: 'diagnostics', path: await host.exportDiagnostics() });
|
||||
@@ -246,6 +261,34 @@ export function SettingsDialog({ host, autostart, onClose, onSaved }: Props) {
|
||||
{error('autostart') && <span className='field-error'>{error('autostart')}</span>}
|
||||
</label>
|
||||
)}
|
||||
<div className='field'>
|
||||
<span>{t('trustedDevices')}</span>
|
||||
{settings.trusted_devices.filter((d) => d.key).length === 0 ? (
|
||||
<span className='help'>{t('trustedNone')}</span>
|
||||
) : (
|
||||
<ul className='devices'>
|
||||
{settings.trusted_devices
|
||||
.filter((d) => d.key)
|
||||
.map((device) => (
|
||||
<li key={device.key}>
|
||||
<span className='device-name'>{device.name}</span>
|
||||
<span className='muted'>{device.key.slice(0, 16)}</span>
|
||||
<button
|
||||
type='button'
|
||||
className='button muted danger'
|
||||
title={t('revokeHelp')}
|
||||
onClick={() => revoke(device.key)}
|
||||
>
|
||||
{t('revoke')}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{error('trusted_devices') && (
|
||||
<span className='field-error'>{error('trusted_devices')}</span>
|
||||
)}
|
||||
</div>
|
||||
{error('file') && <p className='field-error'>{error('file')}</p>}
|
||||
{message && (
|
||||
<p className='confirmation' role='status'>
|
||||
|
||||
@@ -7,9 +7,10 @@ type Props = {
|
||||
share: Share;
|
||||
onDisconnect: (connection: number) => void;
|
||||
onNewCode: () => void;
|
||||
onTrust: (connection: number) => void;
|
||||
};
|
||||
|
||||
export function SharePanel({ share, onDisconnect, onNewCode }: Props) {
|
||||
export function SharePanel({ share, onDisconnect, onNewCode, onTrust }: Props) {
|
||||
const { t } = useI18n();
|
||||
const now = useNow();
|
||||
const [copied, setCopied] = useState(false);
|
||||
@@ -108,20 +109,35 @@ export function SharePanel({ share, onDisconnect, onNewCode }: Props) {
|
||||
<ul className='devices'>
|
||||
{share.devices.map((device) => (
|
||||
<li key={device.connection}>
|
||||
<span className='device-name'>{device.name}</span>
|
||||
<span className='device-name'>
|
||||
{device.name}
|
||||
{device.trusted && <span className='trusted-mark'>{t('trusted')}</span>}
|
||||
</span>
|
||||
<span className='muted'>
|
||||
{[device.platform, device.address].filter(Boolean).join(' · ')}
|
||||
{' · '}
|
||||
{duration(device.since_ms, now)}
|
||||
</span>
|
||||
<button
|
||||
type='button'
|
||||
className='button muted danger'
|
||||
title={t('disconnectHelp')}
|
||||
onClick={() => onDisconnect(device.connection)}
|
||||
>
|
||||
{t('disconnect')}
|
||||
</button>
|
||||
<span className='device-actions'>
|
||||
{device.can_trust && (
|
||||
<button
|
||||
type='button'
|
||||
className='button muted'
|
||||
title={t('trustHelp')}
|
||||
onClick={() => onTrust(device.connection)}
|
||||
>
|
||||
{t('trust')}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type='button'
|
||||
className='button muted danger'
|
||||
title={t('disconnectHelp')}
|
||||
onClick={() => onDisconnect(device.connection)}
|
||||
>
|
||||
{t('disconnect')}
|
||||
</button>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -23,6 +23,10 @@ export type Host = {
|
||||
disconnect(connection: number): Promise<boolean>;
|
||||
/** New QR code and new short code (#19). */
|
||||
regenerateAccess(): Promise<boolean>;
|
||||
/** Trusts the device on this connection: it comes back without a link (#34). */
|
||||
trustDevice(connection: number): Promise<void>;
|
||||
/** Stops trusting a key; a device connected with it is sent away. */
|
||||
revokeDevice(key: string): Promise<void>;
|
||||
settings(): Promise<Settings>;
|
||||
/** Rejects with the list of refused values. */
|
||||
updateSettings(settings: Settings): Promise<SettingsOutcome>;
|
||||
@@ -44,6 +48,8 @@ export const tauriHost: Host = {
|
||||
stop: () => invoke<void>('stop'),
|
||||
disconnect: (connection) => invoke<boolean>('disconnect', { connection }),
|
||||
regenerateAccess: () => invoke<boolean>('regenerate_access'),
|
||||
trustDevice: (connection) => invoke<void>('trust_device', { connection }),
|
||||
revokeDevice: (key) => invoke<void>('revoke_device', { key }),
|
||||
settings: () => invoke<Settings>('settings'),
|
||||
updateSettings: (settings) => invoke<SettingsOutcome>('update_settings', { settings }),
|
||||
interfaces: () => invoke<InterfaceOption[]>('interfaces'),
|
||||
|
||||
@@ -455,10 +455,24 @@ h2 {
|
||||
grid-row: 1 / span 2;
|
||||
}
|
||||
|
||||
.devices li .device-actions {
|
||||
grid-column: 2;
|
||||
grid-row: 1 / span 2;
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.trusted-mark {
|
||||
margin-left: 0.5rem;
|
||||
color: var(--live);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
|
||||
Generated
+21
-42
@@ -8,6 +8,8 @@
|
||||
"name": "@rustscreen/viewer",
|
||||
"version": "0.5.0",
|
||||
"dependencies": {
|
||||
"@noble/ed25519": "^3.2.0",
|
||||
"@noble/hashes": "^2.4.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0"
|
||||
},
|
||||
@@ -126,9 +128,6 @@
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -146,9 +145,6 @@
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -166,9 +162,6 @@
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -186,9 +179,6 @@
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -260,6 +250,25 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@noble/ed25519": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-3.2.0.tgz",
|
||||
"integrity": "sha512-criDgRlnUA09hchYrTy/JUWPIEap5rZxQe6wDWzRx51oWWpDRcUpuNzlgPxDJaOK6AsW9c0wKcj3rKRv6t+bPQ==",
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/@noble/hashes": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz",
|
||||
"integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==",
|
||||
"engines": {
|
||||
"node": ">= 20.19.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/@oxc-project/types": {
|
||||
"version": "0.155.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.155.0.tgz",
|
||||
@@ -380,9 +389,6 @@
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -400,9 +406,6 @@
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -420,9 +423,6 @@
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -440,9 +440,6 @@
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -460,9 +457,6 @@
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -480,9 +474,6 @@
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -1243,9 +1234,6 @@
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -1267,9 +1255,6 @@
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -1291,9 +1276,6 @@
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -1315,9 +1297,6 @@
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@noble/ed25519": "^3.2.0",
|
||||
"@noble/hashes": "^2.4.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0"
|
||||
},
|
||||
|
||||
+27
-12
@@ -19,6 +19,7 @@ import {
|
||||
} from './lib/rotation';
|
||||
import { type VideoStats, ViewerSession, type ViewerState } from './lib/session';
|
||||
import { applyTheme, nextTheme, readTheme, saveTheme, type Theme } from './lib/theme';
|
||||
import { isTrusted } from './lib/trust';
|
||||
import { useActivity } from './lib/useActivity';
|
||||
|
||||
export function App() {
|
||||
@@ -27,6 +28,12 @@ export function App() {
|
||||
() => parseRoomLocation(window.location.pathname, window.location.search, window.location.hash),
|
||||
[],
|
||||
);
|
||||
// A device the host trusts comes back from the bare home page, without a
|
||||
// link: it proves its key instead (#34).
|
||||
const byKey = useMemo(
|
||||
() => !location.ok && location.reason === 'missing_room' && isTrusted(),
|
||||
[location],
|
||||
);
|
||||
const [state, setState] = useState<ViewerState>({ kind: 'connecting', attempt: 0 });
|
||||
const [stream, setStream] = useState<MediaStream | null>(null);
|
||||
const [stats, setStats] = useState<VideoStats | null>(null);
|
||||
@@ -45,10 +52,10 @@ export function App() {
|
||||
// mount of StrictMode opens two WebSockets and two negotiations.
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: attemptKey is the restart key of the "retry" button, deliberately unused in the body.
|
||||
useEffect(() => {
|
||||
if (!location.ok) return;
|
||||
if (!location.ok && !byKey) return;
|
||||
const session = new ViewerSession({
|
||||
room: location.value.room,
|
||||
token: location.value.token,
|
||||
room: location.ok ? location.value.room : null,
|
||||
token: location.ok ? location.value.token : null,
|
||||
wsUrl: signalingUrl(window.location),
|
||||
onState: setState,
|
||||
onStream: setStream,
|
||||
@@ -59,7 +66,7 @@ export function App() {
|
||||
session.stop();
|
||||
sessionRef.current = null;
|
||||
};
|
||||
}, [location, attemptKey]);
|
||||
}, [location, byKey, attemptKey]);
|
||||
|
||||
useEffect(() => {
|
||||
if (state.kind !== 'streaming') {
|
||||
@@ -135,15 +142,18 @@ export function App() {
|
||||
setAttemptKey((key) => key + 1);
|
||||
}, []);
|
||||
|
||||
if (!location.ok) {
|
||||
const untrusted = state.kind === 'failed' && state.code === 'not_trusted';
|
||||
if (!location.ok && (!byKey || untrusted)) {
|
||||
// Without a session in the address, offer the short code (#19). The bare
|
||||
// home page is not an error: it is the way in without a camera.
|
||||
const notice = {
|
||||
missing_room: null,
|
||||
missing_token: t('missingToken'),
|
||||
malformed: t('missingUrl'),
|
||||
newer_link: t('newerLink'),
|
||||
}[location.reason];
|
||||
const notice = untrusted
|
||||
? t('errors.not_trusted')
|
||||
: {
|
||||
missing_room: null,
|
||||
missing_token: t('missingToken'),
|
||||
malformed: t('missingUrl'),
|
||||
newer_link: t('newerLink'),
|
||||
}[location.reason];
|
||||
return <Pairing notice={notice} />;
|
||||
}
|
||||
|
||||
@@ -179,11 +189,16 @@ export function App() {
|
||||
<header className='topbar' {...hold}>
|
||||
<span className='brand'>{t('appName')}</span>
|
||||
<StatusBadge state={state} />
|
||||
{location.value.fingerprint && (
|
||||
{location.ok && location.value.fingerprint && (
|
||||
<span className='badge' title={`${t('fingerprint')}: ${location.value.fingerprint}`}>
|
||||
{location.value.fingerprint.slice(0, 11)}
|
||||
</span>
|
||||
)}
|
||||
{live && isTrusted() && (
|
||||
<span className='badge' title={t('trustedHint')}>
|
||||
{t('trustedBadge')}
|
||||
</span>
|
||||
)}
|
||||
{insecure && (
|
||||
<span className='badge badge-warn' title={t('insecureHint')}>
|
||||
{t('insecureBadge')}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { ViewerSession, type ViewerState } from './session';
|
||||
import { fromSecret, isTrusted, rememberTrust } from './trust';
|
||||
|
||||
/** WebSocket that opens, records what is sent, and lets the test answer. */
|
||||
class ScriptedWebSocket {
|
||||
static readonly OPEN = 1;
|
||||
static readonly CLOSING = 2;
|
||||
static readonly CLOSED = 3;
|
||||
static last: ScriptedWebSocket | null = null;
|
||||
|
||||
readyState = 0;
|
||||
sent: Array<Record<string, unknown>> = [];
|
||||
private listeners = new Map<string, Array<(event: unknown) => void>>();
|
||||
|
||||
constructor(public readonly url: string) {
|
||||
ScriptedWebSocket.last = this;
|
||||
queueMicrotask(() => {
|
||||
this.readyState = ScriptedWebSocket.OPEN;
|
||||
this.emit('open', {});
|
||||
});
|
||||
}
|
||||
|
||||
addEventListener(type: string, listener: (event: unknown) => void): void {
|
||||
const list = this.listeners.get(type) ?? [];
|
||||
list.push(listener);
|
||||
this.listeners.set(type, list);
|
||||
}
|
||||
|
||||
send(data: string): void {
|
||||
this.sent.push(JSON.parse(data));
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.readyState = ScriptedWebSocket.CLOSED;
|
||||
}
|
||||
|
||||
answer(message: Record<string, unknown>): void {
|
||||
this.emit('message', { data: JSON.stringify(message) });
|
||||
}
|
||||
|
||||
private emit(type: string, event: unknown): void {
|
||||
for (const listener of this.listeners.get(type) ?? []) listener(event);
|
||||
}
|
||||
}
|
||||
|
||||
class StubPeerConnection {
|
||||
close(): void {}
|
||||
}
|
||||
|
||||
const SECRET = '9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60';
|
||||
const NONCE = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f';
|
||||
|
||||
function memoryStorage() {
|
||||
const map = new Map<string, string>();
|
||||
return {
|
||||
getItem: (k: string) => map.get(k) ?? null,
|
||||
setItem: (k: string, v: string) => void map.set(k, v),
|
||||
removeItem: (k: string) => void map.delete(k),
|
||||
};
|
||||
}
|
||||
|
||||
describe('coming back by key (#34)', () => {
|
||||
let storage: ReturnType<typeof memoryStorage>;
|
||||
|
||||
beforeEach(() => {
|
||||
storage = memoryStorage();
|
||||
vi.stubGlobal('WebSocket', ScriptedWebSocket);
|
||||
vi.stubGlobal('RTCPeerConnection', StubPeerConnection);
|
||||
vi.stubGlobal('window', { localStorage: storage });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
function session(states: ViewerState[]) {
|
||||
return new ViewerSession({
|
||||
room: null,
|
||||
token: null,
|
||||
key: fromSecret(SECRET),
|
||||
wsUrl: 'ws://127.0.0.1:1/ws',
|
||||
watchLifecycle: false,
|
||||
onState: (state) => states.push(state),
|
||||
onStream: () => undefined,
|
||||
});
|
||||
}
|
||||
|
||||
it('announces its public key without a link, then signs the challenge', async () => {
|
||||
const viewer = session([]);
|
||||
viewer.start();
|
||||
await Promise.resolve();
|
||||
const ws = ScriptedWebSocket.last;
|
||||
expect(ws?.sent[0]).toMatchObject({
|
||||
type: 'hello',
|
||||
room: null,
|
||||
token: null,
|
||||
key: fromSecret(SECRET).publicKey,
|
||||
});
|
||||
ws?.answer({ type: 'challenge', nonce: NONCE });
|
||||
await Promise.resolve();
|
||||
expect(ws?.sent[1]).toEqual({ type: 'proof', signature: fromSecret(SECRET).sign(NONCE) });
|
||||
viewer.stop();
|
||||
});
|
||||
|
||||
it('forgets the trust when the host refuses the key', async () => {
|
||||
rememberTrust(true, storage);
|
||||
const states: ViewerState[] = [];
|
||||
const viewer = session(states);
|
||||
viewer.start();
|
||||
await Promise.resolve();
|
||||
ScriptedWebSocket.last?.answer({ type: 'error', code: 'not_trusted', message: '' });
|
||||
await Promise.resolve();
|
||||
expect(isTrusted(storage)).toBe(false);
|
||||
expect(states.at(-1)).toEqual({ kind: 'failed', code: 'not_trusted' });
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ import type { ClientMessage, DeviceInfo, ServerMessage, StreamSettings } from '.
|
||||
import type { Translate } from './i18n';
|
||||
import { deviceId } from './device';
|
||||
import { type WakeReason, watchLifecycle } from './lifecycle';
|
||||
import { type DeviceKey, deviceKey, rememberTrust } from './trust';
|
||||
|
||||
export type ViewerErrorCode =
|
||||
| 'bad_token'
|
||||
@@ -24,6 +25,8 @@ export type ViewerErrorCode =
|
||||
| 'internal'
|
||||
| 'kicked'
|
||||
| 'share_ended'
|
||||
/** Came back by its key, and the host does not (or no longer) trust it (#34). */
|
||||
| 'not_trusted'
|
||||
| 'network'
|
||||
| 'unsupported';
|
||||
|
||||
@@ -36,8 +39,11 @@ export type ViewerState =
|
||||
| { kind: 'ended'; reason: string };
|
||||
|
||||
export type SessionOptions = {
|
||||
room: string;
|
||||
token: string;
|
||||
/** The link's room and token; both `null` for a trusted device without a link (#34). */
|
||||
room: string | null;
|
||||
token: string | null;
|
||||
/** Key of this device; by default the one kept by the browser, drawn if needed. */
|
||||
key?: DeviceKey | null;
|
||||
wsUrl: string;
|
||||
deviceName?: string;
|
||||
maxAttempts?: number;
|
||||
@@ -61,6 +67,7 @@ const TERMINAL_CODES: ReadonlySet<string> = new Set([
|
||||
'room_full',
|
||||
'kicked',
|
||||
'share_ended',
|
||||
'not_trusted',
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -108,6 +115,7 @@ export class ViewerSession {
|
||||
private pc: RTCPeerConnection | null = null;
|
||||
private retryTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
private attempt = 0;
|
||||
private readonly key: DeviceKey | null;
|
||||
/** Final stop: unmount, refusal on principle, end of session. */
|
||||
private stopped = false;
|
||||
/**
|
||||
@@ -125,6 +133,7 @@ export class ViewerSession {
|
||||
constructor(private readonly options: SessionOptions) {
|
||||
this.maxAttempts = options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
||||
this.quality = options.quality ?? null;
|
||||
this.key = options.key === undefined ? deviceKey() : options.key;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
@@ -288,6 +297,7 @@ export class ViewerSession {
|
||||
room: this.options.room,
|
||||
token: this.options.token,
|
||||
device,
|
||||
key: this.key?.publicKey ?? null,
|
||||
} as ClientMessage;
|
||||
}
|
||||
|
||||
@@ -302,7 +312,21 @@ export class ViewerSession {
|
||||
}
|
||||
|
||||
switch (message.type) {
|
||||
case 'challenge': {
|
||||
// The host trusts this key: prove it is here (#34).
|
||||
const signature = this.key?.sign(message.nonce);
|
||||
if (!signature) {
|
||||
this.fail('protocol_violation');
|
||||
return;
|
||||
}
|
||||
this.send({ type: 'proof', signature } as ClientMessage);
|
||||
break;
|
||||
}
|
||||
case 'trust':
|
||||
rememberTrust(message.trusted);
|
||||
break;
|
||||
case 'welcome':
|
||||
rememberTrust(message.trusted);
|
||||
// The chosen quality survives resumes: the host starts again from
|
||||
// its default setting at every session, so it is asked again.
|
||||
if (this.quality) {
|
||||
@@ -319,6 +343,7 @@ export class ViewerSession {
|
||||
}
|
||||
break;
|
||||
case 'error':
|
||||
if (message.code === 'not_trusted') rememberTrust(false);
|
||||
if (isTerminal(message.code)) {
|
||||
this.fail(message.code as ViewerErrorCode);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { deviceKey, fromSecret, isTrusted, rememberTrust } from './trust';
|
||||
|
||||
/** `rs_proto::trust::TEST_VECTOR`: the host checks the same four values. */
|
||||
const VECTOR = {
|
||||
secret: '9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60',
|
||||
publicKey: 'd75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a',
|
||||
nonce: '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
signature:
|
||||
'76d5c3961e096b67f6932039110292bb727a9475552afe48961c0073c653001e8fba219441d9795a9aa721224353aa589049d2d1050e0f37ce32b7953ea86f0e',
|
||||
};
|
||||
|
||||
function memory(): Map<string, string> & Storage {
|
||||
const map = new Map<string, string>();
|
||||
return Object.assign(map, {
|
||||
getItem: (k: string) => map.get(k) ?? null,
|
||||
setItem: (k: string, v: string) => void map.set(k, v),
|
||||
removeItem: (k: string) => void map.delete(k),
|
||||
}) as unknown as Map<string, string> & Storage;
|
||||
}
|
||||
|
||||
describe('device key', () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it('signs exactly what the host checks', () => {
|
||||
const key = fromSecret(VECTOR.secret);
|
||||
expect(key.publicKey).toBe(VECTOR.publicKey);
|
||||
expect(key.sign(VECTOR.nonce)).toBe(VECTOR.signature);
|
||||
});
|
||||
|
||||
it('refuses to sign a malformed nonce', () => {
|
||||
expect(fromSecret(VECTOR.secret).sign('zz')).toBeNull();
|
||||
});
|
||||
|
||||
it('is drawn once and kept', () => {
|
||||
const storage = memory();
|
||||
const first = deviceKey(storage);
|
||||
const second = deviceKey(storage);
|
||||
expect(first?.publicKey).toMatch(/^[0-9a-f]{64}$/);
|
||||
expect(second?.publicKey).toBe(first?.publicKey);
|
||||
});
|
||||
|
||||
it('works without crypto.subtle, as on a page served over HTTP on the LAN', () => {
|
||||
const random = globalThis.crypto.getRandomValues.bind(globalThis.crypto);
|
||||
vi.stubGlobal('crypto', { getRandomValues: random });
|
||||
expect(globalThis.crypto.subtle).toBeUndefined();
|
||||
const key = deviceKey(memory());
|
||||
expect(key?.sign(VECTOR.nonce)).toMatch(/^[0-9a-f]{128}$/);
|
||||
});
|
||||
|
||||
it('is absent when the browser keeps nothing', () => {
|
||||
expect(deviceKey(null)).toBeNull();
|
||||
const forgetful = {
|
||||
getItem: () => null,
|
||||
setItem: () => undefined,
|
||||
removeItem: () => undefined,
|
||||
};
|
||||
expect(deviceKey(forgetful)).toBeNull();
|
||||
});
|
||||
|
||||
it('remembers what the host said', () => {
|
||||
const storage = memory();
|
||||
expect(isTrusted(storage)).toBe(false);
|
||||
rememberTrust(true, storage);
|
||||
expect(isTrusted(storage)).toBe(true);
|
||||
rememberTrust(false, storage);
|
||||
expect(isTrusted(storage)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* The key of this device, to come back without a link once the host trusts
|
||||
* it (#34).
|
||||
*
|
||||
* The page is served over HTTP on the LAN, which is not a secure context:
|
||||
* `crypto.subtle` does not exist there, `crypto.getRandomValues()` does. The
|
||||
* Ed25519 signature is therefore done in JavaScript (`@noble/ed25519`,
|
||||
* bundled, no network), and the private key lives in `localStorage` for this
|
||||
* origin. It is never sent, never logged: the host receives the public key
|
||||
* and signatures only.
|
||||
*
|
||||
* What is signed is fixed here, not chosen by the host: the context
|
||||
* `rustscreen-trust-v1`, a zero byte, then the nonce of the challenge. It
|
||||
* mirrors `rs_proto::trust`, and both test suites check the same vector.
|
||||
*/
|
||||
import * as ed from '@noble/ed25519';
|
||||
import { sha512 } from '@noble/hashes/sha2.js';
|
||||
|
||||
import { browserStorage, type KeyValueStore } from './storage';
|
||||
|
||||
ed.hashes.sha512 = sha512;
|
||||
|
||||
const SECRET_KEY = 'rustscreen.key';
|
||||
/** Set once the host said it trusts this device: the home page then connects. */
|
||||
const TRUSTED_KEY = 'rustscreen.trusted';
|
||||
const CONTEXT = new TextEncoder().encode('rustscreen-trust-v1');
|
||||
const HEX_32 = /^[0-9a-f]{64}$/;
|
||||
|
||||
export type DeviceKey = {
|
||||
/** Public key, 64 hex digits: what the host keeps. */
|
||||
publicKey: string;
|
||||
/** Signs the nonce of a challenge (64 hex digits), or `null` if malformed. */
|
||||
sign(nonce: string): string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* The key of this device, drawn on first use. `null` when the browser cannot
|
||||
* keep it (storage denied, or a browser too old for the signature code): the
|
||||
* device then goes through the link every time, as before #34.
|
||||
*/
|
||||
export function deviceKey(storage: KeyValueStore | null = browserStorage()): DeviceKey | null {
|
||||
if (!storage) return null;
|
||||
try {
|
||||
let secret = storage.getItem(SECRET_KEY);
|
||||
if (!secret || !HEX_32.test(secret)) {
|
||||
secret = toHex(ed.utils.randomSecretKey());
|
||||
storage.setItem(SECRET_KEY, secret);
|
||||
// Read back: a storage that accepts and forgets would draw a new
|
||||
// key on each visit, which the host could never trust.
|
||||
if (storage.getItem(SECRET_KEY) !== secret) return null;
|
||||
}
|
||||
return fromSecret(secret);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The key for a known secret: exported for the shared test vector. */
|
||||
export function fromSecret(secretHex: string): DeviceKey {
|
||||
const secret = fromHex(secretHex);
|
||||
return {
|
||||
publicKey: toHex(ed.getPublicKey(secret)),
|
||||
sign(nonce: string) {
|
||||
if (!HEX_32.test(nonce)) return null;
|
||||
const message = new Uint8Array(CONTEXT.length + 1 + 32);
|
||||
message.set(CONTEXT, 0);
|
||||
message.set(fromHex(nonce), CONTEXT.length + 1);
|
||||
return toHex(ed.sign(message, secret));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Did the host say, last time, that it trusts this device? */
|
||||
export function isTrusted(storage: KeyValueStore | null = browserStorage()): boolean {
|
||||
try {
|
||||
return storage?.getItem(TRUSTED_KEY) === '1';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Remembers what the host said, from the `welcome` or a `not_trusted`. */
|
||||
export function rememberTrust(trusted: boolean, storage: KeyValueStore | null = browserStorage()) {
|
||||
try {
|
||||
if (trusted) storage?.setItem(TRUSTED_KEY, '1');
|
||||
else storage?.removeItem(TRUSTED_KEY);
|
||||
} catch {
|
||||
// Storage denied: the home page will offer the code, as before.
|
||||
}
|
||||
}
|
||||
|
||||
function toHex(bytes: Uint8Array): string {
|
||||
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
||||
}
|
||||
|
||||
function fromHex(hex: string): Uint8Array {
|
||||
const bytes = new Uint8Array(hex.length / 2);
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
@@ -7,4 +7,8 @@ import type { StreamSettings } from "./StreamSettings";
|
||||
/**
|
||||
* What the viewer sends to the host.
|
||||
*/
|
||||
export type ClientMessage = { "type": "hello", version: number, room: RoomId, token: SessionToken, device: DeviceInfo, } | { "type": "offer", sdp: string, } | { "type": "ice_candidate", candidate: string, sdp_mid: string | null, sdp_mline_index: number | null, } | { "type": "quality_request", settings: StreamSettings, } | { "type": "bye" };
|
||||
export type ClientMessage = { "type": "hello", version: number, room: RoomId | null, token: SessionToken | null, device: DeviceInfo,
|
||||
/**
|
||||
* Ed25519 public key of the device, 64 hex digits. Never the private key.
|
||||
*/
|
||||
key: string | null, } | { "type": "proof", signature: string, } | { "type": "offer", sdp: string, } | { "type": "ice_candidate", candidate: string, sdp_mid: string | null, sdp_mline_index: number | null, } | { "type": "quality_request", settings: StreamSettings, } | { "type": "bye" };
|
||||
@@ -1,3 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type ErrorCode = "bad_version" | "bad_token" | "token_expired" | "token_used" | "room_full" | "source_unavailable" | "protocol_violation" | "internal" | "kicked" | "share_ended";
|
||||
export type ErrorCode = "bad_version" | "bad_token" | "token_expired" | "token_used" | "room_full" | "source_unavailable" | "protocol_violation" | "internal" | "kicked" | "share_ended" | "not_trusted";
|
||||
@@ -11,4 +11,8 @@ export type ServerMessage = { "type": "welcome", version: number, room: RoomId,
|
||||
/**
|
||||
* Number of viewers already connected, and the limit.
|
||||
*/
|
||||
connected: number, limit: number, } | { "type": "answer", sdp: string, } | { "type": "ice_candidate", candidate: string, sdp_mid: string | null, sdp_mline_index: number | null, } | { "type": "source_changed", source: SourceInfo, } | { "type": "settings_applied", settings: StreamSettings, } | { "type": "error", code: ErrorCode, message: string, } | { "type": "bye", reason: string, };
|
||||
connected: number, limit: number,
|
||||
/**
|
||||
* The device got in by its key: it may come back without a link (#34).
|
||||
*/
|
||||
trusted: boolean, } | { "type": "challenge", nonce: string, } | { "type": "trust", trusted: boolean, } | { "type": "answer", sdp: string, } | { "type": "ice_candidate", candidate: string, sdp_mid: string | null, sdp_mline_index: number | null, } | { "type": "source_changed", source: SourceInfo, } | { "type": "settings_applied", settings: StreamSettings, } | { "type": "error", code: ErrorCode, message: string, } | { "type": "bye", reason: string, };
|
||||
@@ -6,6 +6,7 @@
|
||||
pub mod messages;
|
||||
pub mod pairing;
|
||||
pub mod session;
|
||||
pub mod trust;
|
||||
|
||||
pub use messages::{ClientMessage, ErrorCode, ServerMessage};
|
||||
pub use pairing::{LINK_VERSION, PairingRequest, PairingResponse, normalize_code};
|
||||
|
||||
@@ -31,6 +31,10 @@ pub enum ErrorCode {
|
||||
Kicked,
|
||||
/// The host stopped sharing: the room no longer exists.
|
||||
ShareEnded,
|
||||
/// The device came back by its key, but the host does not trust it (or no
|
||||
/// longer does), or the signature did not match (#34). The viewer forgets
|
||||
/// that it was trusted and asks for the QR code again.
|
||||
NotTrusted,
|
||||
}
|
||||
|
||||
/// What the viewer sends to the host.
|
||||
@@ -39,12 +43,25 @@ pub enum ErrorCode {
|
||||
#[ts(export)]
|
||||
pub enum ClientMessage {
|
||||
/// First message: the version decides what follows, the token authorizes.
|
||||
///
|
||||
/// A device the host trusts (#34) may come without a room nor a token: it
|
||||
/// carries its public key, the host answers with a [`ServerMessage::Challenge`]
|
||||
/// and the device proves it holds the private key. A device the host does
|
||||
/// not trust goes through the token, key or not.
|
||||
Hello {
|
||||
version: u16,
|
||||
room: RoomId,
|
||||
token: SessionToken,
|
||||
#[serde(default)]
|
||||
room: Option<RoomId>,
|
||||
#[serde(default)]
|
||||
token: Option<SessionToken>,
|
||||
device: DeviceInfo,
|
||||
/// Ed25519 public key of the device, 64 hex digits. Never the private key.
|
||||
#[serde(default)]
|
||||
key: Option<String>,
|
||||
},
|
||||
/// Answer to [`ServerMessage::Challenge`]: the Ed25519 signature, 128 hex
|
||||
/// digits, of [`crate::trust::signed_message`] for the nonce received.
|
||||
Proof { signature: String },
|
||||
/// The viewer's SDP offer: one receive-only video track.
|
||||
///
|
||||
/// The browser offers, the host answers. This choice comes from the spike:
|
||||
@@ -76,6 +93,18 @@ pub enum ServerMessage {
|
||||
/// Number of viewers already connected, and the limit.
|
||||
connected: u8,
|
||||
limit: u8,
|
||||
/// The device got in by its key: it may come back without a link (#34).
|
||||
trusted: bool,
|
||||
},
|
||||
/// The host trusts the key of the `hello`: sign this nonce (64 hex digits,
|
||||
/// fresh for each connection) to prove the private key is here (#34).
|
||||
Challenge {
|
||||
nonce: String,
|
||||
},
|
||||
/// The host started or stopped trusting this device during the session:
|
||||
/// the viewer remembers it, to come back without a link or to stop trying.
|
||||
Trust {
|
||||
trusted: bool,
|
||||
},
|
||||
/// The host's answer to the viewer's offer.
|
||||
Answer {
|
||||
@@ -121,9 +150,10 @@ mod tests {
|
||||
fn hello_round_trips_through_json() {
|
||||
let msg = ClientMessage::Hello {
|
||||
version: crate::PROTOCOL_VERSION,
|
||||
room: RoomId::parse("abc234").unwrap(),
|
||||
token: SessionToken::new("00112233445566778899aabbccddeeff"),
|
||||
room: Some(RoomId::parse("abc234").unwrap()),
|
||||
token: Some(SessionToken::new("00112233445566778899aabbccddeeff")),
|
||||
device: device(),
|
||||
key: None,
|
||||
};
|
||||
let json = serde_json::to_string(&msg).unwrap();
|
||||
assert!(json.contains("\"type\":\"hello\""), "{json}");
|
||||
@@ -140,12 +170,26 @@ mod tests {
|
||||
settings: StreamSettings::for_preset(crate::session::QualityPreset::Balanced),
|
||||
connected: 1,
|
||||
limit: 5,
|
||||
trusted: false,
|
||||
};
|
||||
let json = serde_json::to_string(&msg).unwrap();
|
||||
assert!(json.contains("\"type\":\"welcome\""), "{json}");
|
||||
assert!(json.contains("\"quality\":\"balanced\""), "{json}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hello_from_an_older_viewer_still_reads() {
|
||||
// Before #34: no key, room and token always present.
|
||||
let json = r#"{"type":"hello","version":1,"room":"abc234","token":"00112233445566778899aabbccddeeff","device":{"id":"d","name":"","user_agent":null,"platform":null}}"#;
|
||||
match serde_json::from_str::<ClientMessage>(json).unwrap() {
|
||||
ClientMessage::Hello { room, key, .. } => {
|
||||
assert!(room.is_some());
|
||||
assert!(key.is_none());
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_message_is_rejected_explicitly() {
|
||||
let err = serde_json::from_str::<ClientMessage>("{\"type\":\"teleport\"}").unwrap_err();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//! What a trusted device signs to come back without a link (#34).
|
||||
//!
|
||||
//! The host sends a fresh 32-byte nonce, the device signs the bytes below with
|
||||
//! its Ed25519 key. The context prefix is fixed on both sides, never sent by
|
||||
//! the host: a device does not sign whatever it is handed, so its key cannot
|
||||
//! be turned into a signing oracle for something else. The viewer writes the
|
||||
//! same prefix in `apps/viewer/src/lib/trust.ts`, and both test suites check
|
||||
//! the same vector (`TEST_VECTOR`).
|
||||
|
||||
/// Domain separation: names the protocol and its version.
|
||||
pub const TRUST_CONTEXT: &str = "rustscreen-trust-v1";
|
||||
|
||||
/// Length of the nonce, in bytes.
|
||||
pub const NONCE_LEN: usize = 32;
|
||||
|
||||
/// The bytes signed for a nonce: the context, a zero byte, the nonce.
|
||||
pub fn signed_message(nonce: &[u8; NONCE_LEN]) -> Vec<u8> {
|
||||
let mut message = Vec::with_capacity(TRUST_CONTEXT.len() + 1 + NONCE_LEN);
|
||||
message.extend_from_slice(TRUST_CONTEXT.as_bytes());
|
||||
message.push(0);
|
||||
message.extend_from_slice(nonce);
|
||||
message
|
||||
}
|
||||
|
||||
/// Shared test vector, in hex: secret key (seed), public key, nonce, signature.
|
||||
/// The viewer's tests check the same four values.
|
||||
pub const TEST_VECTOR: [&str; 4] = [
|
||||
"9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60",
|
||||
"d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a",
|
||||
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
||||
"76d5c3961e096b67f6932039110292bb727a9475552afe48961c0073c653001e8fba219441d9795a9aa721224353aa589049d2d1050e0f37ce32b7953ea86f0e",
|
||||
];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_message_starts_with_the_context_and_ends_with_the_nonce() {
|
||||
let nonce = [7u8; NONCE_LEN];
|
||||
let message = signed_message(&nonce);
|
||||
assert!(message.starts_with(b"rustscreen-trust-v1\0"));
|
||||
assert!(message.ends_with(&nonce));
|
||||
assert_eq!(message.len(), TRUST_CONTEXT.len() + 1 + NONCE_LEN);
|
||||
}
|
||||
}
|
||||
@@ -32,3 +32,5 @@ ts-rs = "12.0.1"
|
||||
[dev-dependencies]
|
||||
futures-util = { version = "0.3.34", default-features = false, features = ["sink", "std"] }
|
||||
tokio-tungstenite = "0.30.0"
|
||||
ed25519-dalek = { version = "3.0.0", default-features = false, features = ["fast"] }
|
||||
hex = "0.4.3"
|
||||
@@ -19,7 +19,7 @@ use rs_codec::{LiveSource, SharedMedia};
|
||||
use rs_platform::{Environment, Inhibition, PortalInfo, SessionType};
|
||||
use rs_proto::StreamSettings;
|
||||
use rs_signaling::{HostConfig, Room, ServerError, TlsMaterial};
|
||||
use rs_store::{Origin, Rejection, Settings, Store};
|
||||
use rs_store::{Origin, Rejection, Settings, Store, TrustedDevice};
|
||||
use tokio::sync::{oneshot, watch};
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
@@ -338,6 +338,48 @@ impl Host {
|
||||
done
|
||||
}
|
||||
|
||||
/// Trusts the device on this connection (#34): its public key is saved
|
||||
/// with its name, and it comes back without a link from now on, to this
|
||||
/// share and the next ones.
|
||||
pub async fn trust_device(&self, connection: u64) -> Result<(), String> {
|
||||
let room = lock(&self.0.view).as_ref().map(|v| v.room.clone());
|
||||
let device = room
|
||||
.and_then(|room| room.device(connection))
|
||||
.ok_or_else(|| "this viewer is no longer connected".to_string())?;
|
||||
let key = device
|
||||
.key
|
||||
.ok_or_else(|| "this browser cannot remember a key".to_string())?;
|
||||
let mut settings = self.settings();
|
||||
settings
|
||||
.trusted_devices
|
||||
.retain(|t| t.key != key && t.id.0 != device.id);
|
||||
settings.trusted_devices.push(TrustedDevice {
|
||||
id: rs_proto::DeviceId(device.id),
|
||||
name: device.name,
|
||||
key,
|
||||
added_ms: now_ms(),
|
||||
});
|
||||
self.update_settings(settings)
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(|rejections| joined(&rejections))
|
||||
}
|
||||
|
||||
/// Stops trusting a key. A device connected with it is sent away at once
|
||||
/// (#34); one connected by a link stays until it leaves.
|
||||
pub async fn revoke_device(&self, key: &str) -> Result<(), String> {
|
||||
let mut settings = self.settings();
|
||||
let before = settings.trusted_devices.len();
|
||||
settings.trusted_devices.retain(|t| t.key != key);
|
||||
if settings.trusted_devices.len() == before {
|
||||
return Ok(());
|
||||
}
|
||||
self.update_settings(settings)
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(|rejections| joined(&rejections))
|
||||
}
|
||||
|
||||
/// Draws a new QR code and a new short code (#19). Viewers already there
|
||||
/// stay, and a device already admitted comes back with the old one; the
|
||||
/// others need the new one.
|
||||
@@ -438,6 +480,17 @@ impl Host {
|
||||
change("confirm_quit", new.confirm_quit != old.confirm_quit, None);
|
||||
change("language", new.language != old.language, None);
|
||||
change("autostart", new.autostart != old.autostart, None);
|
||||
let trust_changed = new.trusted_devices != old.trusted_devices;
|
||||
change("trusted_devices", trust_changed, None);
|
||||
if trust_changed && let Some(room) = &room {
|
||||
let sent_away = room.set_trusted(trusted_keys(&new));
|
||||
tracing::info!(
|
||||
event = "trust_changed",
|
||||
trusted = new.trusted_devices.len(),
|
||||
sent_away = sent_away.len(),
|
||||
"trusted devices updated"
|
||||
);
|
||||
}
|
||||
if new.limit != old.limit
|
||||
&& overrides.limit.is_none()
|
||||
&& let Some(room) = &room
|
||||
@@ -524,6 +577,7 @@ impl Host {
|
||||
Room::new(None, stream_settings, limit)
|
||||
.with_validity(validity(settings.code_validity_min)),
|
||||
);
|
||||
room.set_trusted(trusted_keys(&settings));
|
||||
let server = self.spawn_server(listener, tls.clone(), room.clone(), media.clone());
|
||||
|
||||
let inhibition = match Inhibition::acquire("screen sharing in progress").await {
|
||||
@@ -820,12 +874,20 @@ fn describe(view: &mut View) -> Share {
|
||||
.room
|
||||
.devices()
|
||||
.into_iter()
|
||||
.map(|d| ViewerDevice {
|
||||
connection: d.connection,
|
||||
name: d.name,
|
||||
platform: d.platform,
|
||||
address: d.address.to_string(),
|
||||
since_ms: d.since_ms,
|
||||
.map(|d| {
|
||||
let trusted = d
|
||||
.key
|
||||
.as_deref()
|
||||
.is_some_and(|key| view.room.trusted_name(key).is_some());
|
||||
ViewerDevice {
|
||||
connection: d.connection,
|
||||
name: d.name,
|
||||
platform: d.platform,
|
||||
address: d.address.to_string(),
|
||||
since_ms: d.since_ms,
|
||||
trusted,
|
||||
can_trust: d.key.is_some() && !trusted,
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
refusals: view.room.refusals(),
|
||||
@@ -1067,6 +1129,28 @@ async fn watch_sleep(weak: Weak<Inner>) {
|
||||
}
|
||||
|
||||
/// How long an access stays valid, `None` for no limit.
|
||||
/// The keys the room checks, from the saved list. An entry without a usable
|
||||
/// key (written before #34) lets nobody in.
|
||||
fn trusted_keys(settings: &Settings) -> Vec<rs_signaling::TrustedKey> {
|
||||
settings
|
||||
.trusted_devices
|
||||
.iter()
|
||||
.filter(|t| t.has_key())
|
||||
.map(|t| rs_signaling::TrustedKey {
|
||||
key: t.key.to_ascii_lowercase(),
|
||||
name: t.name.clone(),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn joined(rejections: &[Rejection]) -> String {
|
||||
rejections
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
.join("; ")
|
||||
}
|
||||
|
||||
fn validity(minutes: u32) -> Option<Duration> {
|
||||
(minutes > 0).then(|| Duration::from_secs(u64::from(minutes) * 60))
|
||||
}
|
||||
|
||||
@@ -165,6 +165,11 @@ pub struct ViewerDevice {
|
||||
/// Arrival, in Unix milliseconds.
|
||||
#[ts(type = "number")]
|
||||
pub since_ms: u64,
|
||||
/// The host trusts its key: it comes back without a link (#34).
|
||||
pub trusted: bool,
|
||||
/// It announced a key the host could trust. A browser without storage, or
|
||||
/// too old to sign, has none.
|
||||
pub can_trust: bool,
|
||||
}
|
||||
|
||||
/// A share in progress.
|
||||
|
||||
@@ -56,14 +56,15 @@ async fn viewer(port: u16, room: &str, token: &str, id: &str) -> (Ws, serde_json
|
||||
.expect("WebSocket");
|
||||
let hello = ClientMessage::Hello {
|
||||
version: PROTOCOL_VERSION,
|
||||
room: RoomId::parse(room).unwrap(),
|
||||
token: SessionToken::new(token),
|
||||
room: Some(RoomId::parse(room).unwrap()),
|
||||
token: Some(SessionToken::new(token)),
|
||||
device: DeviceInfo {
|
||||
id: DeviceId(id.into()),
|
||||
name: format!("device {id}"),
|
||||
user_agent: None,
|
||||
platform: Some("test".into()),
|
||||
},
|
||||
key: None,
|
||||
};
|
||||
ws.send(Message::text(serde_json::to_string(&hello).unwrap()))
|
||||
.await
|
||||
@@ -85,6 +86,50 @@ async fn next(ws: &mut Ws) -> serde_json::Value {
|
||||
}
|
||||
}
|
||||
|
||||
/// Introduces itself by a key, with or without a link, and answers the
|
||||
/// challenge if one comes (#34). Returns what follows the hello and the proof.
|
||||
async fn keyed_viewer(
|
||||
port: u16,
|
||||
link: Option<(&str, &str)>,
|
||||
id: &str,
|
||||
signing: &ed25519_dalek::SigningKey,
|
||||
) -> (Ws, serde_json::Value) {
|
||||
use ed25519_dalek::Signer;
|
||||
let (mut ws, _) = tokio_tungstenite::connect_async(format!("ws://127.0.0.1:{port}/ws"))
|
||||
.await
|
||||
.expect("WebSocket");
|
||||
let hello = ClientMessage::Hello {
|
||||
version: PROTOCOL_VERSION,
|
||||
room: link.map(|(room, _)| RoomId::parse(room).unwrap()),
|
||||
token: link.map(|(_, token)| SessionToken::new(token)),
|
||||
device: DeviceInfo {
|
||||
id: DeviceId(id.into()),
|
||||
name: format!("device {id}"),
|
||||
user_agent: None,
|
||||
platform: None,
|
||||
},
|
||||
key: Some(hex::encode(signing.verifying_key().as_bytes())),
|
||||
};
|
||||
ws.send(Message::text(serde_json::to_string(&hello).unwrap()))
|
||||
.await
|
||||
.unwrap();
|
||||
let first = next(&mut ws).await;
|
||||
if first["type"] != "challenge" {
|
||||
return (ws, first);
|
||||
}
|
||||
let mut nonce = [0u8; rs_proto::trust::NONCE_LEN];
|
||||
hex::decode_to_slice(first["nonce"].as_str().unwrap(), &mut nonce).unwrap();
|
||||
let signature = signing.sign(&rs_proto::trust::signed_message(&nonce));
|
||||
let proof = ClientMessage::Proof {
|
||||
signature: hex::encode(signature.to_bytes()),
|
||||
};
|
||||
ws.send(Message::text(serde_json::to_string(&proof).unwrap()))
|
||||
.await
|
||||
.unwrap();
|
||||
let answer = next(&mut ws).await;
|
||||
(ws, answer)
|
||||
}
|
||||
|
||||
/// Without a route to a network (Nix sandbox), no ICE candidate can be
|
||||
/// advertised: the host then rightly refuses the media session. Tests that
|
||||
/// need an admitted viewer have nothing to check.
|
||||
@@ -179,6 +224,71 @@ async fn a_viewer_appears_then_is_kicked_and_cannot_come_back() {
|
||||
assert!(host.state().stop.is_none(), "intended stop, not a failure");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_trusted_device_comes_back_without_a_link_until_revoked() {
|
||||
if no_network() {
|
||||
return;
|
||||
}
|
||||
let (host, _dir) = host("trust", 0).await;
|
||||
let mut states = host.subscribe();
|
||||
host.start(test_pattern()).await.expect("share");
|
||||
let (port, room, token) = identifiers(&host.state().share.unwrap().url);
|
||||
let tablet = ed25519_dalek::SigningKey::from_bytes(&[7u8; 32]);
|
||||
|
||||
// Not trusted yet: no link, no entry, and the viewer hears why.
|
||||
let (_ws, refused) = keyed_viewer(port, None, "tablet", &tablet).await;
|
||||
assert_eq!(refused["code"], "not_trusted", "{refused}");
|
||||
|
||||
// First time through the link: the host may then trust it.
|
||||
let (ws, welcome) = keyed_viewer(port, Some((&room, &token)), "tablet", &tablet).await;
|
||||
assert_eq!(welcome["type"], "welcome", "{welcome}");
|
||||
assert_eq!(welcome["trusted"], false);
|
||||
let state = tokio::time::timeout(
|
||||
Duration::from_secs(3),
|
||||
states.wait_for(|s| s.share.as_ref().is_some_and(|p| p.devices.len() == 1)),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.clone();
|
||||
let device = state.share.unwrap().devices[0].clone();
|
||||
assert!(device.can_trust && !device.trusted);
|
||||
host.trust_device(device.connection).await.expect("trusted");
|
||||
// It hears so while it watches, to come back later without a link.
|
||||
let mut ws = ws;
|
||||
let told = next(&mut ws).await;
|
||||
assert_eq!(told, serde_json::json!({"type": "trust", "trusted": true}));
|
||||
let saved = host.settings().trusted_devices;
|
||||
assert_eq!(saved.len(), 1);
|
||||
assert_eq!(saved[0].key, hex::encode(tablet.verifying_key().as_bytes()));
|
||||
drop(ws);
|
||||
|
||||
// Back without a link, by signing the challenge.
|
||||
let (mut ws, welcome) = keyed_viewer(port, None, "tablet", &tablet).await;
|
||||
assert_eq!(welcome["type"], "welcome", "{welcome}");
|
||||
assert_eq!(welcome["trusted"], true);
|
||||
|
||||
// Another key claiming the same device id does not get in.
|
||||
let impostor = ed25519_dalek::SigningKey::from_bytes(&[9u8; 32]);
|
||||
let (_ws, refused) = keyed_viewer(port, None, "tablet", &impostor).await;
|
||||
assert_eq!(refused["code"], "not_trusted", "{refused}");
|
||||
|
||||
// Revoked: sent away within the second, and refused afterwards.
|
||||
let start = std::time::Instant::now();
|
||||
host.revoke_device(&saved[0].key).await.expect("revoked");
|
||||
let message = next(&mut ws).await;
|
||||
assert_eq!(message["code"], "not_trusted", "{message}");
|
||||
assert!(
|
||||
start.elapsed() < Duration::from_secs(1),
|
||||
"revocation too slow"
|
||||
);
|
||||
let (_ws, refused) = keyed_viewer(port, None, "tablet", &tablet).await;
|
||||
assert_eq!(refused["code"], "not_trusted", "{refused}");
|
||||
assert!(host.settings().trusted_devices.is_empty());
|
||||
|
||||
host.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn stopping_tells_viewers_the_share_ended_and_frees_the_port() {
|
||||
if no_network() {
|
||||
|
||||
@@ -18,6 +18,7 @@ tokio = { version = "1", features = ["rt", "rt-multi-thread", "net", "time", "sy
|
||||
tracing.workspace = true
|
||||
axum = { version = "0.8.9", features = ["ws"] }
|
||||
axum-server = { version = "0.8.0", features = ["tls-rustls"] }
|
||||
ed25519-dalek = { version = "3.0.0", default-features = false, features = ["fast"] }
|
||||
hex = "0.4.3"
|
||||
rand = "0.10.3"
|
||||
rcgen = "0.14.10"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//! - [`locales`]: embedded translations, served to the viewer.
|
||||
//! - [`tls`]: persistent self-signed certificate and pinnable fingerprint.
|
||||
//! - [`qr`]: QR code of the session, to join from a phone.
|
||||
//! - [`trust`]: trusted devices and the check of their signature (#34).
|
||||
//! - [`server`]: HTTP, signaling WebSocket, status API.
|
||||
|
||||
pub mod locales;
|
||||
@@ -14,6 +15,7 @@ pub mod qr;
|
||||
pub mod room;
|
||||
pub mod server;
|
||||
pub mod tls;
|
||||
pub mod trust;
|
||||
|
||||
pub use room::{CodeExchange, Device, Refusal, RefusalCause, Registration, Room, RoomError};
|
||||
pub use server::{
|
||||
@@ -21,3 +23,4 @@ pub use server::{
|
||||
session_url,
|
||||
};
|
||||
pub use tls::{TlsError, TlsMaterial};
|
||||
pub use trust::TrustedKey;
|
||||
@@ -17,6 +17,11 @@
|
||||
//! used, after a dropout or a sleep. Expiry closes the door to newcomers, not to
|
||||
//! those already inside. Every refusal is kept, with its cause, for the host
|
||||
//! interface (#35).
|
||||
//!
|
||||
//! A trusted device (#34) skips the token: the room holds the public keys the
|
||||
//! host trusts, and the server lets in whoever signs its challenge with one of
|
||||
//! them. Removing a key from the list sends away at once the device that came
|
||||
//! in with it.
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::net::IpAddr;
|
||||
@@ -31,6 +36,8 @@ use ts_rs::TS;
|
||||
|
||||
use rand::RngExt;
|
||||
|
||||
use crate::trust::TrustedKey;
|
||||
|
||||
/// A connected viewer, as the host sees it.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct Device {
|
||||
@@ -44,6 +51,11 @@ pub struct Device {
|
||||
pub address: IpAddr,
|
||||
/// Arrival time, in milliseconds since the Unix epoch.
|
||||
pub since_ms: u64,
|
||||
/// Public key announced by the viewer, if it has one: the host can then
|
||||
/// trust it (#34).
|
||||
pub key: Option<String>,
|
||||
/// Came in by its key rather than by a link.
|
||||
pub by_key: bool,
|
||||
}
|
||||
|
||||
struct Present {
|
||||
@@ -184,6 +196,9 @@ pub enum RefusalCause {
|
||||
Kicked,
|
||||
/// No seat left.
|
||||
RoomFull,
|
||||
/// The device came back by a key the host does not trust, or did not prove
|
||||
/// it holds it (#34).
|
||||
NotTrusted,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RefusalCause {
|
||||
@@ -194,6 +209,7 @@ impl std::fmt::Display for RefusalCause {
|
||||
Self::ExpiredToken => "token expired or replaced by the host",
|
||||
Self::Kicked => "device disconnected by the host",
|
||||
Self::RoomFull => "no seat left",
|
||||
Self::NotTrusted => "device not trusted, or its signature did not match",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -244,6 +260,8 @@ pub struct Room {
|
||||
banned: Mutex<Vec<String>>,
|
||||
/// Refusals, newest last. Bounded: the interface shows the last ones.
|
||||
refusals: Mutex<VecDeque<Refusal>>,
|
||||
/// Keys of the devices the host trusts (#34), kept in the settings.
|
||||
trusted: Mutex<Vec<TrustedKey>>,
|
||||
next_connection: AtomicU64,
|
||||
/// Bumped on every arrival or departure: the interface subscribes to it
|
||||
/// instead of polling.
|
||||
@@ -269,6 +287,7 @@ impl Room {
|
||||
present: Mutex::new(Vec::new()),
|
||||
banned: Mutex::new(Vec::new()),
|
||||
refusals: Mutex::new(VecDeque::new()),
|
||||
trusted: Mutex::new(Vec::new()),
|
||||
next_connection: AtomicU64::new(1),
|
||||
changes: watch::Sender::new(0),
|
||||
}
|
||||
@@ -318,6 +337,38 @@ impl Room {
|
||||
self.notify();
|
||||
}
|
||||
|
||||
/// Replaces the trusted keys. A device that came in by a key no longer in
|
||||
/// the list is sent away now, and does not come back to this share with
|
||||
/// its link either: revoking must take effect within the second (#34).
|
||||
/// Returns the connections sent away.
|
||||
pub fn set_trusted(&self, keys: Vec<TrustedKey>) -> Vec<u64> {
|
||||
*lock(&self.trusted) = keys;
|
||||
let revoked: Vec<u64> = lock(&self.present)
|
||||
.iter()
|
||||
.filter(|p| p.device.by_key)
|
||||
.filter(|p| {
|
||||
p.device
|
||||
.key
|
||||
.as_deref()
|
||||
.is_none_or(|key| self.trusted_name(key).is_none())
|
||||
})
|
||||
.map(|p| p.device.connection)
|
||||
.collect();
|
||||
for connection in &revoked {
|
||||
self.kick(*connection);
|
||||
}
|
||||
self.notify();
|
||||
revoked
|
||||
}
|
||||
|
||||
/// The name the host gave a trusted key, `None` if it does not trust it.
|
||||
pub fn trusted_name(&self, key: &str) -> Option<String> {
|
||||
lock(&self.trusted)
|
||||
.iter()
|
||||
.find(|t| t.key == key)
|
||||
.map(|t| t.name.clone())
|
||||
}
|
||||
|
||||
/// The refusals the host interface shows, newest first.
|
||||
pub fn refusals(&self) -> Vec<Refusal> {
|
||||
lock(&self.refusals).iter().rev().cloned().collect()
|
||||
@@ -397,6 +448,8 @@ impl Room {
|
||||
name: &str,
|
||||
platform: Option<String>,
|
||||
address: IpAddr,
|
||||
key: Option<String>,
|
||||
by_key: bool,
|
||||
) -> Registration {
|
||||
let connection = self.next_connection.fetch_add(1, Ordering::SeqCst);
|
||||
let kicked = Arc::new(Notify::new());
|
||||
@@ -414,6 +467,8 @@ impl Room {
|
||||
platform,
|
||||
address,
|
||||
since_ms: now_ms(),
|
||||
key,
|
||||
by_key,
|
||||
},
|
||||
kicked: kicked.clone(),
|
||||
});
|
||||
@@ -451,6 +506,14 @@ impl Room {
|
||||
}
|
||||
}
|
||||
|
||||
/// The present device on this connection.
|
||||
pub fn device(&self, connection: u64) -> Option<Device> {
|
||||
lock(&self.present)
|
||||
.iter()
|
||||
.find(|p| p.device.connection == connection)
|
||||
.map(|p| p.device.clone())
|
||||
}
|
||||
|
||||
pub fn devices(&self) -> Vec<Device> {
|
||||
lock(&self.present)
|
||||
.iter()
|
||||
@@ -601,6 +664,8 @@ pub enum RoomError {
|
||||
Kicked,
|
||||
#[error("room full: {limit} viewers at most")]
|
||||
Full { limit: u8 },
|
||||
#[error("the host does not trust this device: scan the QR code shown by the host")]
|
||||
NotTrusted,
|
||||
}
|
||||
|
||||
impl RoomError {
|
||||
@@ -612,6 +677,7 @@ impl RoomError {
|
||||
Self::ExpiredToken => RefusalCause::ExpiredToken,
|
||||
Self::Kicked => RefusalCause::Kicked,
|
||||
Self::Full { .. } => RefusalCause::RoomFull,
|
||||
Self::NotTrusted => RefusalCause::NotTrusted,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,8 +752,8 @@ mod tests {
|
||||
let room = room(3);
|
||||
let mut changes = room.subscribe();
|
||||
let ip: IpAddr = "192.168.1.30".parse().unwrap();
|
||||
let a = room.register("tablet", "iPad", Some("iPadOS".into()), ip);
|
||||
let b = room.register("phone", "Pixel", None, ip);
|
||||
let a = room.register("tablet", "iPad", Some("iPadOS".into()), ip, None, false);
|
||||
let b = room.register("phone", "Pixel", None, ip, None, false);
|
||||
assert!(changes.has_changed().unwrap());
|
||||
changes.mark_unchanged();
|
||||
assert_eq!(room.devices().len(), 2);
|
||||
@@ -759,7 +825,7 @@ mod tests {
|
||||
fn a_regenerated_access_keeps_admitted_devices_only() {
|
||||
let room = room(5);
|
||||
let first = room.token();
|
||||
room.register("tablet", "iPad", None, ip(30));
|
||||
room.register("tablet", "iPad", None, ip(30), None, false);
|
||||
room.regenerate(None);
|
||||
assert_ne!(room.token(), first);
|
||||
// The tablet comes back from sleep with the old token: it gets in.
|
||||
@@ -776,7 +842,7 @@ mod tests {
|
||||
fn a_kicked_device_loses_its_readmission() {
|
||||
let room = room(5);
|
||||
let first = room.token();
|
||||
let a = room.register("tablet", "iPad", None, ip(30));
|
||||
let a = room.register("tablet", "iPad", None, ip(30), None, false);
|
||||
room.kick(a.connection);
|
||||
room.regenerate(None);
|
||||
assert_eq!(
|
||||
@@ -848,6 +914,35 @@ mod tests {
|
||||
assert_eq!(kept[0].device, format!("device {}", REFUSALS_KEPT + 4));
|
||||
}
|
||||
|
||||
fn trusted(key: &str) -> TrustedKey {
|
||||
TrustedKey {
|
||||
key: key.into(),
|
||||
name: "Kitchen tablet".into(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn revoking_a_key_sends_away_the_device_that_came_with_it() {
|
||||
let room = room(5);
|
||||
room.set_trusted(vec![trusted("aa"), trusted("bb")]);
|
||||
assert_eq!(room.trusted_name("aa").as_deref(), Some("Kitchen tablet"));
|
||||
let by_key = room.register("tablet", "iPad", None, ip(30), Some("aa".into()), true);
|
||||
// Same key, but came in by a link: revoking the trust does not cut it.
|
||||
let by_link = room.register("phone", "Pixel", None, ip(31), Some("aa".into()), false);
|
||||
let other = room.register("laptop", "Mac", None, ip(32), Some("bb".into()), true);
|
||||
|
||||
let sent_away = room.set_trusted(vec![trusted("bb")]);
|
||||
assert_eq!(sent_away, vec![by_key.connection]);
|
||||
assert!(room.trusted_name("aa").is_none());
|
||||
assert!(
|
||||
room.is_banned("tablet"),
|
||||
"the old link no longer lets it in"
|
||||
);
|
||||
assert!(!room.is_banned("phone"));
|
||||
assert!(room.device(other.connection).is_some());
|
||||
let _ = by_link;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_short_code_opens_the_room() {
|
||||
let room = room(5);
|
||||
|
||||
@@ -25,7 +25,7 @@ use serde::Serialize;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::qr;
|
||||
use crate::room::{CodeExchange, Refusal, RefusalCause, Room};
|
||||
use crate::room::{CodeExchange, Refusal, Room, RoomError};
|
||||
use crate::tls::TlsMaterial;
|
||||
|
||||
const HELLO_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
|
||||
@@ -454,6 +454,8 @@ async fn ws_upgrade(
|
||||
enum Cause {
|
||||
Bye,
|
||||
Kicked,
|
||||
/// The host stopped trusting the key this device came in with (#34).
|
||||
Revoked,
|
||||
ShareStopped,
|
||||
WebSocketClosed,
|
||||
WebSocketError,
|
||||
@@ -466,6 +468,7 @@ impl std::fmt::Display for Cause {
|
||||
match self {
|
||||
Self::Bye => f.write_str("departure announced by the viewer"),
|
||||
Self::Kicked => f.write_str("disconnected by the host"),
|
||||
Self::Revoked => f.write_str("trust revoked by the host"),
|
||||
Self::ShareStopped => f.write_str("sharing stopped by the host"),
|
||||
Self::WebSocketClosed => f.write_str("WebSocket closed without a goodbye"),
|
||||
Self::WebSocketError => f.write_str("WebSocket error"),
|
||||
@@ -489,13 +492,15 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
}
|
||||
};
|
||||
|
||||
let (version, room_id, token, device) = match serde_json::from_str::<ClientMessage>(&hello) {
|
||||
let (version, room_id, token, device, key) = match serde_json::from_str::<ClientMessage>(&hello)
|
||||
{
|
||||
Ok(ClientMessage::Hello {
|
||||
version,
|
||||
room,
|
||||
token,
|
||||
device,
|
||||
}) => (version, room, token, device),
|
||||
key,
|
||||
}) => (version, room, token, device, key),
|
||||
_ => {
|
||||
let _ = send(
|
||||
&mut socket,
|
||||
@@ -518,15 +523,22 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
return;
|
||||
}
|
||||
let name = device_name(&device);
|
||||
// A key well formed and trusted by the host skips the token (#34),
|
||||
// whatever link the device came with: an old one, or none at all.
|
||||
let key = key
|
||||
.map(|k| k.to_ascii_lowercase())
|
||||
.filter(|k| crate::trust::is_public_key(k));
|
||||
let trusted_as = key.as_deref().and_then(|k| state.room.trusted_name(k));
|
||||
if state.room.is_banned(&device.id.0) {
|
||||
state
|
||||
.room
|
||||
.record_refusal(peer.ip(), &name, RefusalCause::Kicked);
|
||||
let _ = send(
|
||||
&mut socket,
|
||||
&error(ErrorCode::Kicked, "the host disconnected this device"),
|
||||
)
|
||||
.await;
|
||||
// Revoked rather than disconnected: the device must hear that it is
|
||||
// no longer trusted, to forget it and ask for the QR code.
|
||||
let e = if key.is_some() && trusted_as.is_none() && room_id.is_none() {
|
||||
RoomError::NotTrusted
|
||||
} else {
|
||||
RoomError::Kicked
|
||||
};
|
||||
state.room.record_refusal(peer.ip(), &name, e.refusal());
|
||||
let _ = send(&mut socket, &error(error_code(&e), &e.to_string())).await;
|
||||
return;
|
||||
}
|
||||
// The seat comes first: a full room must not spend the link of the next
|
||||
@@ -539,25 +551,43 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
return;
|
||||
}
|
||||
};
|
||||
if let Err(e) = state.room.authorize(&room_id, &token, &device.id.0) {
|
||||
state.room.release();
|
||||
state.room.record_refusal(peer.ip(), &name, e.refusal());
|
||||
let code = match e {
|
||||
crate::room::RoomError::UnknownRoom => ErrorCode::BadToken,
|
||||
crate::room::RoomError::BadToken => ErrorCode::BadToken,
|
||||
crate::room::RoomError::TokenUsed => ErrorCode::TokenUsed,
|
||||
crate::room::RoomError::ExpiredToken => ErrorCode::TokenExpired,
|
||||
crate::room::RoomError::Kicked => ErrorCode::Kicked,
|
||||
crate::room::RoomError::Full { .. } => ErrorCode::RoomFull,
|
||||
let by_key = if let (Some(key), Some(trusted_as)) = (&key, &trusted_as) {
|
||||
match prove_key(&mut socket, &state.room, key).await {
|
||||
Ok(()) => {
|
||||
tracing::info!(event = "trusted_device_admitted", device = %trusted_as, "came back by its key");
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
state.room.release();
|
||||
state.room.record_refusal(peer.ip(), &name, e.refusal());
|
||||
let _ = send(&mut socket, &error(error_code(&e), &e.to_string())).await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let authorized = match (&room_id, &token) {
|
||||
(Some(room_id), Some(token)) => state.room.authorize(room_id, token, &device.id.0),
|
||||
// No link: only a trusted key could have opened the door. The
|
||||
// device hears so, forgets the trust and asks for the QR code.
|
||||
_ if key.is_some() => Err(RoomError::NotTrusted),
|
||||
_ => Err(RoomError::BadToken),
|
||||
};
|
||||
let _ = send(&mut socket, &error(code, &e.to_string())).await;
|
||||
return;
|
||||
}
|
||||
if let Err(e) = authorized {
|
||||
state.room.release();
|
||||
state.room.record_refusal(peer.ip(), &name, e.refusal());
|
||||
let _ = send(&mut socket, &error(error_code(&e), &e.to_string())).await;
|
||||
return;
|
||||
}
|
||||
false
|
||||
};
|
||||
// The host's name for a trusted device wins over the one it announces.
|
||||
let name = trusted_as.filter(|_| by_key).unwrap_or(name);
|
||||
tracing::info!(
|
||||
event = "session_opened",
|
||||
device = %device.name,
|
||||
device = %name,
|
||||
peer = %peer.ip(),
|
||||
connected,
|
||||
by_key,
|
||||
"viewer admitted"
|
||||
);
|
||||
|
||||
@@ -597,9 +627,14 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
return;
|
||||
};
|
||||
|
||||
let registration = state
|
||||
.room
|
||||
.register(&device.id.0, &name, device.platform.clone(), peer.ip());
|
||||
let registration = state.room.register(
|
||||
&device.id.0,
|
||||
&name,
|
||||
device.platform.clone(),
|
||||
peer.ip(),
|
||||
key.clone(),
|
||||
by_key,
|
||||
);
|
||||
let connection = registration.connection;
|
||||
|
||||
let welcome = ServerMessage::Welcome {
|
||||
@@ -609,17 +644,34 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
settings: state.room.settings,
|
||||
connected,
|
||||
limit: state.room.limit(),
|
||||
trusted: by_key,
|
||||
};
|
||||
if send(&mut socket, &welcome).await.is_err() {
|
||||
cleanup(&state, connection, cmd_tx, driver);
|
||||
return;
|
||||
}
|
||||
|
||||
// The host may trust or revoke this device while it watches: it hears so
|
||||
// right away, not at its next connection (#34).
|
||||
let mut changes = state.room.subscribe();
|
||||
let mut trusted = by_key;
|
||||
let cause = loop {
|
||||
tokio::select! {
|
||||
Ok(()) = changes.changed() => {
|
||||
let now = is_trusted(&state.room, key.as_deref());
|
||||
// Came in by its key and lost it: it is being sent away with
|
||||
// `not_trusted`, which says the same thing.
|
||||
if now != trusted && (now || !by_key) {
|
||||
trusted = now;
|
||||
let _ = send(&mut socket, &ServerMessage::Trust { trusted }).await;
|
||||
}
|
||||
}
|
||||
() = registration.kicked.notified() => {
|
||||
// Same signal for both: the ban list tells which one.
|
||||
let (code, cause) = if state.room.is_banned(&device.id.0) {
|
||||
let revoked = by_key && !is_trusted(&state.room, key.as_deref());
|
||||
let (code, cause) = if revoked {
|
||||
(ErrorCode::NotTrusted, Cause::Revoked)
|
||||
} else if state.room.is_banned(&device.id.0) {
|
||||
(ErrorCode::Kicked, Cause::Kicked)
|
||||
} else {
|
||||
(ErrorCode::ShareEnded, Cause::ShareStopped)
|
||||
@@ -675,6 +727,9 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
tracing::debug!("trickled candidate ignored: the offer already carries the candidates");
|
||||
}
|
||||
Ok(ClientMessage::Bye) => break Cause::Bye,
|
||||
Ok(ClientMessage::Proof { .. }) => {
|
||||
let _ = send(&mut socket, &error(ErrorCode::ProtocolViolation, "no challenge pending")).await;
|
||||
}
|
||||
Ok(ClientMessage::Hello { .. }) => {
|
||||
let _ = send(&mut socket, &error(ErrorCode::ProtocolViolation, "hello already received")).await;
|
||||
}
|
||||
@@ -735,6 +790,46 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>, peer: Socket
|
||||
cleanup(&state, connection, cmd_tx, driver);
|
||||
}
|
||||
|
||||
/// The challenge of a trusted key: a fresh nonce, signed by the device within
|
||||
/// the hello delay. The list is read again after the answer: a key revoked
|
||||
/// meanwhile does not get in (#34).
|
||||
async fn prove_key(socket: &mut WebSocket, room: &Room, key: &str) -> Result<(), RoomError> {
|
||||
let nonce = crate::trust::draw_nonce();
|
||||
let challenge = ServerMessage::Challenge {
|
||||
nonce: hex::encode(nonce),
|
||||
};
|
||||
if send(socket, &challenge).await.is_err() {
|
||||
return Err(RoomError::NotTrusted);
|
||||
}
|
||||
let signature = match tokio::time::timeout(HELLO_TIMEOUT, socket.recv()).await {
|
||||
Ok(Some(Ok(Message::Text(text)))) => match serde_json::from_str::<ClientMessage>(&text) {
|
||||
Ok(ClientMessage::Proof { signature }) => signature,
|
||||
_ => return Err(RoomError::NotTrusted),
|
||||
},
|
||||
_ => return Err(RoomError::NotTrusted),
|
||||
};
|
||||
if crate::trust::verify(key, &nonce, &signature) && room.trusted_name(key).is_some() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(RoomError::NotTrusted)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_trusted(room: &Room, key: Option<&str>) -> bool {
|
||||
key.is_some_and(|k| room.trusted_name(k).is_some())
|
||||
}
|
||||
|
||||
fn error_code(e: &RoomError) -> ErrorCode {
|
||||
match e {
|
||||
RoomError::UnknownRoom | RoomError::BadToken => ErrorCode::BadToken,
|
||||
RoomError::TokenUsed => ErrorCode::TokenUsed,
|
||||
RoomError::ExpiredToken => ErrorCode::TokenExpired,
|
||||
RoomError::Kicked => ErrorCode::Kicked,
|
||||
RoomError::Full { .. } => ErrorCode::RoomFull,
|
||||
RoomError::NotTrusted => ErrorCode::NotTrusted,
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup(
|
||||
state: &AppState,
|
||||
connection: u64,
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
//! Trusted devices (#34): who may come back without a link, and the check of
|
||||
//! their signature.
|
||||
//!
|
||||
//! The host keeps the public key of each trusted device; the private key
|
||||
//! never leaves the browser. Coming back is a challenge: a fresh nonce per
|
||||
//! connection, signed by the device (`rs_proto::trust`). An old signature
|
||||
//! replayed proves nothing, since its nonce is not the one of this connection,
|
||||
//! and a revoked key is no longer in the list whatever it signs.
|
||||
|
||||
use ed25519_dalek::{Signature, VerifyingKey};
|
||||
use rand::RngExt;
|
||||
use rs_proto::trust::{NONCE_LEN, signed_message};
|
||||
|
||||
/// A device the host trusts, as the room needs it: its key and its name.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TrustedKey {
|
||||
/// Ed25519 public key, 64 lowercase hex digits.
|
||||
pub key: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
/// A fresh nonce, to sign once.
|
||||
pub fn draw_nonce() -> [u8; NONCE_LEN] {
|
||||
rand::rng().random()
|
||||
}
|
||||
|
||||
/// Is `key` a well-formed public key? Checked before it is ever stored.
|
||||
pub fn is_public_key(key: &str) -> bool {
|
||||
parse_key(key).is_some()
|
||||
}
|
||||
|
||||
/// Does `signature` sign `nonce` with `key`? Any malformed input is `false`.
|
||||
pub fn verify(key: &str, nonce: &[u8; NONCE_LEN], signature: &str) -> bool {
|
||||
let Some(key) = parse_key(key) else {
|
||||
return false;
|
||||
};
|
||||
let Some(signature) = decode::<64>(signature).map(|b| Signature::from_bytes(&b)) else {
|
||||
return false;
|
||||
};
|
||||
// `verify_strict` refuses the weak keys and the malleable signatures that
|
||||
// plain `verify` lets through.
|
||||
key.verify_strict(&signed_message(nonce), &signature)
|
||||
.is_ok()
|
||||
}
|
||||
|
||||
fn parse_key(key: &str) -> Option<VerifyingKey> {
|
||||
let bytes = decode::<32>(key)?;
|
||||
let key = VerifyingKey::from_bytes(&bytes).ok()?;
|
||||
(!key.is_weak()).then_some(key)
|
||||
}
|
||||
|
||||
fn decode<const N: usize>(text: &str) -> Option<[u8; N]> {
|
||||
let mut bytes = [0u8; N];
|
||||
hex::decode_to_slice(text, &mut bytes).ok()?;
|
||||
Some(bytes)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ed25519_dalek::{Signer, SigningKey};
|
||||
use rs_proto::trust::TEST_VECTOR;
|
||||
|
||||
fn vector() -> (SigningKey, [u8; NONCE_LEN]) {
|
||||
let mut seed = [0u8; 32];
|
||||
hex::decode_to_slice(TEST_VECTOR[0], &mut seed).unwrap();
|
||||
let mut nonce = [0u8; NONCE_LEN];
|
||||
hex::decode_to_slice(TEST_VECTOR[2], &mut nonce).unwrap();
|
||||
(SigningKey::from_bytes(&seed), nonce)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_shared_vector_holds() {
|
||||
let (signing, nonce) = vector();
|
||||
assert_eq!(
|
||||
hex::encode(signing.verifying_key().as_bytes()),
|
||||
TEST_VECTOR[1]
|
||||
);
|
||||
let signature = hex::encode(signing.sign(&signed_message(&nonce)).to_bytes());
|
||||
assert_eq!(
|
||||
signature, TEST_VECTOR[3],
|
||||
"update TEST_VECTOR and trust.test.ts"
|
||||
);
|
||||
assert!(verify(TEST_VECTOR[1], &nonce, TEST_VECTOR[3]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_signature_does_not_carry_over_to_another_nonce() {
|
||||
let (signing, nonce) = vector();
|
||||
let signature = hex::encode(signing.sign(&signed_message(&nonce)).to_bytes());
|
||||
let other = draw_nonce();
|
||||
assert!(!verify(TEST_VECTOR[1], &other, &signature));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn another_key_or_garbage_is_refused() {
|
||||
let (signing, nonce) = vector();
|
||||
let signature = hex::encode(signing.sign(&signed_message(&nonce)).to_bytes());
|
||||
let stranger = SigningKey::from_bytes(&[3u8; 32]);
|
||||
let stranger_key = hex::encode(stranger.verifying_key().as_bytes());
|
||||
assert!(!verify(&stranger_key, &nonce, &signature));
|
||||
assert!(!verify("zz", &nonce, &signature));
|
||||
assert!(!verify(TEST_VECTOR[1], &nonce, "00"));
|
||||
// The identity point is a weak key: never accepted as a device key.
|
||||
let identity = format!("01{}", "00".repeat(31));
|
||||
assert!(!is_public_key(&identity));
|
||||
assert!(is_public_key(TEST_VECTOR[1]));
|
||||
}
|
||||
}
|
||||
@@ -89,14 +89,32 @@ pub enum CloseAction {
|
||||
Quit,
|
||||
}
|
||||
|
||||
/// A device allowed to come back without scanning again (#34). The storage
|
||||
/// exists already so that the format does not need a new version that day.
|
||||
/// A device allowed to come back without scanning again (#34).
|
||||
///
|
||||
/// The host keeps the public key only: the device proves it holds the private
|
||||
/// one by signing a challenge, and the private key never leaves it.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
#[ts(export, export_to = "../../../desktop/src/bindings/")]
|
||||
pub struct TrustedDevice {
|
||||
pub id: DeviceId,
|
||||
#[serde(alias = "nom")]
|
||||
pub name: String,
|
||||
/// Ed25519 public key, 64 lowercase hex digits. Empty in a file written
|
||||
/// before #34: such an entry lets nobody in.
|
||||
#[serde(default)]
|
||||
pub key: String,
|
||||
/// When the host started trusting it, in milliseconds since the Unix epoch.
|
||||
#[serde(default)]
|
||||
#[ts(type = "number")]
|
||||
pub added_ms: u64,
|
||||
}
|
||||
|
||||
impl TrustedDevice {
|
||||
/// A key the host can check: 64 hex digits. Whether it is a valid curve
|
||||
/// point is checked by the server, which does the cryptography.
|
||||
pub fn has_key(&self) -> bool {
|
||||
self.key.len() == 64 && self.key.bytes().all(|b| b.is_ascii_hexdigit())
|
||||
}
|
||||
}
|
||||
|
||||
/// Everything that can be set, in a single place.
|
||||
@@ -572,6 +590,9 @@ mod tests {
|
||||
trusted_devices: vec![TrustedDevice {
|
||||
id: DeviceId("ipad".into()),
|
||||
name: "iPad du salon".into(),
|
||||
// Written before #34: no key, so it lets nobody in.
|
||||
key: String::new(),
|
||||
added_ms: 0,
|
||||
}],
|
||||
}
|
||||
}
|
||||
@@ -684,6 +705,8 @@ mod tests {
|
||||
trusted_devices: vec![TrustedDevice {
|
||||
id: DeviceId("ipad".into()),
|
||||
name: "iPad du salon".into(),
|
||||
key: "ab".repeat(32),
|
||||
added_ms: 1_761_800_000_000,
|
||||
}],
|
||||
..Settings::default()
|
||||
};
|
||||
|
||||
@@ -129,8 +129,9 @@ système, prévention d'une fermeture accidentelle.
|
||||
- Chaque room porte un jeton aléatoire (128 bits) **à usage unique**, une durée de vie et un journal
|
||||
des refus (ADR 0010). Une connexion sans jeton est refusée, sauf en mode « réseau de confiance »
|
||||
explicite.
|
||||
- Appareils de confiance : après appairage, une clé publique d'appareil permet de reconnecter sans
|
||||
mot de passe ; la révocation est immédiate et locale.
|
||||
- Appareils de confiance (ADR 0011) : l'hôte garde la clé publique Ed25519 d'un appareil auquel il
|
||||
fait confiance; l'appareil revient sans lien en signant un nonce neuf à chaque connexion. La
|
||||
révocation renvoie l'appareil sur-le-champ et reste locale.
|
||||
- Aucune télémétrie, aucun appel sortant. Un test d'intégration vérifie l'absence de connexion
|
||||
externe pendant une session.
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# ADR 0011: appareils de confiance, clé Ed25519 signée en JavaScript
|
||||
|
||||
Statut: adoptée le 30 octobre 2026 (issue #34).
|
||||
|
||||
## Contexte
|
||||
|
||||
Le ticket #34 demande qu'une tablette déjà appairée revienne sans rescanner de QR code: au premier
|
||||
appairage, le viewer génère une paire de clés et l'hôte garde la clé publique; ensuite, le retour se
|
||||
fait par la signature d'un nonce, sans jeton partagé, et la révocation agit en moins d'une seconde.
|
||||
|
||||
Deux contraintes viennent des décisions précédentes:
|
||||
|
||||
- **le viewer est servi en HTTP sur le LAN** (ADR 0005), qui n'est pas un contexte sécurisé.
|
||||
`crypto.subtle` n'y existe pas: ni WebCrypto, ni clé non extractible. `crypto.getRandomValues()`,
|
||||
lui, existe;
|
||||
- **le lien est à usage unique** (ADR 0010): sans confiance, chaque retour après un redémarrage du
|
||||
partage demande un nouveau scan, puisque la room et son jeton changent à chaque partage.
|
||||
|
||||
## Décision
|
||||
|
||||
1. **Ed25519, signé en JavaScript dans le viewer** (`@noble/ed25519` et `@noble/hashes`, embarqués
|
||||
dans le bundle, sans réseau), vérifié côté hôte par `ed25519-dalek` (`verify_strict`). La clé
|
||||
privée vit dans le `localStorage` de l'origine de l'hôte, n'est jamais envoyée ni journalisée.
|
||||
2. **Le viewer annonce toujours sa clé publique dans le `hello`.** L'hôte qui la reconnaît répond
|
||||
par un `challenge` (nonce de 32 octets, neuf à chaque connexion); le viewer répond par une
|
||||
`proof`. Ce qui est signé est fixé des deux côtés, jamais choisi par l'hôte: le contexte
|
||||
`rustscreen-trust-v1`, un octet nul, puis le nonce (`rs_proto::trust`). Un vecteur de test
|
||||
commun aux deux suites garde le Rust et le TypeScript d'accord.
|
||||
3. **La confiance se donne depuis l'hôte, appareil par appareil.** Un spectateur entré par le lien
|
||||
ou le code court apparaît avec un bouton « Faire confiance »; rien n'est accordé automatiquement.
|
||||
L'hôte garde la clé et le nom dans `settings.json` (`trusted_devices`), pour ce partage et les
|
||||
suivants. L'appareil connecté l'apprend sur-le-champ (message `trust`), sans attendre sa
|
||||
prochaine connexion.
|
||||
4. **Un appareil de confiance passe avant le jeton**, avec ou sans lien. Il revient depuis la simple
|
||||
adresse de l'hôte (`http://hôte:port/`): le viewer, qui sait qu'on lui a fait confiance, s'y
|
||||
connecte sans room ni jeton. Les places restent comptées et un appareil déconnecté par l'hôte
|
||||
reste dehors pour la durée du partage.
|
||||
5. **La révocation agit tout de suite, sans « Enregistrer ».** Retirer une clé renvoie l'appareil
|
||||
entré avec elle (`not_trusted`), lui interdit de revenir par son ancien lien pendant ce partage,
|
||||
et lui fait oublier qu'il était de confiance: il redemande le QR code.
|
||||
|
||||
## Conséquences
|
||||
|
||||
- Un appareil de confiance revient après un redémarrage du partage, une veille ou un changement de
|
||||
room, sans intervention de l'hôte.
|
||||
- Rejouer un ancien échange ne sert à rien: le nonce n'est pas celui de la connexion, et une clé
|
||||
révoquée n'est plus dans la liste, quoi qu'elle signe. La liste est relue après la preuve, donc
|
||||
une révocation pendant le défi compte.
|
||||
- La clé privée est lisible par du JavaScript de la même origine. Le viewer n'en charge pas
|
||||
d'autre (pas de CDN, pas de tiers), mais un hôte compromis peut la lire: c'est le même hôte qui
|
||||
la juge, le risque ne change pas.
|
||||
- En HTTP, un attaquant actif sur le chemin peut relayer un défi vers un vrai appareil qui se
|
||||
connecte au même moment. Il pouvait déjà lire le jeton en clair (ADR 0005); la confiance ne
|
||||
l'aggrave pas et ne prétend pas le corriger.
|
||||
- Un navigateur sans stockage (navigation privée) ou trop ancien (sans `BigInt`, iOS antérieur à
|
||||
14) n'a pas de clé: il passe par le lien, comme avant. L'hôte ne lui propose pas la confiance.
|
||||
- Le bundle du viewer grossit de 8 ko compressés (77 à 84 ko).
|
||||
|
||||
## Alternatives écartées
|
||||
|
||||
- **WebCrypto (Ed25519 ou ECDSA P-256)**: indisponible hors contexte sécurisé, c'est-à-dire dans le
|
||||
mode par défaut. Le réserver à `--tls` laisserait la fonction à ceux qui n'en ont pas besoin.
|
||||
- **Secret partagé tiré par l'hôte, HMAC du nonce**: plus simple, mais l'hôte garderait de quoi se
|
||||
faire passer pour l'appareil, et le ticket exclut le jeton partagé.
|
||||
- **Confiance automatique à chaque premier appairage**: tout appareil qui a vu un QR code une fois
|
||||
reviendrait pour toujours; la décision appartient à l'hôte.
|
||||
- **Clé non extractible en IndexedDB quand le contexte est sécurisé**: deux chemins de code pour un
|
||||
gain qui ne porte que sur le mode `--tls`. À reprendre si ce mode devient courant.
|
||||
|
||||
## Condition de réouverture
|
||||
|
||||
Si les navigateurs ouvrent WebCrypto aux origines du LAN, ou si le mode TLS devient le mode par
|
||||
défaut, la clé passe dans WebCrypto, non extractible, et la bibliothèque JavaScript disparaît. Si
|
||||
la confiance doit couvrir plusieurs hôtes à la fois, la liste quitte `settings.json`.
|
||||
@@ -17,6 +17,7 @@ le 26 octobre 2026 (issue #2); les suivantes tranchent ce qui restait ouvert.
|
||||
| [0008](0008-format-des-diagnostics.md) | diagnostics exportés | archive zip locale, manifeste et journaux expurgés, aucun envoi |
|
||||
| [0009](0009-capture-wayland-et-ecran-virtuel.md) | capture Linux et écran virtuel | PipeWire en feature, repli x11rb, type `VIRTUAL` du portail |
|
||||
| [0010](0010-jeton-usage-unique.md) | accès à la session | lien à usage unique, code court réutilisable, journal des refus |
|
||||
| [0011](0011-appareils-de-confiance.md) | appareils de confiance | clé Ed25519 signée en JavaScript, défi par connexion, révocation immédiate |
|
||||
|
||||
Aucune décision structurante n'est ouverte à ce jour. Une nouvelle décision ouvre une issue, puis
|
||||
une ADR au même plan quand elle est tranchée.
|
||||
+13
-2
@@ -48,6 +48,8 @@
|
||||
"language": "Language",
|
||||
"insecureBadge": "not encrypted",
|
||||
"insecureHint": "The page and signalling travel unencrypted on the local network. The video stream itself is encrypted end to end (DTLS-SRTP).",
|
||||
"trustedBadge": "Trusted",
|
||||
"trustedHint": "The host trusts this device: open this address again to come back, without a QR code.",
|
||||
"networkFallback": "Connection lost. Check that you are on the same network as the host.",
|
||||
"errors": {
|
||||
"bad_token": "This link matches no session on this host. Scan its QR code again, or type its short code.",
|
||||
@@ -61,7 +63,8 @@
|
||||
"kicked": "The host disconnected this device. Ask for a new QR code to come back.",
|
||||
"share_ended": "The host stopped sharing.",
|
||||
"network": "Connection lost after several attempts. Check that you are on the same network as the host. The connection resumes by itself when the network returns, or with the button below. If the host restarted, scan its QR code again: the address changes at every start.",
|
||||
"unsupported": "This browser does not support WebRTC."
|
||||
"unsupported": "This browser does not support WebRTC.",
|
||||
"not_trusted": "The host no longer trusts this device. Scan the QR code it shows, or type its short code."
|
||||
}
|
||||
},
|
||||
"desktop": {
|
||||
@@ -104,6 +107,9 @@
|
||||
"nobody": "Nobody yet. The link and the QR code next to this let people join.",
|
||||
"disconnect": "Disconnect",
|
||||
"disconnectHelp": "The device is cut off and cannot come back with this link.",
|
||||
"trust": "Trust",
|
||||
"trustHelp": "This device will come back without a QR code, to this share and the next ones. You can revoke it in the settings.",
|
||||
"trusted": "trusted",
|
||||
"refused": "Refused connections",
|
||||
"refusedNone": "No connection refused since this share started.",
|
||||
"unknownDevice": "unnamed device",
|
||||
@@ -112,7 +118,8 @@
|
||||
"token_used": "link already used by another device",
|
||||
"expired_token": "QR code expired or replaced",
|
||||
"kicked": "device disconnected by you",
|
||||
"room_full": "no seat left"
|
||||
"room_full": "no seat left",
|
||||
"not_trusted": "device not trusted, or wrong signature"
|
||||
},
|
||||
"sleepInhibited": "Sleep suspended while sharing",
|
||||
"sleepNotInhibited": "Sleep could not be suspended: the screen may turn off.",
|
||||
@@ -163,6 +170,10 @@
|
||||
"quitConfirm": "Quit and stop sharing",
|
||||
"dontAskAgain": "Don’t ask again",
|
||||
"confirmQuit": "Ask before quitting during a share",
|
||||
"trustedDevices": "Trusted devices",
|
||||
"trustedNone": "No trusted device. Use \"Trust\" next to a connected viewer.",
|
||||
"revoke": "Revoke",
|
||||
"revokeHelp": "The device loses its access now and needs the QR code to come back.",
|
||||
"diagnostics": "Export diagnostics",
|
||||
"diagnosticsHelp": "An archive you send yourself: no image, no window title, no MAC address.",
|
||||
"diagnosticsWritten": "Archive written: {path}",
|
||||
|
||||
+13
-2
@@ -48,6 +48,8 @@
|
||||
"language": "Langue",
|
||||
"insecureBadge": "non chiffré",
|
||||
"insecureHint": "La page et le signalement circulent en clair sur le réseau local. Le flux vidéo, lui, est chiffré de bout en bout (DTLS-SRTP).",
|
||||
"trustedBadge": "De confiance",
|
||||
"trustedHint": "L'hôte fait confiance à cet appareil : rouvrez cette adresse pour revenir, sans QR code.",
|
||||
"networkFallback": "Connexion perdue. Vérifiez que vous êtes sur le même réseau que l’hôte.",
|
||||
"errors": {
|
||||
"bad_token": "Ce lien ne correspond à aucune session de cet hôte. Scannez à nouveau son QR code, ou tapez son code court.",
|
||||
@@ -61,7 +63,8 @@
|
||||
"kicked": "L’hôte a déconnecté cet appareil. Demandez-lui un nouveau QR code pour revenir.",
|
||||
"share_ended": "L’hôte a arrêté le partage.",
|
||||
"network": "Connexion perdue après plusieurs tentatives. Vérifiez que vous êtes sur le même réseau que l’hôte. La connexion reprendra seule au retour du réseau, ou avec le bouton ci-dessous. Si l’hôte a redémarré, scannez à nouveau son QR code: l’adresse change à chaque démarrage.",
|
||||
"unsupported": "Ce navigateur ne prend pas en charge WebRTC."
|
||||
"unsupported": "Ce navigateur ne prend pas en charge WebRTC.",
|
||||
"not_trusted": "L'hôte ne fait plus confiance à cet appareil. Scannez le QR code qu'il affiche, ou tapez son code court."
|
||||
}
|
||||
},
|
||||
"desktop": {
|
||||
@@ -104,6 +107,9 @@
|
||||
"nobody": "Personne pour l’instant. Le lien et le QR code ci-contre permettent de rejoindre.",
|
||||
"disconnect": "Déconnecter",
|
||||
"disconnectHelp": "L’appareil est coupé et ne peut plus revenir avec ce lien.",
|
||||
"trust": "Faire confiance",
|
||||
"trustHelp": "Cet appareil reviendra sans QR code, à ce partage et aux suivants. Vous pouvez le révoquer dans les réglages.",
|
||||
"trusted": "de confiance",
|
||||
"refused": "Connexions refusées",
|
||||
"refusedNone": "Aucune connexion refusée depuis le début du partage.",
|
||||
"unknownDevice": "appareil sans nom",
|
||||
@@ -112,7 +118,8 @@
|
||||
"token_used": "lien déjà utilisé par un autre appareil",
|
||||
"expired_token": "QR code expiré ou remplacé",
|
||||
"kicked": "appareil déconnecté par vous",
|
||||
"room_full": "plus de place"
|
||||
"room_full": "plus de place",
|
||||
"not_trusted": "appareil non reconnu, ou signature fausse"
|
||||
},
|
||||
"sleepInhibited": "Mise en veille suspendue pendant le partage",
|
||||
"sleepNotInhibited": "La mise en veille n’a pas pu être suspendue: l’écran peut s’éteindre.",
|
||||
@@ -163,6 +170,10 @@
|
||||
"quitConfirm": "Quitter et arrêter le partage",
|
||||
"dontAskAgain": "Ne plus demander",
|
||||
"confirmQuit": "Demander avant de quitter pendant un partage",
|
||||
"trustedDevices": "Appareils de confiance",
|
||||
"trustedNone": "Aucun appareil de confiance. Utilisez « Faire confiance » à côté d'un spectateur connecté.",
|
||||
"revoke": "Révoquer",
|
||||
"revokeHelp": "L'appareil perd son accès tout de suite et devra rescanner le QR code pour revenir.",
|
||||
"diagnostics": "Exporter les diagnostics",
|
||||
"diagnosticsHelp": "Une archive à transmettre vous-même: ni image, ni titre de fenêtre, ni adresse MAC.",
|
||||
"diagnosticsWritten": "Archive écrite: {path}",
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ let
|
||||
version = "0.5.0";
|
||||
src = ../apps/viewer;
|
||||
|
||||
npmDepsHash = "sha256-vx3u0/6p9qomUQIC4NVyNmRxOWQG/QnVXjc0Rv3YNS4=";
|
||||
npmDepsHash = "sha256-LBgtO4fU8EEye11o+o+B/POwl+bdFvHuzB69r6iZQZI=";
|
||||
|
||||
nativeBuildInputs = [ pkgs.nodejs_22 ];
|
||||
|
||||
|
||||
Reference in new issue
Block a user