@tindalabs/shield 0.1.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.
Files changed (118) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +357 -0
  3. package/dist/assess.d.ts +16 -0
  4. package/dist/assess.js +220 -0
  5. package/dist/config/default-extensions-config.json +103 -0
  6. package/dist/core/ContentProtector.d.ts +63 -0
  7. package/dist/core/ContentProtector.js +281 -0
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +2 -0
  10. package/dist/core/mediator/ContentProtectionMediator.d.ts +86 -0
  11. package/dist/core/mediator/ContentProtectionMediator.js +238 -0
  12. package/dist/core/mediator/eventDataTypes.d.ts +112 -0
  13. package/dist/core/mediator/eventDataTypes.js +23 -0
  14. package/dist/core/mediator/handlers/abstractEventHandler.d.ts +41 -0
  15. package/dist/core/mediator/handlers/abstractEventHandler.js +59 -0
  16. package/dist/core/mediator/handlers/devToolsEventHandler.d.ts +9 -0
  17. package/dist/core/mediator/handlers/devToolsEventHandler.js +95 -0
  18. package/dist/core/mediator/handlers/eventHandlerRegistry.d.ts +9 -0
  19. package/dist/core/mediator/handlers/eventHandlerRegistry.js +34 -0
  20. package/dist/core/mediator/handlers/extensionEventHandlers.d.ts +40 -0
  21. package/dist/core/mediator/handlers/extensionEventHandlers.js +140 -0
  22. package/dist/core/mediator/handlers/iFrameEventHandlers.d.ts +27 -0
  23. package/dist/core/mediator/handlers/iFrameEventHandlers.js +93 -0
  24. package/dist/core/mediator/handlers/screenShotEventHandlers.d.ts +34 -0
  25. package/dist/core/mediator/handlers/screenShotEventHandlers.js +111 -0
  26. package/dist/core/mediator/protection-event.d.ts +77 -0
  27. package/dist/core/mediator/protection-event.js +32 -0
  28. package/dist/core/mediator/types.d.ts +105 -0
  29. package/dist/core/mediator/types.js +1 -0
  30. package/dist/index.d.ts +10 -0
  31. package/dist/index.js +7 -0
  32. package/dist/otel.d.ts +24 -0
  33. package/dist/otel.js +83 -0
  34. package/dist/policy.d.ts +98 -0
  35. package/dist/policy.js +97 -0
  36. package/dist/strategies/AbstractStrategy.d.ts +124 -0
  37. package/dist/strategies/AbstractStrategy.js +256 -0
  38. package/dist/strategies/ClipboardStrategy.d.ts +67 -0
  39. package/dist/strategies/ClipboardStrategy.js +291 -0
  40. package/dist/strategies/ContextMenuStrategy.d.ts +60 -0
  41. package/dist/strategies/ContextMenuStrategy.js +454 -0
  42. package/dist/strategies/DevToolsStrategy.d.ts +55 -0
  43. package/dist/strategies/DevToolsStrategy.js +314 -0
  44. package/dist/strategies/ExtensionStrategy.d.ts +66 -0
  45. package/dist/strategies/ExtensionStrategy.js +486 -0
  46. package/dist/strategies/IFrameStrategy.d.ts +49 -0
  47. package/dist/strategies/IFrameStrategy.js +255 -0
  48. package/dist/strategies/KeyboardStrategy.d.ts +35 -0
  49. package/dist/strategies/KeyboardStrategy.js +130 -0
  50. package/dist/strategies/PrintStrategy.d.ts +47 -0
  51. package/dist/strategies/PrintStrategy.js +201 -0
  52. package/dist/strategies/ScreenshotStrategy.d.ts +90 -0
  53. package/dist/strategies/ScreenshotStrategy.js +502 -0
  54. package/dist/strategies/SelectionStrategy.d.ts +49 -0
  55. package/dist/strategies/SelectionStrategy.js +216 -0
  56. package/dist/strategies/WatermarkStrategy.d.ts +56 -0
  57. package/dist/strategies/WatermarkStrategy.js +287 -0
  58. package/dist/strategies/index.d.ts +10 -0
  59. package/dist/strategies/index.js +11 -0
  60. package/dist/types/assessment.d.ts +62 -0
  61. package/dist/types/assessment.js +1 -0
  62. package/dist/types/index.d.ts +278 -0
  63. package/dist/types/index.js +17 -0
  64. package/dist/utils/DOMObserver.d.ts +68 -0
  65. package/dist/utils/DOMObserver.js +134 -0
  66. package/dist/utils/base/LoggableComponent.d.ts +44 -0
  67. package/dist/utils/base/LoggableComponent.js +56 -0
  68. package/dist/utils/detectors/AbstractDevToolsDetector.d.ts +98 -0
  69. package/dist/utils/detectors/AbstractDevToolsDetector.js +127 -0
  70. package/dist/utils/detectors/dateToStringDetector.d.ts +43 -0
  71. package/dist/utils/detectors/dateToStringDetector.js +96 -0
  72. package/dist/utils/detectors/debugLibDetector.d.ts +64 -0
  73. package/dist/utils/detectors/debugLibDetector.js +195 -0
  74. package/dist/utils/detectors/debuggerDetector.d.ts +51 -0
  75. package/dist/utils/detectors/debuggerDetector.js +211 -0
  76. package/dist/utils/detectors/defineGetterDetector.d.ts +48 -0
  77. package/dist/utils/detectors/defineGetterDetector.js +150 -0
  78. package/dist/utils/detectors/detectorInterface.d.ts +36 -0
  79. package/dist/utils/detectors/detectorInterface.js +1 -0
  80. package/dist/utils/detectors/devToolsDetectorManager.d.ts +88 -0
  81. package/dist/utils/detectors/devToolsDetectorManager.js +243 -0
  82. package/dist/utils/detectors/funcToStringDetector.d.ts +43 -0
  83. package/dist/utils/detectors/funcToStringDetector.js +90 -0
  84. package/dist/utils/detectors/regToStringDetector.d.ts +43 -0
  85. package/dist/utils/detectors/regToStringDetector.js +129 -0
  86. package/dist/utils/detectors/sizeDetector.d.ts +54 -0
  87. package/dist/utils/detectors/sizeDetector.js +134 -0
  88. package/dist/utils/detectors/timingDetector.d.ts +55 -0
  89. package/dist/utils/detectors/timingDetector.js +143 -0
  90. package/dist/utils/dom.d.ts +20 -0
  91. package/dist/utils/dom.js +83 -0
  92. package/dist/utils/environment.d.ts +29 -0
  93. package/dist/utils/environment.js +267 -0
  94. package/dist/utils/eventManager.d.ts +162 -0
  95. package/dist/utils/eventManager.js +548 -0
  96. package/dist/utils/index.d.ts +2 -0
  97. package/dist/utils/index.js +3 -0
  98. package/dist/utils/intervalManager.d.ts +91 -0
  99. package/dist/utils/intervalManager.js +221 -0
  100. package/dist/utils/keyboardShortcutManager/keyboardShortcutManager.d.ts +41 -0
  101. package/dist/utils/keyboardShortcutManager/keyboardShortcutManager.js +135 -0
  102. package/dist/utils/keyboardShortcutManager/keyboardShortcuts.d.ts +18 -0
  103. package/dist/utils/keyboardShortcutManager/keyboardShortcuts.js +195 -0
  104. package/dist/utils/logging/simple/Loggable.d.ts +33 -0
  105. package/dist/utils/logging/simple/Loggable.js +1 -0
  106. package/dist/utils/logging/simple/LoggingDelegate.d.ts +42 -0
  107. package/dist/utils/logging/simple/LoggingDelegate.js +53 -0
  108. package/dist/utils/logging/simple/SimpleLoggingService.d.ts +39 -0
  109. package/dist/utils/logging/simple/SimpleLoggingService.js +58 -0
  110. package/dist/utils/orientation.d.ts +15 -0
  111. package/dist/utils/orientation.js +32 -0
  112. package/dist/utils/protectedContentManager.d.ts +155 -0
  113. package/dist/utils/protectedContentManager.js +424 -0
  114. package/dist/utils/securityOverlayManager.d.ts +253 -0
  115. package/dist/utils/securityOverlayManager.js +786 -0
  116. package/dist/utils/timeoutManager.d.ts +50 -0
  117. package/dist/utils/timeoutManager.js +113 -0
  118. package/package.json +61 -0
