@s4e/jsentinel
Version:
Script integrity and clipboard tamper detection for browsers.
124 lines (123 loc) • 3.26 kB
TypeScript
export type JSentinelEventType = "ready" | "alert" | "error" | "network.request" | "network.response" | "headers.checked" | "headers.error";
export type JSentinelReason = "hash-mismatch" | "not-in-manifest" | "fetch-failed" | "volatile-content" | "unpinned-url" | "insecure-protocol" | "unable-to-hash" | "watchdog-timeout" | "wasm-verification-failed" | "native-api-modified" | "suspicious-script-detected" | "excessive-form-access" | "clipboard-tamper" | "clipboard-permission-denied" | "csp-violation";
export declare const REASON_DESCRIPTIONS: Record<JSentinelReason, string>;
export type ScriptBlockedDetail = {
key: string;
src: string | null;
inline: boolean;
expected?: string;
got: string;
severity: "error" | "warn";
reason: JSentinelReason;
meta?: Record<string, unknown>;
};
export type AlertDetail = {
key: string;
src: string | null;
inline: boolean;
expected?: string;
got: string;
severity: "error" | "warn";
reason: JSentinelReason;
description?: string;
meta?: Record<string, unknown>;
userAgent?: string;
};
export type ScanSummary = {
total: number;
alerts: number;
verified: number;
};
export type RequestKind = "fetch" | "xhr" | "beacon";
export type NetworkRequestDetail = {
id: string;
kind: RequestKind;
url: string;
method: string;
ts: number;
};
export type NetworkResponseDetail = {
id: string;
kind: RequestKind;
url: string;
status: number | "opaque" | null;
ok: boolean | null;
duration_ms: number;
headers?: Record<string, string>;
size?: {
contentLength?: number;
transferSize?: number;
};
error?: string;
ts: number;
};
export type HeadersCheckedDetail = {
url: string;
status: number | "opaque";
headers: Record<string, string | undefined>;
ts: number;
};
export type HeadersErrorDetail = {
message: string;
ts: number;
};
export type CspViolationDetail = {
documentURI: string;
blockedURI: string;
effectiveDirective: string;
violatedDirective?: string;
originalPolicy?: string;
sourceFile?: string;
statusCode?: number;
lineNumber?: number;
columnNumber?: number;
sample?: string;
disposition?: "enforce" | "report";
referrer?: string;
ts: number;
};
export type JSentinelMessage = {
type: "ready";
data: {
version: string;
scan: ScanSummary;
};
} | {
type: "alert";
data: AlertDetail;
} | {
type: "error";
data: {
stage: string;
message: string;
};
} | {
type: "network.request";
data: NetworkRequestDetail;
} | {
type: "network.response";
data: NetworkResponseDetail;
} | {
type: "headers.checked";
data: HeadersCheckedDetail;
} | {
type: "headers.error";
data: HeadersErrorDetail;
};
export type JSentinelFeatures = {
clipboard?: boolean;
headers?: boolean;
csp?: boolean;
network?: boolean;
extension?: boolean;
};
export type JSentinelOptions = {
manifestPath?: string;
trustedHosts?: string[];
features?: JSentinelFeatures;
license: string;
splunkUrl?: string;
splunkToken?: string;
skipHostCheck?: boolean;
debug?: boolean;
};