content-security-toolkit 1.0.0 → 1.0.1

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 (54) hide show
  1. package/README.md +203 -41
  2. package/package.json +12 -5
  3. package/dist/core/mediator/handlers/baseEventHandler.d.ts +0 -65
  4. package/dist/core/mediator/handlers/baseEventHandler.js +0 -99
  5. package/dist/core/mediator/handlers/index.d.ts +0 -9
  6. package/dist/core/mediator/handlers/index.js +0 -34
  7. package/dist/strategies/AbstractStrategy.mediator.d.ts +0 -162
  8. package/dist/strategies/AbstractStrategy.mediator.js +0 -349
  9. package/dist/strategies/DevToolsStrategy copy.d.ts +0 -85
  10. package/dist/strategies/DevToolsStrategy copy.js +0 -362
  11. package/dist/strategies/DevToolsStrategy-detectorManager.d.ts +0 -70
  12. package/dist/strategies/DevToolsStrategy-detectorManager.js +0 -309
  13. package/dist/strategies/DevToolsStrategy-simple.d.ts +0 -75
  14. package/dist/strategies/DevToolsStrategy-simple.js +0 -366
  15. package/dist/strategies/StrategyRegistry.d.ts +0 -133
  16. package/dist/strategies/StrategyRegistry.js +0 -379
  17. package/dist/utils/base/LoggableComponent.d.ts +0 -62
  18. package/dist/utils/base/LoggableComponent.js +0 -95
  19. package/dist/utils/debuggerDetector/debuggerDetectionWorker.d.ts +0 -6
  20. package/dist/utils/debuggerDetector/debuggerDetectionWorker.js +0 -24
  21. package/dist/utils/debuggerDetector/debuggerDetector.d.ts +0 -55
  22. package/dist/utils/debuggerDetector/debuggerDetector.js +0 -158
  23. package/dist/utils/debuggerDetector/firefoxDetector.d.ts +0 -8
  24. package/dist/utils/debuggerDetector/firefoxDetector.js +0 -64
  25. package/dist/utils/detection.d.ts +0 -29
  26. package/dist/utils/detection.js +0 -267
  27. package/dist/utils/detectors/debuggerDetectionWorker.d.ts +0 -6
  28. package/dist/utils/detectors/debuggerDetectionWorker.js +0 -24
  29. package/dist/utils/detectors/firefoxDetector.d.ts +0 -8
  30. package/dist/utils/detectors/firefoxDetector.js +0 -64
  31. package/dist/utils/logging/LogLevel.d.ts +0 -21
  32. package/dist/utils/logging/LogLevel.js +0 -46
  33. package/dist/utils/logging/LoggingConfig.d.ts +0 -68
  34. package/dist/utils/logging/LoggingConfig.js +0 -64
  35. package/dist/utils/logging/LoggingFactory.d.ts +0 -22
  36. package/dist/utils/logging/LoggingFactory.js +0 -61
  37. package/dist/utils/logging/LoggingService.d.ts +0 -235
  38. package/dist/utils/logging/LoggingService.js +0 -385
  39. package/dist/utils/logging/SimpleLoggingService.d.ts +0 -39
  40. package/dist/utils/logging/SimpleLoggingService.js +0 -58
  41. package/dist/utils/logging/advanced/LogLevel.d.ts +0 -21
  42. package/dist/utils/logging/advanced/LogLevel.js +0 -46
  43. package/dist/utils/logging/advanced/LoggingConfig.d.ts +0 -68
  44. package/dist/utils/logging/advanced/LoggingConfig.js +0 -64
  45. package/dist/utils/logging/advanced/LoggingFactory.d.ts +0 -22
  46. package/dist/utils/logging/advanced/LoggingFactory.js +0 -61
  47. package/dist/utils/logging/advanced/LoggingService.d.ts +0 -235
  48. package/dist/utils/logging/advanced/LoggingService.js +0 -385
  49. package/dist/utils/protectedContentManager-simple.d.ts +0 -86
  50. package/dist/utils/protectedContentManager-simple.js +0 -180
  51. package/dist/utils/securityOverlayManager-observer-pause.d.ts +0 -283
  52. package/dist/utils/securityOverlayManager-observer-pause.js +0 -878
  53. package/dist/utils/securityOverlayManager-simple.d.ts +0 -197
  54. package/dist/utils/securityOverlayManager-simple.js +0 -552
