mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-09-13 13:19:05 +02:00
refactor: cleanup
This commit is contained in:
@@ -388,7 +388,10 @@ export function enableProfileSync(profileId: string): Promise<void> {
|
||||
* the operator happens to be sitting. Falls back to this machine's zone.
|
||||
*/
|
||||
export function profileTimezone(profile: BrowserProfile): string {
|
||||
const raw = profile.wayfern_config?.fingerprint;
|
||||
// Identity-backed profiles keep the exit's location in `location`; legacy
|
||||
// ones carry it inside the stored payload.
|
||||
const raw =
|
||||
profile.wayfern_config?.location ?? profile.wayfern_config?.fingerprint;
|
||||
if (raw) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as WayfernFingerprintConfig;
|
||||
|
||||
@@ -31,7 +31,11 @@ import { RippleButton } from "./ui/ripple";
|
||||
function getScreenSize(
|
||||
profile: BrowserProfile,
|
||||
): { w: number; h: number } | null {
|
||||
const fp = profile.wayfern_config?.fingerprint;
|
||||
// An identity-backed profile stores no device, only the user's edits, so a
|
||||
// screen size is available only when the user pinned one.
|
||||
const fp =
|
||||
profile.wayfern_config?.fingerprint ??
|
||||
profile.wayfern_config?.identity_overrides;
|
||||
if (!fp) return null;
|
||||
try {
|
||||
const parsed: WayfernFingerprintConfig = JSON.parse(fp);
|
||||
|
||||
@@ -65,9 +65,10 @@ export function WayfernConfigDialog({
|
||||
const handleSave = async () => {
|
||||
if (!profile) return;
|
||||
|
||||
if (config.fingerprint) {
|
||||
const storedJson = config.identity_overrides ?? config.fingerprint;
|
||||
if (storedJson) {
|
||||
try {
|
||||
JSON.parse(config.fingerprint);
|
||||
JSON.parse(storedJson);
|
||||
} catch (_error) {
|
||||
const { toast } = await import("sonner");
|
||||
toast.error(t("wayfernConfigDialog.invalidFingerprint"), {
|
||||
|
||||
@@ -55,7 +55,7 @@ const isFingerprintEditingDisabled = (config: WayfernConfig): boolean => {
|
||||
interface GeneratedFingerprint {
|
||||
fingerprint: string;
|
||||
identity_id: string | null;
|
||||
identity_baseline: string | null;
|
||||
location: string | null;
|
||||
}
|
||||
|
||||
const getCurrentOS = (): WayfernOS => {
|
||||
@@ -109,15 +109,18 @@ export function WayfernConfigForm({
|
||||
configJson,
|
||||
},
|
||||
);
|
||||
onConfigChange("fingerprint", result.fingerprint);
|
||||
// The identity travels with the fingerprint it produced. Storing one
|
||||
// without the other leaves a device the launch path cannot reproduce, so
|
||||
// it would be discarded and re-minted on the next launch.
|
||||
// An identity-backed profile stores the id, its location and the user's
|
||||
// edits, never the device: the browser rebuilds the device from the id
|
||||
// on every launch, so nothing worth copying is ever written to disk. A
|
||||
// legacy browser without the identity API still stores the payload.
|
||||
onConfigChange("identity_id", result.identity_id ?? undefined);
|
||||
onConfigChange("location", result.location ?? undefined);
|
||||
onConfigChange(
|
||||
"identity_baseline",
|
||||
result.identity_baseline ?? undefined,
|
||||
"fingerprint",
|
||||
result.identity_id ? undefined : result.fingerprint,
|
||||
);
|
||||
onConfigChange("identity_overrides", undefined);
|
||||
onConfigChange("identity_baseline", undefined);
|
||||
} catch (error) {
|
||||
console.error("Failed to generate fingerprint:", error);
|
||||
} finally {
|
||||
@@ -164,12 +167,16 @@ export function WayfernConfigForm({
|
||||
onConfigChange,
|
||||
]);
|
||||
|
||||
// What the form edits: the override map for an identity-backed profile
|
||||
// (only the user's own edits exist on disk), the whole payload for a legacy
|
||||
// one.
|
||||
const editedJson = config.identity_id
|
||||
? config.identity_overrides
|
||||
: config.fingerprint;
|
||||
useEffect(() => {
|
||||
if (config.fingerprint) {
|
||||
if (editedJson) {
|
||||
try {
|
||||
const parsed = JSON.parse(
|
||||
config.fingerprint,
|
||||
) as WayfernFingerprintConfig;
|
||||
const parsed = JSON.parse(editedJson) as WayfernFingerprintConfig;
|
||||
setFingerprintConfig(parsed);
|
||||
} catch (error) {
|
||||
console.error("Failed to parse fingerprint config:", error);
|
||||
@@ -178,7 +185,7 @@ export function WayfernConfigForm({
|
||||
} else {
|
||||
setFingerprintConfig({});
|
||||
}
|
||||
}, [config.fingerprint]);
|
||||
}, [editedJson]);
|
||||
|
||||
const updateFingerprintConfig = (
|
||||
key: keyof WayfernFingerprintConfig,
|
||||
@@ -200,7 +207,12 @@ export function WayfernConfigForm({
|
||||
|
||||
try {
|
||||
const jsonString = JSON.stringify(newConfig);
|
||||
onConfigChange("fingerprint", jsonString);
|
||||
onConfigChange(
|
||||
config.identity_id ? "identity_overrides" : "fingerprint",
|
||||
Object.keys(newConfig).length === 0 && config.identity_id
|
||||
? undefined
|
||||
: jsonString,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to serialize fingerprint config:", error);
|
||||
}
|
||||
|
||||
+3
-1
@@ -414,7 +414,9 @@ export interface WayfernConfig {
|
||||
os?: WayfernOS; // Operating system for fingerprint generation
|
||||
geo_proxy_signature?: string; // Internal: routing the fingerprint's location was computed for
|
||||
identity_id?: string; // Internal: UUID the device is derived from on browsers with the identity API
|
||||
identity_baseline?: string; // Internal: derived fingerprint before edits, diffed to recover overrides
|
||||
identity_baseline?: string; // Legacy: read once by the migration to identity-only storage, never written
|
||||
identity_overrides?: string; // JSON object of the user's own edits to an identity-backed device
|
||||
location?: string; // JSON object of the exit-derived location fields (timezone, language, coordinates)
|
||||
}
|
||||
|
||||
// Wayfern fingerprint config - matches the C++ FingerprintData structure
|
||||
|
||||
Reference in New Issue
Block a user