content-security-toolkit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +171 -0
- package/dist/config/default-extensions-config.json +103 -0
- package/dist/core/ContentProtector.d.ts +63 -0
- package/dist/core/ContentProtector.js +279 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/mediator/ContentProtectionMediator.d.ts +86 -0
- package/dist/core/mediator/ContentProtectionMediator.js +238 -0
- package/dist/core/mediator/eventDataTypes.d.ts +205 -0
- package/dist/core/mediator/eventDataTypes.js +23 -0
- package/dist/core/mediator/handlers/abstractEventHandler.d.ts +67 -0
- package/dist/core/mediator/handlers/abstractEventHandler.js +106 -0
- package/dist/core/mediator/handlers/baseEventHandler.d.ts +65 -0
- package/dist/core/mediator/handlers/baseEventHandler.js +99 -0
- package/dist/core/mediator/handlers/devToolsEventHandler.d.ts +9 -0
- package/dist/core/mediator/handlers/devToolsEventHandler.js +95 -0
- package/dist/core/mediator/handlers/eventHandlerRegistry.d.ts +9 -0
- package/dist/core/mediator/handlers/eventHandlerRegistry.js +34 -0
- package/dist/core/mediator/handlers/extensionEventHandlers.d.ts +40 -0
- package/dist/core/mediator/handlers/extensionEventHandlers.js +140 -0
- package/dist/core/mediator/handlers/iFrameEventHandlers.d.ts +27 -0
- package/dist/core/mediator/handlers/iFrameEventHandlers.js +93 -0
- package/dist/core/mediator/handlers/index.d.ts +9 -0
- package/dist/core/mediator/handlers/index.js +34 -0
- package/dist/core/mediator/handlers/screenShotEventHandlers.d.ts +34 -0
- package/dist/core/mediator/handlers/screenShotEventHandlers.js +111 -0
- package/dist/core/mediator/protection-event.d.ts +94 -0
- package/dist/core/mediator/protection-event.js +43 -0
- package/dist/core/mediator/types.d.ts +105 -0
- package/dist/core/mediator/types.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/strategies/AbstractStrategy.d.ts +152 -0
- package/dist/strategies/AbstractStrategy.js +296 -0
- package/dist/strategies/AbstractStrategy.mediator.d.ts +162 -0
- package/dist/strategies/AbstractStrategy.mediator.js +349 -0
- package/dist/strategies/ClipboardStrategy.d.ts +67 -0
- package/dist/strategies/ClipboardStrategy.js +291 -0
- package/dist/strategies/ContextMenuStrategy.d.ts +60 -0
- package/dist/strategies/ContextMenuStrategy.js +454 -0
- package/dist/strategies/DevToolsStrategy copy.d.ts +85 -0
- package/dist/strategies/DevToolsStrategy copy.js +362 -0
- package/dist/strategies/DevToolsStrategy-detectorManager.d.ts +70 -0
- package/dist/strategies/DevToolsStrategy-detectorManager.js +309 -0
- package/dist/strategies/DevToolsStrategy-simple.d.ts +75 -0
- package/dist/strategies/DevToolsStrategy-simple.js +366 -0
- package/dist/strategies/DevToolsStrategy.d.ts +55 -0
- package/dist/strategies/DevToolsStrategy.js +314 -0
- package/dist/strategies/ExtensionStrategy.d.ts +66 -0
- package/dist/strategies/ExtensionStrategy.js +486 -0
- package/dist/strategies/IFrameStrategy.d.ts +49 -0
- package/dist/strategies/IFrameStrategy.js +255 -0
- package/dist/strategies/KeyboardStrategy.d.ts +35 -0
- package/dist/strategies/KeyboardStrategy.js +130 -0
- package/dist/strategies/PrintStrategy.d.ts +47 -0
- package/dist/strategies/PrintStrategy.js +201 -0
- package/dist/strategies/ScreenshotStrategy.d.ts +90 -0
- package/dist/strategies/ScreenshotStrategy.js +488 -0
- package/dist/strategies/SelectionStrategy.d.ts +49 -0
- package/dist/strategies/SelectionStrategy.js +216 -0
- package/dist/strategies/StrategyRegistry.d.ts +133 -0
- package/dist/strategies/StrategyRegistry.js +379 -0
- package/dist/strategies/WatermarkStrategy.d.ts +47 -0
- package/dist/strategies/WatermarkStrategy.js +273 -0
- package/dist/strategies/index.d.ts +9 -0
- package/dist/strategies/index.js +10 -0
- package/dist/types/index.d.ts +271 -0
- package/dist/types/index.js +16 -0
- package/dist/utils/DOMObserver.d.ts +68 -0
- package/dist/utils/DOMObserver.js +134 -0
- package/dist/utils/base/LoggableComponent.d.ts +62 -0
- package/dist/utils/base/LoggableComponent.js +95 -0
- package/dist/utils/debuggerDetector/debuggerDetectionWorker.d.ts +6 -0
- package/dist/utils/debuggerDetector/debuggerDetectionWorker.js +24 -0
- package/dist/utils/debuggerDetector/debuggerDetector.d.ts +55 -0
- package/dist/utils/debuggerDetector/debuggerDetector.js +158 -0
- package/dist/utils/debuggerDetector/firefoxDetector.d.ts +8 -0
- package/dist/utils/debuggerDetector/firefoxDetector.js +64 -0
- package/dist/utils/detection.d.ts +29 -0
- package/dist/utils/detection.js +267 -0
- package/dist/utils/detectors/AbstractDevToolsDetector.d.ts +105 -0
- package/dist/utils/detectors/AbstractDevToolsDetector.js +136 -0
- package/dist/utils/detectors/dateToStringDetector.d.ts +43 -0
- package/dist/utils/detectors/dateToStringDetector.js +96 -0
- package/dist/utils/detectors/debugLibDetector.d.ts +64 -0
- package/dist/utils/detectors/debugLibDetector.js +195 -0
- package/dist/utils/detectors/debuggerDetectionWorker.d.ts +6 -0
- package/dist/utils/detectors/debuggerDetectionWorker.js +24 -0
- package/dist/utils/detectors/debuggerDetector.d.ts +51 -0
- package/dist/utils/detectors/debuggerDetector.js +211 -0
- package/dist/utils/detectors/defineGetterDetector.d.ts +48 -0
- package/dist/utils/detectors/defineGetterDetector.js +150 -0
- package/dist/utils/detectors/detectorInterface.d.ts +36 -0
- package/dist/utils/detectors/detectorInterface.js +1 -0
- package/dist/utils/detectors/devToolsDetectorManager.d.ts +88 -0
- package/dist/utils/detectors/devToolsDetectorManager.js +246 -0
- package/dist/utils/detectors/firefoxDetector.d.ts +8 -0
- package/dist/utils/detectors/firefoxDetector.js +64 -0
- package/dist/utils/detectors/funcToStringDetector.d.ts +43 -0
- package/dist/utils/detectors/funcToStringDetector.js +90 -0
- package/dist/utils/detectors/regToStringDetector.d.ts +43 -0
- package/dist/utils/detectors/regToStringDetector.js +129 -0
- package/dist/utils/detectors/sizeDetector.d.ts +54 -0
- package/dist/utils/detectors/sizeDetector.js +134 -0
- package/dist/utils/detectors/timingDetector.d.ts +55 -0
- package/dist/utils/detectors/timingDetector.js +143 -0
- package/dist/utils/dom.d.ts +20 -0
- package/dist/utils/dom.js +83 -0
- package/dist/utils/environment.d.ts +29 -0
- package/dist/utils/environment.js +267 -0
- package/dist/utils/eventManager.d.ts +167 -0
- package/dist/utils/eventManager.js +556 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/intervalManager.d.ts +96 -0
- package/dist/utils/intervalManager.js +229 -0
- package/dist/utils/keyboardShortcutManager/keyboardShortcutManager.d.ts +41 -0
- package/dist/utils/keyboardShortcutManager/keyboardShortcutManager.js +135 -0
- package/dist/utils/keyboardShortcutManager/keyboardShortcuts.d.ts +18 -0
- package/dist/utils/keyboardShortcutManager/keyboardShortcuts.js +195 -0
- package/dist/utils/logging/LogLevel.d.ts +21 -0
- package/dist/utils/logging/LogLevel.js +46 -0
- package/dist/utils/logging/LoggingConfig.d.ts +68 -0
- package/dist/utils/logging/LoggingConfig.js +64 -0
- package/dist/utils/logging/LoggingFactory.d.ts +22 -0
- package/dist/utils/logging/LoggingFactory.js +61 -0
- package/dist/utils/logging/LoggingService.d.ts +235 -0
- package/dist/utils/logging/LoggingService.js +385 -0
- package/dist/utils/logging/SimpleLoggingService.d.ts +39 -0
- package/dist/utils/logging/SimpleLoggingService.js +58 -0
- package/dist/utils/logging/advanced/LogLevel.d.ts +21 -0
- package/dist/utils/logging/advanced/LogLevel.js +46 -0
- package/dist/utils/logging/advanced/LoggingConfig.d.ts +68 -0
- package/dist/utils/logging/advanced/LoggingConfig.js +64 -0
- package/dist/utils/logging/advanced/LoggingFactory.d.ts +22 -0
- package/dist/utils/logging/advanced/LoggingFactory.js +61 -0
- package/dist/utils/logging/advanced/LoggingService.d.ts +235 -0
- package/dist/utils/logging/advanced/LoggingService.js +385 -0
- package/dist/utils/logging/simple/Loggable.d.ts +33 -0
- package/dist/utils/logging/simple/Loggable.js +1 -0
- package/dist/utils/logging/simple/LoggingDelegate.d.ts +42 -0
- package/dist/utils/logging/simple/LoggingDelegate.js +53 -0
- package/dist/utils/logging/simple/SimpleLoggingService.d.ts +39 -0
- package/dist/utils/logging/simple/SimpleLoggingService.js +58 -0
- package/dist/utils/orientation.d.ts +15 -0
- package/dist/utils/orientation.js +32 -0
- package/dist/utils/protectedContentManager-simple.d.ts +86 -0
- package/dist/utils/protectedContentManager-simple.js +180 -0
- package/dist/utils/protectedContentManager.d.ts +162 -0
- package/dist/utils/protectedContentManager.js +427 -0
- package/dist/utils/screenshotDetector.d.ts +72 -0
- package/dist/utils/screenshotDetector.js +179 -0
- package/dist/utils/securityOverlayManager-observer-pause.d.ts +283 -0
- package/dist/utils/securityOverlayManager-observer-pause.js +878 -0
- package/dist/utils/securityOverlayManager-simple.d.ts +197 -0
- package/dist/utils/securityOverlayManager-simple.js +552 -0
- package/dist/utils/securityOverlayManager.d.ts +260 -0
- package/dist/utils/securityOverlayManager.js +774 -0
- package/dist/utils/timeoutManager.d.ts +55 -0
- package/dist/utils/timeoutManager.js +121 -0
- package/package.json +54 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { MediatorAware, ProtectionMediator } from "../core/mediator/types";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the security overlay
|
|
4
|
+
*/
|
|
5
|
+
export interface OverlayOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Title to display in the overlay
|
|
8
|
+
*/
|
|
9
|
+
title?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Main message to display
|
|
12
|
+
*/
|
|
13
|
+
message?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Secondary message to display
|
|
16
|
+
*/
|
|
17
|
+
secondaryMessage?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Text color for the overlay
|
|
20
|
+
*/
|
|
21
|
+
textColor?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Background color for the overlay
|
|
24
|
+
*/
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Z-index for the overlay (default: 2147483647)
|
|
28
|
+
*/
|
|
29
|
+
zIndex?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to show a close button
|
|
32
|
+
*/
|
|
33
|
+
showCloseButton?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Text for the close button
|
|
36
|
+
*/
|
|
37
|
+
closeButtonText?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Callback when close button is clicked
|
|
40
|
+
*/
|
|
41
|
+
onCloseButtonClick?: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Duration in milliseconds to show the overlay (0 for indefinite)
|
|
44
|
+
*/
|
|
45
|
+
duration?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Additional custom styles for the overlay
|
|
48
|
+
*/
|
|
49
|
+
customStyles?: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Additional custom styles for the text
|
|
52
|
+
*/
|
|
53
|
+
textStyles?: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Font size (ScreenshotStrategy - refactor)
|
|
56
|
+
*/
|
|
57
|
+
fontSize?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Additional HTML content to display in the overlay
|
|
60
|
+
*/
|
|
61
|
+
additionalContent?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Whether to block events (create an event blocker)
|
|
64
|
+
*/
|
|
65
|
+
blockEvents?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether to automatically restore the overlay if it's removed from the DOM
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
autoRestore?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Utility class to manage security overlays
|
|
74
|
+
*/
|
|
75
|
+
export declare class SecurityOverlayManager implements MediatorAware {
|
|
76
|
+
readonly COMPONENT_NAME = "SecurityOverlayManager";
|
|
77
|
+
private mediator;
|
|
78
|
+
private overlayElement;
|
|
79
|
+
private eventBlocker;
|
|
80
|
+
private overlayTimeout;
|
|
81
|
+
private debugMode;
|
|
82
|
+
private domObserver;
|
|
83
|
+
private currentOptions;
|
|
84
|
+
private autoRestoreEnabled;
|
|
85
|
+
private isActive;
|
|
86
|
+
private documentWheelHandler;
|
|
87
|
+
private windowWheelHandler;
|
|
88
|
+
private documentTouchMoveHandler;
|
|
89
|
+
private windowTouchMoveHandler;
|
|
90
|
+
private onElementsRemovedCallbacks;
|
|
91
|
+
/**
|
|
92
|
+
* Create a new SecurityOverlayManager
|
|
93
|
+
* @param debugMode Enable debug mode for troubleshooting
|
|
94
|
+
*/
|
|
95
|
+
constructor(debugMode?: boolean);
|
|
96
|
+
/**
|
|
97
|
+
* Set the mediator
|
|
98
|
+
* to communicate with the other components
|
|
99
|
+
*/
|
|
100
|
+
setMediator(mediator: ProtectionMediator): void;
|
|
101
|
+
/**
|
|
102
|
+
* Handle overlay shown event
|
|
103
|
+
*/
|
|
104
|
+
private handleOverlayShown;
|
|
105
|
+
/**
|
|
106
|
+
* Handle overlay removed event
|
|
107
|
+
*/
|
|
108
|
+
private handleOverlayRemoved;
|
|
109
|
+
/**
|
|
110
|
+
* Handle overlay restored event
|
|
111
|
+
*/
|
|
112
|
+
private handleOverlayRestored;
|
|
113
|
+
/**
|
|
114
|
+
* Show a security overlay
|
|
115
|
+
* @param options Options for the overlay
|
|
116
|
+
* @returns Object containing the created overlay and event blocker elements
|
|
117
|
+
*/
|
|
118
|
+
showOverlay(options: OverlayOptions): {
|
|
119
|
+
overlay: HTMLElement | null;
|
|
120
|
+
blocker: HTMLElement | null;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Remove the security overlay and clean up all event listeners
|
|
124
|
+
* @param disableAutoRestore Whether to disable auto-restoration when removing
|
|
125
|
+
*/
|
|
126
|
+
removeOverlay(disableAutoRestore?: boolean): void;
|
|
127
|
+
/**
|
|
128
|
+
* Disable auto-restoration of the overlay
|
|
129
|
+
* This should be called when the condition that triggered the overlay is no longer true
|
|
130
|
+
*/
|
|
131
|
+
disableAutoRestore(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Check if the manager is active
|
|
134
|
+
* This returns true if the overlay is supposed to be shown, regardless of whether it's currently
|
|
135
|
+
* in the DOM or has been removed by external forces
|
|
136
|
+
*/
|
|
137
|
+
isOverlayActive(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Ensure the overlay is restored if it should be active but isn't displayed
|
|
140
|
+
* This is useful for external components to check if the overlay should be restored
|
|
141
|
+
*/
|
|
142
|
+
checkAndRestoreOverlay(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Remove global event listeners that were added to document and window
|
|
145
|
+
*/
|
|
146
|
+
private removeGlobalEventListeners;
|
|
147
|
+
/**
|
|
148
|
+
* Create an overlay element
|
|
149
|
+
* @param options Options for the overlay
|
|
150
|
+
* @returns The created overlay element
|
|
151
|
+
*/
|
|
152
|
+
private createOverlay;
|
|
153
|
+
/**
|
|
154
|
+
* Create an event blocker that prevents interaction with the page
|
|
155
|
+
* @returns The created event blocker element
|
|
156
|
+
*/
|
|
157
|
+
private createEventBlocker;
|
|
158
|
+
/**
|
|
159
|
+
* Set up DOM observer to detect when overlay elements are removed
|
|
160
|
+
*/
|
|
161
|
+
private setupObserver;
|
|
162
|
+
/**
|
|
163
|
+
* Notify all callbacks when elements are removed
|
|
164
|
+
*/
|
|
165
|
+
private notifyElementsRemovedCallbacks;
|
|
166
|
+
/**
|
|
167
|
+
* Add a callback to be called when overlay elements are removed
|
|
168
|
+
* @param callback Callback function
|
|
169
|
+
*/
|
|
170
|
+
addElementsRemovedCallback(callback: (removedElements: HTMLElement[]) => void): void;
|
|
171
|
+
/**
|
|
172
|
+
* Remove a callback
|
|
173
|
+
* @param callback Callback function to remove
|
|
174
|
+
*/
|
|
175
|
+
removeElementsRemovedCallback(callback: (removedElements: HTMLElement[]) => void): void;
|
|
176
|
+
/**
|
|
177
|
+
* Check if an overlay is currently displayed
|
|
178
|
+
* @returns True if an overlay is displayed, false otherwise
|
|
179
|
+
*/
|
|
180
|
+
isOverlayDisplayed(): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Get the current overlay element
|
|
183
|
+
* @returns The current overlay element or null if none exists
|
|
184
|
+
*/
|
|
185
|
+
getOverlayElement(): HTMLElement | null;
|
|
186
|
+
/**
|
|
187
|
+
* Get the current event blocker element
|
|
188
|
+
* @returns The current event blocker element or null if none exists
|
|
189
|
+
*/
|
|
190
|
+
getEventBlocker(): HTMLElement | null;
|
|
191
|
+
/**
|
|
192
|
+
* Check if the overlay exists in the DOM
|
|
193
|
+
* This is different from isOverlayDisplayed() which checks if the manager has a reference
|
|
194
|
+
* @returns True if the overlay exists in the DOM, false otherwise
|
|
195
|
+
*/
|
|
196
|
+
doesOverlayExistInDOM(): boolean;
|
|
197
|
+
}
|