@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,50 @@
1
+ import { LoggableComponent } from "./base/LoggableComponent";
2
+ /**
3
+ * Manages timeouts for the content protection toolkit
4
+ * Provides a centralized way to create, track, and clear timeouts
5
+ */
6
+ export declare class TimeoutManager extends LoggableComponent {
7
+ private static instance;
8
+ private timeouts;
9
+ /**
10
+ * Create a new TimeoutManager
11
+ * @param debugMode Enable debug mode for troubleshooting
12
+ */
13
+ private constructor();
14
+ /**
15
+ * Get the TimeoutManager instance (singleton)
16
+ * @param debugMode Enable debug mode for troubleshooting
17
+ */
18
+ static getInstance(debugMode?: boolean): TimeoutManager;
19
+ /**
20
+ * Set a timeout with a unique ID
21
+ * @param id Unique identifier for the timeout
22
+ * @param callback Function to execute
23
+ * @param delay Delay in milliseconds
24
+ * @returns The timeout ID for later reference
25
+ */
26
+ setTimeout(id: string, callback: () => void, delay: number): string;
27
+ /**
28
+ * Clear a timeout by ID
29
+ * @param id Timeout ID to clear
30
+ * @returns True if the timeout was found and cleared
31
+ */
32
+ clearTimeout(id: string): boolean;
33
+ /**
34
+ * Clear all timeouts
35
+ * @returns Number of timeouts cleared
36
+ */
37
+ clearAllTimeouts(): number;
38
+ /**
39
+ * Check if a timeout exists
40
+ * @param id Timeout ID to check
41
+ * @returns True if the timeout exists
42
+ */
43
+ hasTimeout(id: string): boolean;
44
+ /**
45
+ * Get the number of active timeouts
46
+ * @returns Number of active timeouts
47
+ */
48
+ getTimeoutCount(): number;
49
+ }
50
+ export declare const timeoutManager: TimeoutManager;
@@ -0,0 +1,113 @@
1
+ import { isBrowser } from "./environment";
2
+ import { LoggableComponent } from "./base/LoggableComponent";
3
+ /**
4
+ * Manages timeouts for the content protection toolkit
5
+ * Provides a centralized way to create, track, and clear timeouts
6
+ */
7
+ export class TimeoutManager extends LoggableComponent {
8
+ /**
9
+ * Create a new TimeoutManager
10
+ * @param debugMode Enable debug mode for troubleshooting
11
+ */
12
+ constructor(debugMode = false) {
13
+ super("TimeoutManager", debugMode);
14
+ this.timeouts = new Map();
15
+ this.logger.log("Initialized");
16
+ }
17
+ /**
18
+ * Get the TimeoutManager instance (singleton)
19
+ * @param debugMode Enable debug mode for troubleshooting
20
+ */
21
+ static getInstance(debugMode = false) {
22
+ if (!TimeoutManager.instance) {
23
+ TimeoutManager.instance = new TimeoutManager(debugMode);
24
+ }
25
+ // Update debug mode if it's explicitly passed
26
+ if (arguments.length > 0) {
27
+ TimeoutManager.instance.setDebugMode(debugMode);
28
+ }
29
+ return TimeoutManager.instance;
30
+ }
31
+ /**
32
+ * Set a timeout with a unique ID
33
+ * @param id Unique identifier for the timeout
34
+ * @param callback Function to execute
35
+ * @param delay Delay in milliseconds
36
+ * @returns The timeout ID for later reference
37
+ */
38
+ setTimeout(id, callback, delay) {
39
+ if (!isBrowser())
40
+ return id;
41
+ // Clear any existing timeout with this ID
42
+ this.clearTimeout(id);
43
+ // Create a new timeout
44
+ const timeoutId = window.setTimeout(() => {
45
+ // Remove from our map when it executes
46
+ this.timeouts.delete(id);
47
+ // Execute the callback
48
+ try {
49
+ callback();
50
+ }
51
+ catch (error) {
52
+ this.logger.error(`Error executing timeout "${id}":`, error);
53
+ }
54
+ }, delay);
55
+ // Store in our map
56
+ this.timeouts.set(id, timeoutId);
57
+ this.logger.log(`Set timeout "${id}" with delay ${delay}ms`);
58
+ return id;
59
+ }
60
+ /**
61
+ * Clear a timeout by ID
62
+ * @param id Timeout ID to clear
63
+ * @returns True if the timeout was found and cleared
64
+ */
65
+ clearTimeout(id) {
66
+ if (!isBrowser())
67
+ return false;
68
+ const timeoutId = this.timeouts.get(id);
69
+ if (timeoutId !== undefined) {
70
+ window.clearTimeout(timeoutId);
71
+ this.timeouts.delete(id);
72
+ this.logger.log(`Cleared timeout "${id}"`);
73
+ return true;
74
+ }
75
+ return false;
76
+ }
77
+ /**
78
+ * Clear all timeouts
79
+ * @returns Number of timeouts cleared
80
+ */
81
+ clearAllTimeouts() {
82
+ if (!isBrowser())
83
+ return 0;
84
+ let count = 0;
85
+ this.timeouts.forEach((timeoutId, _id) => {
86
+ window.clearTimeout(timeoutId);
87
+ count++;
88
+ });
89
+ this.timeouts.clear();
90
+ if (count > 0) {
91
+ this.logger.log(`Cleared all ${count} timeouts`);
92
+ }
93
+ return count;
94
+ }
95
+ /**
96
+ * Check if a timeout exists
97
+ * @param id Timeout ID to check
98
+ * @returns True if the timeout exists
99
+ */
100
+ hasTimeout(id) {
101
+ return this.timeouts.has(id);
102
+ }
103
+ /**
104
+ * Get the number of active timeouts
105
+ * @returns Number of active timeouts
106
+ */
107
+ getTimeoutCount() {
108
+ return this.timeouts.size;
109
+ }
110
+ }
111
+ TimeoutManager.instance = null;
112
+ // Create a singleton instance for use throughout the application
113
+ export const timeoutManager = TimeoutManager.getInstance(false);
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@tindalabs/shield",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "type": "module",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
16
+ "lint": "eslint 'src/**/*.ts'",
17
+ "format": "prettier --write 'src/**/*.ts'",
18
+ "prepublishOnly": "npm run lint && npm run test && npm run build",
19
+ "prepare": "npm run build",
20
+ "examples:install": "cd examples && npm install",
21
+ "examples:build": "npm run build && npm run examples:install",
22
+ "examples:start": "cd examples && npm run start"
23
+ },
24
+ "keywords": [
25
+ "browser-security",
26
+ "tamper-detection",
27
+ "devtools-detection",
28
+ "automation-detection",
29
+ "webdriver",
30
+ "headless",
31
+ "content-protection",
32
+ "fingerprinting",
33
+ "opentelemetry",
34
+ "typescript",
35
+ "frontend-security"
36
+ ],
37
+ "author": "Isonimus",
38
+ "license": "MIT",
39
+ "homepage": "https://github.com/tindalabs/shield#readme",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/tindalabs/shield.git"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/tindalabs/shield/issues"
46
+ },
47
+ "description": "Browser tamper detection for hostile environments. Detects DevTools, automation drivers, extension injection, and environment spoofing — surfaces findings as structured risk signals, not just boolean flags.",
48
+ "devDependencies": {
49
+ "@eslint/js": "^9.22.0",
50
+ "@types/jest": "^29.5.14",
51
+ "@types/node": "^22.13.10",
52
+ "eslint": "^9.22.0",
53
+ "eslint-config-prettier": "^10.1.1",
54
+ "jest": "^29.7.0",
55
+ "jest-environment-jsdom": "^29.7.0",
56
+ "prettier": "^3.5.3",
57
+ "ts-jest": "^29.2.6",
58
+ "typescript": "^5.8.2",
59
+ "typescript-eslint": "^8.27.0"
60
+ }
61
+ }