@@ -0,0 +1,53 @@
1
+ import { SimpleLoggingService } from "./SimpleLoggingService";
2
+ /**
3
+ * Delegate class that implements logging functionality
4
+ * Can be composed into any class that needs logging
5
+ */
6
+ export class LoggingDelegate {
7
+ /**
8
+ * Create a new LoggingDelegate
9
+ * @param componentName Name of the component for log prefixing
10
+ * @param debugMode Whether debug mode is enabled
11
+ */
12
+ constructor(componentName, debugMode = false) {
13
+ this.logger = new SimpleLoggingService(componentName, debugMode);
14
+ }
15
+ /**
16
+ * Log a debug message if debug mode is enabled
17
+ * @param message Message to log
18
+ * @param args Additional arguments to log
19
+ */
20
+ log(message, ...args) {
21
+ this.logger.log(message, ...args);
22
+ }
23
+ /**
24
+ * Log a warning message
25
+ * @param message Warning message
26
+ * @param args Additional arguments to log
27
+ */
28
+ warn(message, ...args) {
29
+ this.logger.warn(message, ...args);
30
+ }
31
+ /**
32
+ * Log an error message
33
+ * @param message Error message
34
+ * @param args Additional arguments to log
35
+ */
36
+ error(message, ...args) {
37
+ this.logger.error(message, ...args);
38
+ }
39
+ /**
40
+ * Set debug mode
41
+ * @param enabled Whether debug mode should be enabled
42
+ */
43
+ setDebugMode(enabled) {
44
+ this.logger.setDebugMode(enabled);
45
+ }
46
+ /**
47
+ * Check if debug mode is enabled
48
+ * @returns Whether debug mode is enabled
49
+ */
50
+ isDebugEnabled() {
51
+ return this.logger.isDebugEnabled();
52
+ }
53
+ }
@@ -0,0 +1,39 @@
1
+ export declare class SimpleLoggingService {
2
+ private componentName;
3
+ private debugMode;
4
+ /**
5
+ * Create a new SimpleLoggingService
6
+ * for consistent logging across the toolkit
7
+ * @param componentName Name of the component for log prefixing
8
+ * @param debugMode Whether debug mode is enabled
9
+ */
10
+ constructor(componentName: string, debugMode?: boolean);
11
+ /**
12
+ * Log a debug message if debug mode is enabled
13
+ * @param message Message to log
14
+ * @param args Additional arguments to log
15
+ */
16
+ log(message: string, ...args: unknown[]): void;
17
+ /**
18
+ * Log a warning message
19
+ * @param message Warning message
20
+ * @param args Additional arguments to log
21
+ */
22
+ warn(message: string, ...args: unknown[]): void;
23
+ /**
24
+ * Log an error message
25
+ * @param message Error message
26
+ * @param args Additional arguments to log
27
+ */
28
+ error(message: string, ...args: unknown[]): void;
29
+ /**
30
+ * Set debug mode
31
+ * @param enabled Whether debug mode should be enabled
32
+ */
33
+ setDebugMode(enabled: boolean): void;
34
+ /**
35
+ * Get current debug mode
36
+ * @returns Whether debug mode is enabled
37
+ */
38
+ isDebugEnabled(): boolean;
39
+ }
@@ -0,0 +1,58 @@
1
+ export class SimpleLoggingService {
2
+ /**
3
+ * Create a new SimpleLoggingService
4
+ * for consistent logging across the toolkit
5
+ * @param componentName Name of the component for log prefixing
6
+ * @param debugMode Whether debug mode is enabled
7
+ */
8
+ constructor(componentName, debugMode = false) {
9
+ this.componentName = componentName;
10
+ this.debugMode = debugMode;
11
+ }
12
+ /**
13
+ * Log a debug message if debug mode is enabled
14
+ * @param message Message to log
15
+ * @param args Additional arguments to log
16
+ */
17
+ log(message, ...args) {
18
+ if (this.debugMode) {
19
+ console.log(`${this.componentName}: ${message}`, ...args);
20
+ }
21
+ }
22
+ /**
23
+ * Log a warning message
24
+ * @param message Warning message
25
+ * @param args Additional arguments to log
26
+ */
27
+ warn(message, ...args) {
28
+ if (this.debugMode) {
29
+ console.warn(`${this.componentName}: ${message}`, ...args);
30
+ }
31
+ else {
32
+ // In non-debug mode, only log the message without args for brevity
33
+ console.warn(`${this.componentName}: ${message}`);
34
+ }
35
+ }
36
+ /**
37
+ * Log an error message
38
+ * @param message Error message
39
+ * @param args Additional arguments to log
40
+ */
41
+ error(message, ...args) {
42
+ console.error(`${this.componentName}: ${message}`, ...args);
43
+ }
44
+ /**
45
+ * Set debug mode
46
+ * @param enabled Whether debug mode should be enabled
47
+ */
48
+ setDebugMode(enabled) {
49
+ this.debugMode = enabled;
50
+ }
51
+ /**
52
+ * Get current debug mode
53
+ * @returns Whether debug mode is enabled
54
+ */
55
+ isDebugEnabled() {
56
+ return this.debugMode;
57
+ }
58
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Check if the device is currently in landscape mode using the Screen Orientation API
3
+ * @returns true if in landscape mode, false if in portrait mode
4
+ */
5
+ export declare function isLandscape(): boolean;
6
+ /**
7
+ * Get the current orientation type
8
+ * @returns The orientation type string or null if not available
9
+ */
10
+ export declare function getOrientationType(): string | null;
11
+ /**
12
+ * Get the current orientation angle in degrees
13
+ * @returns The orientation angle in degrees or 0 if not available
14
+ */
15
+ export declare function getOrientationAngle(): number;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Check if the device is currently in landscape mode using the Screen Orientation API
3
+ * @returns true if in landscape mode, false if in portrait mode
4
+ */
5
+ export function isLandscape() {
6
+ if (typeof screen === 'undefined' || !screen.orientation) {
7
+ // Fallback to window dimensions if Screen Orientation API is not available
8
+ return window.innerWidth > window.innerHeight;
9
+ }
10
+ // Use Screen Orientation API
11
+ return screen.orientation.type.includes('landscape');
12
+ }
13
+ /**
14
+ * Get the current orientation type
15
+ * @returns The orientation type string or null if not available
16
+ */
17
+ export function getOrientationType() {
18
+ if (typeof screen === 'undefined' || !screen.orientation) {
19
+ return window.innerWidth > window.innerHeight ? 'landscape' : 'portrait';
20
+ }
21
+ return screen.orientation.type;
22
+ }
23
+ /**
24
+ * Get the current orientation angle in degrees
25
+ * @returns The orientation angle in degrees or 0 if not available
26
+ */
27
+ export function getOrientationAngle() {
28
+ if (typeof screen === 'undefined' || !screen.orientation) {
29
+ return 0;
30
+ }
31
+ return screen.orientation.angle;
32
+ }
@@ -0,0 +1,155 @@
1
+ import type { MediatorAware, ProtectionMediator } from "../core/mediator/types";
2
+ import { LoggableComponent } from "./base/LoggableComponent";
3
+ /**
4
+ * Options for the protected content placeholder
5
+ */
6
+ export interface PlaceholderOptions {
7
+ /**
8
+ * Title to display in the placeholder
9
+ */
10
+ title?: string;
11
+ /**
12
+ * Main message to display
13
+ */
14
+ message?: string;
15
+ /**
16
+ * Secondary message to display
17
+ */
18
+ secondaryMessage?: string;
19
+ /**
20
+ * Text color for the placeholder
21
+ */
22
+ textColor?: string;
23
+ /**
24
+ * Background color for the placeholder
25
+ */
26
+ backgroundColor?: string;
27
+ }
28
+ /**
29
+ * Utility class to manage protected content by hiding and revealing it
30
+ */
31
+ export declare class ProtectedContentManager extends LoggableComponent implements MediatorAware {
32
+ private mediator;
33
+ private targetElement;
34
+ private originalContent;
35
+ private contentStates;
36
+ private activeStateId;
37
+ private stateQueue;
38
+ private onContentHiddenCallback?;
39
+ private onContentRestoredCallback?;
40
+ private lastHideReason;
41
+ /**
42
+ * Create a new ProtectedContentManager
43
+ * @param targetElement Element containing sensitive content to protect
44
+ * @param debugMode Enable debug mode for troubleshooting
45
+ */
46
+ constructor(targetElement: HTMLElement, debugMode?: boolean);
47
+ /**
48
+ * Set the mediator to communicate with the other components
49
+ * @param mediator The protection mediator instance
50
+ */
51
+ setMediator(mediator: ProtectionMediator): void;
52
+ /**
53
+ * Handle content hidden event
54
+ * @param event The protection event containing content hidden data
55
+ */
56
+ private handleContentHidden;
57
+ /**
58
+ * Handle content restored event
59
+ * @param event The protection event containing content restored data
60
+ */
61
+ private handleContentRestored;
62
+ /**
63
+ * Register a new content state
64
+ * @param owner The strategy or component that owns this state
65
+ * @param reason The reason for hiding content
66
+ * @param options Options for the placeholder
67
+ * @param priority Priority for content hiding (higher numbers take precedence)
68
+ * @returns The ID of the registered content state
69
+ */
70
+ private registerContentState;
71
+ /**
72
+ * Add a content state to the queue
73
+ * @param stateId ID of the content state to add to queue
74
+ */
75
+ private addToQueue;
76
+ /**
77
+ * Apply a specific content state by ID
78
+ * @param stateId ID of the content state to apply
79
+ * @returns True if the state was applied successfully
80
+ */
81
+ private applyContentStateById;
82
+ /**
83
+ * Remove content states for a specific owner
84
+ * @param owner The owner to remove states for
85
+ * @returns The number of states removed
86
+ */
87
+ private removeContentStatesByOwner;
88
+ /**
89
+ * Hide the original content and replace it with a placeholder
90
+ * @param options Options for customizing the placeholder
91
+ * @returns True if content was hidden, false if there was no content to hide
92
+ */
93
+ hideContent(options: PlaceholderOptions): boolean;
94
+ /**
95
+ * Restore the original content
96
+ * @returns True if content was restored, false if there was no content to restore
97
+ */
98
+ restoreContent(): boolean;
99
+ /**
100
+ * Check if content is currently hidden
101
+ * @returns True if content is hidden, false otherwise
102
+ */
103
+ isContentHidden(): boolean;
104
+ /**
105
+ * Get the currently active content state ID
106
+ * @returns The active content state ID or null if none is active
107
+ */
108
+ getActiveContentStateId(): string | null;
109
+ /**
110
+ * Get all content states for a specific owner
111
+ * @param owner The owner to get states for
112
+ * @returns Array of content state IDs
113
+ */
114
+ getContentStatesByOwner(owner: string): string[];
115
+ /**
116
+ * Update the target element
117
+ * @param element New target element
118
+ */
119
+ updateTargetElement(element: HTMLElement): void;
120
+ /**
121
+ * Get the current target element
122
+ * @returns The current target element
123
+ */
124
+ getTargetElement(): HTMLElement;
125
+ /**
126
+ * Set callbacks for content visibility changes
127
+ * Useful for frameworks like Vue that need to re-mount components after content restoration
128
+ * @param onHidden Callback invoked when content is hidden
129
+ * @param onRestored Callback invoked when content is restored
130
+ */
131
+ setContentCallbacks(onHidden?: (reason: string, targetElement: HTMLElement | null) => void, onRestored?: (targetElement: HTMLElement | null) => void): void;
132
+ /**
133
+ * Clear all content states
134
+ * @returns The number of states removed
135
+ */
136
+ clearAllContentStates(): number;
137
+ /**
138
+ * Get debug information about content states
139
+ * @returns Object with debug information
140
+ */
141
+ getDebugInfo(): {
142
+ totalStates: number;
143
+ statesByOwner: Record<string, number>;
144
+ statesByReason: Record<string, number>;
145
+ activeStateId: string | null;
146
+ queueLength: number;
147
+ stateDetails: Array<{
148
+ id: string;
149
+ owner: string;
150
+ reason: string;
151
+ priority: number;
152
+ hiddenAt: number;
153
+ }>;
154
+ };
155
+ }