@s4e/jsentinel
Version:
Script integrity and clipboard tamper detection for browsers.
57 lines (56 loc) • 1.39 kB
TypeScript
export type JSentinelEventType = "ready" | "script.ok" | "script.mismatch" | "scan.complete" | "clipboard.tamper" | "clipboard.permission" | "error";
export type JSentinelReason = "hash-different" | "manifest-missing-key" | "fetch-error" | "volatile-inline" | "url-pin-mismatch" | "insecure-http" | "unknown";
export type ScriptDetailBase = {
key: string;
src: string | null;
inline: boolean;
expected?: string;
got: string;
};
export type ScriptOkDetail = ScriptDetailBase & {
ok: true;
severity: "info";
};
export type ScriptMismatchDetail = ScriptDetailBase & {
ok: false;
severity: "error" | "warn";
reason: JSentinelReason;
};
export type ScanCompleteDetail = {
total: number;
ok: number;
mismatched: number;
};
export type JSentinelMessage = {
type: "ready";
data: {};
} | {
type: "script.ok";
data: ScriptOkDetail;
} | {
type: "script.mismatch";
data: ScriptMismatchDetail;
} | {
type: "scan.complete";
data: ScanCompleteDetail;
} | {
type: "clipboard.tamper";
data: {
expected: string;
got: string;
};
} | {
type: "clipboard.permission";
data: {};
} | {
type: "error";
data: {
stage: string;
message: string;
};
};
export type JSentinelOptions = {
manifestPath?: string;
watchClipboard?: boolean;
verboseChecks?: boolean;
};