@nextgensoftwares/folio-plugin-protect
Protected reading in the browser: canvas pages with layers baked in, copy and print deterrents, tamper detection, and a pager for server-rendered page images. Guides: Reader & protection, Protected reading.
Components
| Export | Description |
|---|---|
canvasPages(options) | ComponentType<PageViewProps> for <FolioView pageComponent>: pages painted to <canvas>, guarded |
type CanvasPagesOptions | painters, math, images, resolveSrc, forensic, onTamper, beforeRender, maxScale |
FolioProtect, type FolioProtectProps | wrapper: copy/print/select/context-menu/drag rules, blur on focus loss or devtools, audit hooks |
type BlockedAction | 'copy' | 'print' | 'save' | 'contextmenu' | 'drag' | 'select' |
FolioImagePager, type FolioImagePagerProps, type FolioImagePagerHandle | server page images with scroll/page/spread modes, lazy loading, prefetch, keyboard and swipe; pageAccess locks pages without requesting their images; the handle is a ReaderTarget |
ImagePage, type ImagePageProps | one lazily loaded page image (canvas or <img>) |
Browser rendering
| Export | Description |
|---|---|
rasterizePageInBrowser(options) | a PageRasterizer for exportFlattenedPdf (PNG or JPEG via OffscreenCanvas) |
browserImageLoader(resolveSrc?) | CORS <img> loader returning LoadedImage |
canvasMathFromHtml(render) | canvas math from KaTeX HTML (vector glyphs, rules, paths) |
browserPath2d(d) | Path2D factory for render-canvas |
createPageCanvas(width, height) | OffscreenCanvas, else a <canvas> |
Tamper detection
| Export | Description |
|---|---|
diagnose(snapshot, expectation) | pure check → TamperKind[] |
type TamperKind | 'removed' | 'injected' | 'style' | 'resized' | 'hidden' | 'pixels' | 'stylesheet' |
type TamperEvent, type TamperHandler | { kind, page?, detail?, at } and its callback |
type PageSnapshot, type PageExpectation | what the guard reads and expects |
pixelChecksum(data, width, height) | sampled checksum of RGBA pixels |
tamperReporter(handler, windowMs?, now?) | rate-limited reporting (one per kind and page per window); a throwing handler is contained |
guardPage(options), type GuardHandle | MutationObserver + periodic check that repairs and reports |
snapshot(...), canvasChecksum(canvas) | DOM readers used by the guard |
Copy, print, devtools
| Export | Description |
|---|---|
limitCopy(text, policy, used?), type CopyPolicy, type CopyDecision | applies 'allow' | 'block' | { maxChars, budget } |
blockedShortcut(event, opts) | Ctrl/Cmd+P, S, U → 'print' | 'save' | null |
devtoolsLikelyOpen(window, threshold?) | docked-devtools heuristic (deterrent only) |
obscureReason(state, opts), type ObscureReason | why to blur: 'blur' | 'hidden' | 'devtools' | null |
protectCss, ensureProtectCss(doc, nonce?), PROTECT_STYLE_ID | the protection stylesheet |