Skip to content

Commit 1d691d1

Browse files
committed
docs: document clipboard protection + full ContentProtector options (ROADMAP #3)
Clipboard protection was integrated and tested but undocumented. Adds it to the README ContentProtector example, and replaces REFERENCE.md's stub with a complete "ContentProtector Options" table: every top-level option (type, default, description) plus per-strategy sub-tables for all 7 companion options interfaces (ClipboardOptions, WatermarkOptions, ContextMenuOptions, ScreenshotOptions, DevToolsOptions, BrowserExtensionOptions, FrameEmbeddingOptions). Notes that preventSelection/preventPrinting/ preventKeyboardShortcuts are boolean-only. README stays a curated quickstart that points to the reference. Also fixes the REFERENCE.md table of contents, which previously listed ~15 sections (Advanced Usage, API Reference, per-strategy docs, Utility Classes) that were never written — all dead anchors. TOC now reflects actual content. Completes ROADMAP item #3.
1 parent 0d77759 commit 1d691d1

3 files changed

Lines changed: 116 additions & 22 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,12 @@ const protector = new ContentProtector({
211211
preventDevTools: true,
212212
preventKeyboardShortcuts: true,
213213
preventPrinting: true,
214+
preventClipboard: true,
215+
clipboardOptions: { preventCopy: true, preventCut: true, preventPaste: false },
214216
enableWatermark: true,
215217
watermarkOptions: { text: 'Confidential', userId: 'user-123' },
218+
// …and more (selection, context menu, screenshots, extensions, iframe embedding)
219+
// — see REFERENCE.md for the complete options table.
216220
});
217221

218222
protector.protect();

REFERENCE.md

Lines changed: 111 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,14 @@ This document provides detailed usage information and API reference for the Shie
55
## Table of Contents
66

77
- [Basic Usage](#basic-usage)
8-
- [Advanced Usage](#advanced-usage)
9-
- [Custom Event Handlers](#custom-event-handlers)
10-
- [Using Individual Strategies](#using-individual-strategies)
11-
- [Updating Options](#updating-options)
12-
- [API Reference](#api-reference)
13-
- [ContentProtector](#contentprotector)
14-
- [Protection Strategies](#protection-strategies)
15-
- [ContextMenuStrategy](#contextmenustrategy)
16-
- [SelectionStrategy](#selectionstrategy)
17-
- [PrintStrategy](#printstrategy)
18-
- [KeyboardStrategy](#keyboardstrategy)
19-
- [DevToolsStrategy](#devtoolsstrategy)
20-
- [ScreenshotStrategy](#screenshotstrategy)
21-
- [WatermarkStrategy](#watermarkstrategy)
22-
- [BrowserExtensionDetectionStrategy](#browserextensiondetectionstrategy)
23-
- [FrameEmbeddingProtectionStrategy](#frameembeddingprotectionstrategy)
24-
- [Utility Classes](#utility-classes)
25-
- [SecurityOverlayManager](#securityoverlaymanager)
26-
- [ProtectedContentManager](#protectedcontentmanager)
27-
- [DomObserver](#domobserver)
8+
- [ContentProtector Options](#contentprotector-options)
9+
- [ClipboardOptions](#clipboardoptions)
10+
- [WatermarkOptions](#watermarkoptions)
11+
- [ContextMenuOptions](#contextmenuoptions)
12+
- [ScreenshotOptions](#screenshotoptions)
13+
- [DevToolsOptions](#devtoolsoptions)
14+
- [BrowserExtensionOptions](#browserextensionoptions)
15+
- [FrameEmbeddingOptions](#frameembeddingoptions)
2816

2917
## Basic Usage
3018

@@ -45,6 +33,15 @@ const protector = new ContentProtector({
4533
preventScreenshots: true,
4634
preventExtensions: true,
4735
preventEmbedding: true,
36+
37+
// Block copy/cut/paste (and the Clipboard API + execCommand)
38+
preventClipboard: true,
39+
clipboardOptions: {
40+
preventCopy: true, // default: true
41+
preventCut: true, // default: true
42+
preventPaste: false, // default: false
43+
replacementText: 'Content copying is disabled for security reasons.'
44+
},
4845

4946
// Enable watermarking
5047
enableWatermark: true,
@@ -63,4 +60,97 @@ protector.protect();
6360

6461
// Remove all protections when needed
6562
protector.unprotect();
66-
```
63+
```
64+
65+
## ContentProtector Options
66+
67+
All options are passed to the `ContentProtector` constructor. Every protection is **off by default** — you opt in per feature. Most `prevent*`/`enable*` toggles have an optional companion `*Options` object for fine-tuning; `preventSelection`, `preventPrinting`, and `preventKeyboardShortcuts` are boolean-only and take no further options.
68+
69+
| Option | Type | Default | Description |
70+
|--------|------|---------|-------------|
71+
| `targetElement` | `HTMLElement \| null` | `document.body` | Element to protect. |
72+
| `preventSelection` | `boolean` | `false` | Block text selection. |
73+
| `preventContextMenu` | `boolean` | `false` | Block the right-click context menu. |
74+
| `contextMenuOptions` | `ContextMenuOptions` || Context-menu behaviour (see below). |
75+
| `preventKeyboardShortcuts` | `boolean` | `false` | Block shortcuts (copy, save, print, screenshot keys). |
76+
| `preventPrinting` | `boolean` | `false` | Block printing and print-to-PDF. |
77+
| `preventClipboard` | `boolean` | `false` | Block copy/cut/paste events, the Clipboard API, and `execCommand`. |
78+
| `clipboardOptions` | `ClipboardOptions` || Per-operation clipboard control (see below). |
79+
| `preventScreenshots` | `boolean` | `false` | Detect screenshot attempts and respond. |
80+
| `screenshotOptions` | `ScreenshotOptions` || Screenshot response behaviour (see below). |
81+
| `preventDevTools` | `boolean` | `false` | Detect DevTools opening and respond. |
82+
| `devToolsOptions` | `DevToolsOptions` || DevTools detector configuration (see below). |
83+
| `preventExtensions` | `boolean` | `false` | Detect scraping/automation browser extensions. |
84+
| `extensionOptions` | `BrowserExtensionOptions` || Extension detection configuration (see below). |
85+
| `preventEmbedding` | `boolean` | `false` | Block the page from being embedded in an iframe. |
86+
| `frameEmbeddingOptions` | `FrameEmbeddingOptions` || Frame-embedding rules (see below). |
87+
| `enableWatermark` | `boolean` | `false` | Overlay a repeating watermark. |
88+
| `watermarkOptions` | `WatermarkOptions` || Watermark appearance (see below). |
89+
| `customHandlers` | `CustomEventHandlers` || Callbacks fired on protection events (`onPrintAttempt`, `onKeyboardShortcutBlocked`, `onDevToolsOpen`, `onProtectionBypassed`, …). |
90+
| `debugMode` | `boolean` | `false` | Verbose logging across all strategies. |
91+
92+
### `ClipboardOptions`
93+
94+
| Field | Type | Default | Description |
95+
|-------|------|---------|-------------|
96+
| `preventCopy` | `boolean` | `true` | Block copy operations. |
97+
| `preventCut` | `boolean` | `true` | Block cut operations. |
98+
| `preventPaste` | `boolean` | `false` | Block paste operations. |
99+
| `replacementText` | `string` | `"Content copying is disabled for security reasons."` | Text written to the clipboard in place of copied content. |
100+
101+
### `WatermarkOptions`
102+
103+
| Field | Type | Default | Description |
104+
|-------|------|---------|-------------|
105+
| `text` | `string` | _(required)_ | Watermark text. |
106+
| `userId` | `string` || Included in the watermark for traceability. |
107+
| `opacity` | `number` | `0.15` | Opacity, `0``1`. |
108+
| `density` | `number` | `3` | Pattern density, `1``10`. |
109+
| `style` | `Partial<CSSStyleDeclaration>` || Custom CSS applied to each watermark element. |
110+
111+
### `ContextMenuOptions`
112+
113+
| Field | Type | Default | Description |
114+
|-------|------|---------|-------------|
115+
| `observeForIframes` | `boolean` | `false` | Also protect iframes added to the DOM dynamically. |
116+
117+
### `ScreenshotOptions`
118+
119+
| Field | Type | Default | Description |
120+
|-------|------|---------|-------------|
121+
| `showOverlay` | `boolean` | `true` | Show a blocking overlay when a screenshot is detected. |
122+
| `overlayOptions` | `OverlayOptions` || Custom overlay appearance. |
123+
| `hideContent` | `boolean` | `true` | Hide protected content while triggered. |
124+
| `preventFullscreen` | `boolean` | `true` | Block fullscreen mode. |
125+
| `fullscreenMessage` | `string` || Message shown when fullscreen is attempted. |
126+
127+
### `DevToolsOptions`
128+
129+
| Field | Type | Default | Description |
130+
|-------|------|---------|-------------|
131+
| `checkFrequency` | `number` || Detector poll interval, in milliseconds. |
132+
| `showOverlay` | `boolean` | `true` | Show a blocking overlay when DevTools opens. |
133+
| `overlayOptions` | `OverlayOptions` || Custom overlay appearance. |
134+
| `hideContent` | `boolean` | `true` | Hide protected content while triggered. |
135+
| `detectorTypes` | `string[]` || Specific detectors to run; empty selects the optimal set for the current browser. |
136+
137+
### `BrowserExtensionOptions`
138+
139+
| Field | Type | Default | Description |
140+
|-------|------|---------|-------------|
141+
| `configPath` | `string` || Path to a JSON extension-signature config. |
142+
| `extensionsConfig` | `Record<string, ExtensionConfig>` || Inline extension signatures (alternative to `configPath`). |
143+
| `detectionInterval` | `number` || How often to scan for extensions, in milliseconds. |
144+
| `showOverlay` | `boolean` | `true` | Show a blocking overlay when an extension is detected. |
145+
| `overlayOptions` | `OverlayOptions` || Custom overlay appearance. |
146+
| `hideContent` | `boolean` | `true` | Hide protected content while triggered. |
147+
148+
### `FrameEmbeddingOptions`
149+
150+
| Field | Type | Default | Description |
151+
|-------|------|---------|-------------|
152+
| `allowedDomains` | `string[]` | `[]` | Domains permitted to embed the content; empty allows same-origin only. |
153+
| `blockAllFrames` | `boolean` | `false` | Block embedding in any iframe, even same-origin. |
154+
| `showOverlay` | `boolean` | `true` | Show a blocking overlay when embedding is detected. |
155+
| `overlayOptions` | `OverlayOptions` || Custom overlay appearance. |
156+
| `hideContent` | `boolean` | `true` | Hide protected content while triggered. |

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ If screenshot detection later grows more independent heuristics, adopt the DevTo
6363
- [x] Add `clipboardOptions` to `ContentProtectionOptions`
6464
- [x] Integrate ClipboardStrategy initialization in `ContentProtector.initializeStrategies()`
6565
- [x] Add unit tests for clipboard protection (`src/tests/strategies/ClipboardStrategy.test.ts`)
66-
- [ ] Update documentation
66+
- [x] Update documentation (README `ContentProtector` example + new complete "ContentProtector Options" table in REFERENCE.md covering `clipboardOptions` and all other strategy options)
6767

6868
---
6969

0 commit comments

Comments
 (0)