import React from "react";
import { getMemory } from "../memory";
import { RequestCluster } from "../request-cluster";
import { Sources, StolenDataEntry } from "../stolen-data-entry";
import { useEmitter } from "../util";
const MAX_STRING_VALUE_LENGTH = 100;
function StolenDataValue({
entry,
}: {
entry: StolenDataEntry;
prefixKey?: string;
}) {
const [version] = useEmitter(entry);
let body = null;
if (!entry.value) {
body = <>>;
} else {
body = (
{entry.value.slice(0, MAX_STRING_VALUE_LENGTH)}{" "}
{entry.value.length > MAX_STRING_VALUE_LENGTH ? "(...)" : ""}
);
}
return (
{
entry.toggleMark();
e.stopPropagation();
}}
>
{body}
);
}
const icons: Record = {
cookie: "🍪",
pathname: "🛣",
queryparams: "🅿",
header: "H",
};
function StolenDataRow({
entry,
cluster,
}: {
entry: StolenDataEntry;
cluster: RequestCluster;
}) {
const [version] = useEmitter(entry);
return (
entry.toggleMark()}
/>
|
entry.toggleMark()}
>
{entry.name}
|
{[entry.source].map((source) => icons[source])} |
|
);
}
export default function StolenDataCluster({
origin,
shorthost,
minValueLength,
cookiesOnly,
cookiesOrOriginOnly,
}: {
origin: string;
shorthost: string;
refreshToken: number;
minValueLength: number;
cookiesOnly: boolean;
cookiesOrOriginOnly: boolean;
}) {
const cluster = getMemory().getClustersForOrigin(origin)[shorthost];
return (
{cluster.getFullHosts().map((host) => (
{host},
))}
{cluster
.getRepresentativeStolenData({
minValueLength,
cookiesOnly,
cookiesOrOriginOnly,
})
.map((entry) => (
))}
);
}