mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-16 08:31:57 +02:00
The body commands took a path from the client, so a token holder could read any file the process could. They now take a response id and resolve the location themselves, and the UI never sees a path at all: the desktop host asks the backend where the file is, and the bridge fetches /responses/:id/body. Ephemeral responses (GraphQL introspection) never reach the database, so resolution falls back to the path send writes them to.
30 lines
868 B
TypeScript
30 lines
868 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
interface Props {
|
|
/** A URL the host resolved, for a body it already stored. */
|
|
url?: string;
|
|
data?: Uint8Array;
|
|
mimeType?: string;
|
|
}
|
|
|
|
export function VideoViewer({ url, data, mimeType }: Props) {
|
|
const [src, setSrc] = useState<string>();
|
|
|
|
useEffect(() => {
|
|
if (url) {
|
|
setSrc(url);
|
|
} else if (data) {
|
|
// As in AudioViewer: a media element trusts the declared type instead of sniffing
|
|
const blob = new Blob([new Uint8Array(data)], { type: mimeType ?? "video/mp4" });
|
|
const objectUrl = URL.createObjectURL(blob);
|
|
setSrc(objectUrl);
|
|
return () => URL.revokeObjectURL(objectUrl);
|
|
} else {
|
|
setSrc(undefined);
|
|
}
|
|
}, [url, data, mimeType]);
|
|
|
|
// oxlint-disable-next-line jsx-a11y/media-has-caption
|
|
return <video className="w-full" controls src={src} />;
|
|
}
|