Scaffold flit: PWA + Go CLI for ephemeral E2E file transfer
Ports the yaw/2.1 identity/signaling/WebRTC transport from waste-go to both a browser PWA (with QR pairing and Web Share Target) and a headless Go CLI, trimmed to 1:1 ephemeral file transfer only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
28
pwa/src/pairing/keyring.ts
Normal file
28
pwa/src/pairing/keyring.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// Persistent trusted-peer list ("Add device" flow) — separate from the
|
||||
// ephemeral one-shot QR room pairing in pairing/ephemeral.ts.
|
||||
|
||||
export interface TrustedPeer {
|
||||
id: string // hex Ed25519 pubkey
|
||||
label: string
|
||||
addedAt: number
|
||||
}
|
||||
|
||||
const KEY = 'flit_keyring'
|
||||
|
||||
export function listTrusted(): TrustedPeer[] {
|
||||
try { return JSON.parse(localStorage.getItem(KEY) ?? '[]') } catch { return [] }
|
||||
}
|
||||
|
||||
export function addTrusted(id: string, label: string): void {
|
||||
const peers = listTrusted().filter(p => p.id !== id)
|
||||
peers.push({ id, label, addedAt: Date.now() })
|
||||
localStorage.setItem(KEY, JSON.stringify(peers))
|
||||
}
|
||||
|
||||
export function removeTrusted(id: string): void {
|
||||
localStorage.setItem(KEY, JSON.stringify(listTrusted().filter(p => p.id !== id)))
|
||||
}
|
||||
|
||||
export function isTrusted(id: string): boolean {
|
||||
return listTrusted().some(p => p.id === id)
|
||||
}
|
||||
Reference in New Issue
Block a user