@@ -1,46 +0,0 @@
1
- /**
2
- * Enum defining log severity levels
3
- */
4
- export var LogLevel;
5
- (function (LogLevel) {
6
- LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
7
- LogLevel[LogLevel["WARN"] = 1] = "WARN";
8
- LogLevel[LogLevel["INFO"] = 2] = "INFO";
9
- LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
10
- LogLevel[LogLevel["TRACE"] = 4] = "TRACE";
11
- LogLevel[LogLevel["VERBOSE"] = 5] = "VERBOSE";
12
- })(LogLevel || (LogLevel = {}));
13
- /**
14
- * Map of log level names to their enum values
15
- */
16
- export const LOG_LEVEL_MAP = {
17
- error: LogLevel.ERROR,
18
- warn: LogLevel.WARN,
19
- info: LogLevel.INFO,
20
- debug: LogLevel.DEBUG,
21
- trace: LogLevel.TRACE,
22
- verbose: LogLevel.VERBOSE,
23
- };
24
- /**
25
- * Get the name of a log level
26
- * @param level The log level
27
- * @returns The name of the log level
28
- */
29
- export function getLogLevelName(level) {
30
- switch (level) {
31
- case LogLevel.ERROR:
32
- return "ERROR";
33
- case LogLevel.WARN:
34
- return "WARN";
35
- case LogLevel.INFO:
36
- return "INFO";
37
- case LogLevel.DEBUG:
38
- return "DEBUG";
39
- case LogLevel.TRACE:
40
- return "TRACE";
41
- case LogLevel.VERBOSE:
42
- return "VERBOSE";
43
- default:
44
- return "UNKNOWN";
45
- }
46
- }
@@ -1,68 +0,0 @@
1
- import { LogLevel } from "./LogLevel";
2
- /**
3
- * Global logging configuration
4
- */
5
- export interface LoggingConfig {
6
- /**
7
- * Default log level for all components
8
- * @default LogLevel.INFO
9
- */
10
- defaultLevel: LogLevel;
11
- /**
12
- * Component-specific log levels
13
- */
14
- componentLevels: Record<string, LogLevel>;
15
- /**
16
- * Whether to use colors in console output
17
- * @default true
18
- */
19
- useColors: boolean;
20
- /**
21
- * Whether to include timestamps in logs
22
- * @default true
23
- */
24
- includeTimestamps: boolean;
25
- /**
26
- * Whether to include component names in logs
27
- * @default true
28
- */
29
- includeComponentName: boolean;
30
- /**
31
- * Components to enable logging for (null means all)
32
- */
33
- enabledComponents: string[] | null;
34
- /**
35
- * Level to focus on (null means all levels)
36
- */
37
- focusedLevel: LogLevel | null;
38
- }
39
- /**
40
- * Default logging configuration
41
- */
42
- export declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
43
- /**
44
- * Get the current logging configuration
45
- * @returns The current logging configuration
46
- */
47
- export declare function getLoggingConfig(): LoggingConfig;
48
- /**
49
- * Update the logging configuration
50
- * @param config New configuration (partial)
51
- */
52
- export declare function updateLoggingConfig(config: Partial<LoggingConfig>): void;
53
- /**
54
- * Reset the logging configuration to defaults
55
- */
56
- export declare function resetLoggingConfig(): void;
57
- /**
58
- * Get the log level for a specific component
59
- * @param componentName Component name
60
- * @returns The log level for the component
61
- */
62
- export declare function getComponentLogLevel(componentName: string): LogLevel;
63
- /**
64
- * Set the log level for a specific component
65
- * @param componentName Component name
66
- * @param level Log level
67
- */
68
- export declare function setComponentLogLevel(componentName: string, level: LogLevel): void;
@@ -1,64 +0,0 @@
1
- import { LogLevel } from "./LogLevel";
2
- /**
3
- * Default logging configuration
4
- */
5
- export const DEFAULT_LOGGING_CONFIG = {
6
- defaultLevel: LogLevel.INFO,
7
- componentLevels: {},
8
- useColors: true,
9
- includeTimestamps: true,
10
- includeComponentName: true,
11
- enabledComponents: null,
12
- focusedLevel: null,
13
- };
14
- /**
15
- * Current global logging configuration
16
- */
17
- let currentConfig = { ...DEFAULT_LOGGING_CONFIG };
18
- /**
19
- * Get the current logging configuration
20
- * @returns The current logging configuration
21
- */
22
- export function getLoggingConfig() {
23
- return { ...currentConfig };
24
- }
25
- /**
26
- * Update the logging configuration
27
- * @param config New configuration (partial)
28
- */
29
- export function updateLoggingConfig(config) {
30
- currentConfig = {
31
- ...currentConfig,
32
- ...config,
33
- // Merge component levels
34
- componentLevels: {
35
- ...currentConfig.componentLevels,
36
- ...(config.componentLevels || {}),
37
- },
38
- };
39
- console.log("Updated logging configuration:", currentConfig);
40
- }
41
- /**
42
- * Reset the logging configuration to defaults
43
- */
44
- export function resetLoggingConfig() {
45
- currentConfig = { ...DEFAULT_LOGGING_CONFIG };
46
- console.log("Reset logging configuration to defaults");
47
- }
48
- /**
49
- * Get the log level for a specific component
50
- * @param componentName Component name
51
- * @returns The log level for the component
52
- */
53
- export function getComponentLogLevel(componentName) {
54
- return currentConfig.componentLevels[componentName] || currentConfig.defaultLevel;
55
- }
56
- /**
57
- * Set the log level for a specific component
58
- * @param componentName Component name
59
- * @param level Log level
60
- */
61
- export function setComponentLogLevel(componentName, level) {
62
- currentConfig.componentLevels[componentName] = level;
63
- console.log(`Set log level for ${componentName} to ${LogLevel[level]}`);
64
- }
@@ -1,22 +0,0 @@
1
- import { LoggingService } from "./LoggingService";
2
- /**
3
- * Factory for creating LoggingService instances
4
- */
5
- export declare class LoggingFactory {
6
- private static instances;
7
- /**
8
- * Get a LoggingService instance for a component
9
- * @param componentName Component name
10
- * @returns LoggingService instance
11
- */
12
- static getLogger(componentName: string): LoggingService;
13
- /**
14
- * Update all existing logger instances with current configuration
15
- */
16
- static updateAllLoggers(): void;
17
- /**
18
- * Get all registered logger instances
19
- * @returns Map of component names to logger instances
20
- */
21
- static getAllLoggers(): Map<string, LoggingService>;
22
- }
@@ -1,61 +0,0 @@
1
- import { LoggingService } from "./LoggingService";
2
- import { getComponentLogLevel, getLoggingConfig } from "./LoggingConfig";
3
- /**
4
- * Factory for creating LoggingService instances
5
- */
6
- export class LoggingFactory {
7
- /**
8
- * Get a LoggingService instance for a component
9
- * @param componentName Component name
10
- * @returns LoggingService instance
11
- */
12
- static getLogger(componentName) {
13
- // Check if we already have an instance for this component
14
- if (this.instances.has(componentName)) {
15
- return this.instances.get(componentName);
16
- }
17
- // Get the global config
18
- const config = getLoggingConfig();
19
- // Create a new instance
20
- const logger = new LoggingService({
21
- componentName,
22
- level: getComponentLogLevel(componentName),
23
- useColors: config.useColors,
24
- includeTimestamps: config.includeTimestamps,
25
- includeComponentName: config.includeComponentName,
26
- });
27
- // Apply global settings
28
- if (config.enabledComponents !== null) {
29
- logger.setEnabledComponents(config.enabledComponents);
30
- }
31
- if (config.focusedLevel !== null) {
32
- logger.focusLevel(config.focusedLevel);
33
- }
34
- // Store the instance
35
- this.instances.set(componentName, logger);
36
- return logger;
37
- }
38
- /**
39
- * Update all existing logger instances with current configuration
40
- */
41
- static updateAllLoggers() {
42
- const config = getLoggingConfig();
43
- for (const [componentName, logger] of this.instances.entries()) {
44
- logger.setLevel(getComponentLogLevel(componentName));
45
- if (config.enabledComponents !== null) {
46
- logger.setEnabledComponents(config.enabledComponents);
47
- }
48
- if (config.focusedLevel !== null) {
49
- logger.focusLevel(config.focusedLevel);
50
- }
51
- }
52
- }
53
- /**
54
- * Get all registered logger instances
55
- * @returns Map of component names to logger instances
56
- */
57
- static getAllLoggers() {
58
- return new Map(this.instances);
59
- }
60
- }
61
- LoggingFactory.instances = new Map();
@@ -1,235 +0,0 @@
1
- import { LogLevel } from "./LogLevel";
2
- /**
3
- * Options for the LoggingService
4
- */
5
- export interface LoggingOptions {
6
- /**
7
- * Component name for log prefixing
8
- */
9
- componentName: string;
10
- /**
11
- * Initial log level
12
- * @default LogLevel.INFO
13
- */
14
- level?: LogLevel;
15
- /**
16
- * Whether logging is enabled
17
- * @default true
18
- */
19
- enabled?: boolean;
20
- /**
21
- * Whether to use colors in console output
22
- * @default true
23
- */
24
- useColors?: boolean;
25
- /**
26
- * Whether to include timestamps in logs
27
- * @default true
28
- */
29
- includeTimestamps?: boolean;
30
- /**
31
- * Whether to include component name in logs
32
- * @default true
33
- */
34
- includeComponentName?: boolean;
35
- }
36
- /**
37
- * Performance timing result
38
- */
39
- export interface TimingResult<T> {
40
- result: T;
41
- duration: number;
42
- }
43
- /**
44
- * Advanced logging service with context tracking, filtering, and performance measurement
45
- */
46
- export declare class LoggingService {
47
- private componentName;
48
- private currentLevel;
49
- private enabled;
50
- private useColors;
51
- private includeTimestamps;
52
- private includeComponentName;
53
- private contextStack;
54
- private contextDepth;
55
- private enabledComponents;
56
- private focusedLevel;
57
- private groupDepth;
58
- /**
59
- * Create a new LoggingService
60
- * @param options Configuration options
61
- */
62
- constructor(options: LoggingOptions);
63
- /**
64
- * Set the current log level threshold
65
- * @param level New log level
66
- */
67
- setLevel(level: LogLevel): void;
68
- /**
69
- * Get the current log level
70
- * @returns The current log level
71
- */
72
- getLevel(): LogLevel;
73
- /**
74
- * Get the current log level name
75
- * @returns The current log level name
76
- */
77
- getLevelName(): string;
78
- /**
79
- * Enable or disable logging
80
- * @param enabled Whether logging should be enabled
81
- */
82
- setEnabled(enabled: boolean): void;
83
- /**
84
- * Check if logging is enabled
85
- * @returns Whether logging is enabled
86
- */
87
- isEnabled(): boolean;
88
- /**
89
- * Set components to show logs for
90
- * @param components Array of component names to enable, or null to enable all
91
- */
92
- setEnabledComponents(components: string[] | null): void;
93
- /**
94
- * Focus on a specific log level
95
- * @param level Level to focus on, or null to show all levels
96
- */
97
- focusLevel(level: LogLevel | null): void;
98
- /**
99
- * Increase context depth (call when entering a loop or nested function)
100
- * @param contextName Optional name for the context
101
- * @returns A function that exits this context when called
102
- */
103
- enterContext(contextName?: string): () => void;
104
- /**
105
- * Decrease context depth (call when exiting a loop or nested function)
106
- */
107
- exitContext(): void;
108
- /**
109
- * Execute a function within a named context
110
- * @param contextName Name for the context
111
- * @param fn Function to execute
112
- * @returns The result of the function
113
- */
114
- withContext<T>(contextName: string, fn: () => T): T;
115
- /**
116
- * Execute an async function within a named context
117
- * @param contextName Name for the context
118
- * @param fn Async function to execute
119
- * @returns Promise resolving to the result of the function
120
- */
121
- withContextAsync<T>(contextName: string, fn: () => Promise<T>): Promise<T>;
122
- /**
123
- * Start a console group
124
- * @param label Label for the group
125
- * @param collapsed Whether the group should be collapsed
126
- */
127
- startGroup(label: string, collapsed?: boolean): void;
128
- /**
129
- * End the current console group
130
- */
131
- endGroup(): void;
132
- /**
133
- * Execute a function within a console group
134
- * @param label Label for the group
135
- * @param fn Function to execute
136
- * @param collapsed Whether the group should be collapsed
137
- * @returns The result of the function
138
- */
139
- group<T>(label: string, fn: () => T, collapsed?: boolean): T;
140
- /**
141
- * Execute an async function within a console group
142
- * @param label Label for the group
143
- * @param fn Async function to execute
144
- * @param collapsed Whether the group should be collapsed
145
- * @returns Promise resolving to the result of the function
146
- */
147
- groupAsync<T>(label: string, fn: () => Promise<T>, collapsed?: boolean): Promise<T>;
148
- /**
149
- * Measure the execution time of a function
150
- * @param label Label for the timing
151
- * @param fn Function to measure
152
- * @returns Object containing the result and duration
153
- */
154
- time<T>(label: string, fn: () => T): TimingResult<T>;
155
- /**
156
- * Measure the execution time of an async function
157
- * @param label Label for the timing
158
- * @param fn Async function to measure
159
- * @returns Promise resolving to an object containing the result and duration
160
- */
161
- timeAsync<T>(label: string, fn: () => Promise<T>): Promise<TimingResult<T>>;
162
- /**
163
- * Log with automatic level adjustment based on context depth
164
- * @param message Message to log
165
- * @param args Additional arguments to log
166
- */
167
- logWithContext(message: string, ...args: unknown[]): void;
168
- /**
169
- * Main logging method
170
- * @param level Log level
171
- * @param message Message to log
172
- * @param args Additional arguments to log
173
- */
174
- log(level: LogLevel, message: string, ...args: unknown[]): void;
175
- /**
176
- * Log an error message
177
- * @param message Error message
178
- * @param args Additional arguments to log
179
- */
180
- error(message: string, ...args: unknown[]): void;
181
- /**
182
- * Log a warning message
183
- * @param message Warning message
184
- * @param args Additional arguments to log
185
- */
186
- warn(message: string, ...args: unknown[]): void;
187
- /**
188
- * Log an info message
189
- * @param message Info message
190
- * @param args Additional arguments to log
191
- */
192
- info(message: string, ...args: unknown[]): void;
193
- /**
194
- * Log a debug message
195
- * @param message Debug message
196
- * @param args Additional arguments to log
197
- */
198
- debug(message: string, ...args: unknown[]): void;
199
- /**
200
- * Log a trace message
201
- * @param message Trace message
202
- * @param args Additional arguments to log
203
- */
204
- trace(message: string, ...args: unknown[]): void;
205
- /**
206
- * Log a verbose message
207
- * @param message Verbose message
208
- * @param args Additional arguments to log
209
- */
210
- verbose(message: string, ...args: unknown[]): void;
211
- /**
212
- * Check if a message should be logged
213
- * @param level Log level of the message
214
- * @returns Whether the message should be logged
215
- */
216
- private shouldLog;
217
- /**
218
- * Format a log message
219
- * @param level Log level
220
- * @param message Message to format
221
- * @returns Formatted message
222
- */
223
- private formatMessage;
224
- /**
225
- * Get the current timestamp as a string
226
- * @returns Formatted timestamp
227
- */
228
- private getTimestamp;
229
- /**
230
- * Get prefix for log level
231
- * @param level Log level
232
- * @returns Formatted prefix
233
- */
234
- private getLevelPrefix;
235
- }