import { formatSize } from "@yaakapp-internal/lib/formatSize"; import type { Flow } from "@yaakapp-internal/proxy-lib"; import { Button, CONTROL_TOOLTIP_DELAY, formatMillis, Icon, Tooltip } from "@yaakapp-internal/ui"; import { useDecryptList, useEditDecryptList } from "../hooks/useDecryptList"; import { type DecryptSubject, detailActions, listEdit, setDecrypted } from "../lib/decrypt"; import { sidebarPath } from "../lib/search"; import { EmptyState } from "./FlowBodyViewer"; /** * The detail of HTTPS passed through undecrypted: its sizes and time, and buttons that add its * host or its app to the decrypt list, from the next connection on. */ export function NotDecrypted({ flow }: { flow: Flow }) { const list = useDecryptList(); const save = useEditDecryptList(); const host = sidebarPath(flow.url).split("/")[0] ?? flow.url; const hostSubject: DecryptSubject = { kind: "host", host }; const appSubject: DecryptSubject | null = flow.clientName == null ? null : { kind: "app", name: flow.clientName, bundleId: flow.clientBundleId }; const app = flow.clientName; const actions = detailActions( list, host, app == null ? null : { name: app, bundleId: flow.clientBundleId }, ); const open = flow.elapsedMs == null && flow.error == null; const decrypt = (subject: DecryptSubject) => save.mutate(listEdit(list, setDecrypted(list, [subject], true))); const facts = [ `${formatSize(Number(flow.requestSize))} sent`, `${formatSize(Number(flow.responseSize))} received`, open ? "open" : flow.elapsedMs == null ? null : formatMillis(flow.elapsedMs), ].filter((f) => f != null); return (
Not decrypted
{facts.join(" ยท ")}
{flow.error != null &&
{flow.error}
} {actions.listed ? (
Decrypting new connections
) : actions.blocked != null ? (
Excluded by {actions.blocked}
) : (
{actions.host && ( )} {actions.app && appSubject != null && ( )}
)}
); }