@readium/navigator 2.2.9 → 2.4.0-alpha.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 +28 -0
- package/dist/index.js +2799 -1798
- package/dist/index.umd.cjs +79 -86
- package/package.json +11 -12
- package/src/Navigator.ts +76 -0
- package/src/divina/DivinaNavigator.ts +0 -0
- package/src/divina/index.ts +0 -0
- package/src/epub/EpubNavigator.ts +93 -10
- package/src/epub/css/Properties.ts +8 -8
- package/src/epub/css/ReadiumCSS.ts +7 -5
- package/src/epub/frame/FrameBlobBuilder.ts +15 -14
- package/src/epub/frame/FrameManager.ts +38 -2
- package/src/epub/frame/FramePoolManager.ts +9 -2
- package/src/epub/fxl/FXLFrameManager.ts +31 -2
- package/src/epub/fxl/FXLFramePoolManager.ts +9 -3
- package/src/epub/preferences/EpubDefaults.ts +6 -6
- package/src/epub/preferences/EpubPreferences.ts +6 -6
- package/src/epub/preferences/EpubPreferencesEditor.ts +1 -3
- package/src/epub/preferences/EpubSettings.ts +5 -7
- package/src/helpers/lineLength.ts +4 -6
- package/src/injection/epubInjectables.ts +11 -3
- package/src/injection/webpubInjectables.ts +12 -2
- package/src/peripherals/KeyboardPeripherals.ts +53 -0
- package/src/protection/AutomationDetector.ts +66 -0
- package/src/protection/ContextMenuProtector.ts +46 -0
- package/src/protection/DevToolsDetector.ts +290 -0
- package/src/protection/IframeEmbeddingDetector.ts +73 -0
- package/src/protection/NavigatorProtector.ts +95 -0
- package/src/protection/PrintProtector.ts +58 -0
- package/src/protection/utils/WorkerConsole.ts +84 -0
- package/src/protection/utils/console.ts +16 -0
- package/src/protection/utils/match.ts +18 -0
- package/src/protection/utils/platform.ts +22 -0
- package/src/webpub/WebPubFrameManager.ts +38 -5
- package/src/webpub/WebPubFramePoolManager.ts +9 -2
- package/src/webpub/WebPubNavigator.ts +87 -7
- package/types/src/Navigator.d.ts +14 -0
- package/types/src/divina/DivinaNavigator.d.ts +0 -0
- package/types/src/divina/index.d.ts +0 -0
- package/types/src/epub/EpubNavigator.d.ts +14 -2
- package/types/src/epub/css/Properties.d.ts +4 -0
- package/types/src/epub/frame/FrameBlobBuilder.d.ts +2 -2
- package/types/src/epub/frame/FrameManager.d.ts +5 -1
- package/types/src/epub/frame/FramePoolManager.d.ts +4 -1
- package/types/src/epub/fxl/FXLFrameManager.d.ts +5 -1
- package/types/src/epub/fxl/FXLFramePoolManager.d.ts +4 -2
- package/types/src/epub/preferences/EpubDefaults.d.ts +4 -0
- package/types/src/epub/preferences/EpubPreferences.d.ts +4 -0
- package/types/src/epub/preferences/EpubPreferencesEditor.d.ts +2 -0
- package/types/src/epub/preferences/EpubSettings.d.ts +4 -0
- package/types/src/helpers/lineLength.d.ts +2 -3
- package/types/src/injection/epubInjectables.d.ts +2 -2
- package/types/src/injection/webpubInjectables.d.ts +2 -1
- package/types/src/peripherals/KeyboardPeripherals.d.ts +13 -0
- package/types/src/protection/AutomationDetector.d.ts +14 -0
- package/types/src/protection/ContextMenuProtector.d.ts +11 -0
- package/types/src/protection/DevToolsDetector.d.ts +75 -0
- package/types/src/protection/IframeEmbeddingDetector.d.ts +14 -0
- package/types/src/protection/NavigatorProtector.d.ts +12 -0
- package/types/src/protection/PrintProtector.d.ts +13 -0
- package/types/src/protection/utils/WorkerConsole.d.ts +15 -0
- package/types/src/protection/utils/console.d.ts +6 -0
- package/types/src/protection/utils/match.d.ts +8 -0
- package/types/src/protection/utils/platform.d.ts +4 -0
- package/types/src/webpub/WebPubFrameManager.d.ts +5 -1
- package/types/src/webpub/WebPubFramePoolManager.d.ts +4 -1
- package/types/src/webpub/WebPubNavigator.d.ts +13 -1
- package/dist/assets/AccessibleDfA-Bold.woff2 +0 -0
- package/dist/assets/AccessibleDfA-Italic.woff2 +0 -0
- package/dist/assets/AccessibleDfA-Regular.woff +0 -0
- package/dist/assets/AccessibleDfA-Regular.woff2 +0 -0
- package/dist/assets/iAWriterDuospace-Regular.ttf +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AutomationDetectorOptions {
|
|
2
|
+
/** Callback when an automation tool is detected */
|
|
3
|
+
onDetected?: (tool: string) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class AutomationDetector {
|
|
6
|
+
private options;
|
|
7
|
+
private detectedTools;
|
|
8
|
+
private observer?;
|
|
9
|
+
constructor(options: AutomationDetectorOptions);
|
|
10
|
+
private isAutomationToolPresent;
|
|
11
|
+
private setupDetection;
|
|
12
|
+
private handleDetected;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContextMenuEvent } from "@readium/navigator-html-injectables";
|
|
2
|
+
export interface ContextMenuProtectionOptions {
|
|
3
|
+
onContextMenuBlocked?: (event: ContextMenuEvent) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class ContextMenuProtector {
|
|
6
|
+
private contextMenuHandler?;
|
|
7
|
+
private onContextMenuBlocked?;
|
|
8
|
+
constructor(options?: ContextMenuProtectionOptions);
|
|
9
|
+
private handleContextMenu;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface DevToolsDetectorOptions {
|
|
2
|
+
/** Callback when Developer Tools are detected as open */
|
|
3
|
+
onDetected?: () => void;
|
|
4
|
+
/** Callback when Developer Tools are detected as closed */
|
|
5
|
+
onClosed?: () => void;
|
|
6
|
+
/** Detection interval in milliseconds (default: 1000) */
|
|
7
|
+
interval?: number;
|
|
8
|
+
/** Enable debugger-based detection (fallback, impacts UX) */
|
|
9
|
+
enableDebuggerDetection?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class DevToolsDetector {
|
|
12
|
+
private options;
|
|
13
|
+
private isOpen;
|
|
14
|
+
private intervalId?;
|
|
15
|
+
private checkCount;
|
|
16
|
+
private maxChecks;
|
|
17
|
+
private maxPrintTime;
|
|
18
|
+
private largeObjectArray;
|
|
19
|
+
private workerConsole?;
|
|
20
|
+
constructor(options?: DevToolsDetectorOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Create large object array for performance testing
|
|
23
|
+
*/
|
|
24
|
+
private createLargeObjectArray;
|
|
25
|
+
/**
|
|
26
|
+
* Get cached large object array
|
|
27
|
+
*/
|
|
28
|
+
private getLargeObjectArray;
|
|
29
|
+
/**
|
|
30
|
+
* Performance-based detection using console.table timing
|
|
31
|
+
*/
|
|
32
|
+
private calcTablePrintTime;
|
|
33
|
+
/**
|
|
34
|
+
* Performance-based detection using console.log timing
|
|
35
|
+
*/
|
|
36
|
+
private calcLogPrintTime;
|
|
37
|
+
/**
|
|
38
|
+
* Check if performance-based detection is enabled for current browser
|
|
39
|
+
*/
|
|
40
|
+
private isPerformanceDetectionEnabled;
|
|
41
|
+
/**
|
|
42
|
+
* Check if debugger detection is enabled for current browser
|
|
43
|
+
*/
|
|
44
|
+
private isDebuggerDetectionEnabled;
|
|
45
|
+
/**
|
|
46
|
+
* Performance-based detection using large object timing differences
|
|
47
|
+
*/
|
|
48
|
+
private checkPerformanceBased;
|
|
49
|
+
/**
|
|
50
|
+
* Debugger-based detection (fallback method)
|
|
51
|
+
* WARNING: This method impacts user experience
|
|
52
|
+
*/
|
|
53
|
+
private checkDebuggerBased;
|
|
54
|
+
/**
|
|
55
|
+
* Main detection method combining multiple approaches
|
|
56
|
+
* Prioritizes performance-based detection
|
|
57
|
+
*/
|
|
58
|
+
private detectDevTools;
|
|
59
|
+
/**
|
|
60
|
+
* Start continuous detection monitoring
|
|
61
|
+
*/
|
|
62
|
+
private startDetection;
|
|
63
|
+
/**
|
|
64
|
+
* Get current DevTools state
|
|
65
|
+
*/
|
|
66
|
+
isDevToolsOpen(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Force an immediate check
|
|
69
|
+
*/
|
|
70
|
+
checkNow(): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Stop detection and cleanup resources
|
|
73
|
+
*/
|
|
74
|
+
destroy(): void;
|
|
75
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IframeEmbeddingDetectorOptions {
|
|
2
|
+
/** Callback when iframe embedding is detected */
|
|
3
|
+
onDetected?: (isCrossOrigin: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class IframeEmbeddingDetector {
|
|
6
|
+
private options;
|
|
7
|
+
private observer?;
|
|
8
|
+
private detected;
|
|
9
|
+
constructor(options: IframeEmbeddingDetectorOptions);
|
|
10
|
+
private isIframed;
|
|
11
|
+
private setupDetection;
|
|
12
|
+
private handleDetected;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IContentProtectionConfig } from "../Navigator";
|
|
2
|
+
export declare const NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT = "readium:navigator:suspiciousActivity";
|
|
3
|
+
export declare class NavigatorProtector {
|
|
4
|
+
private automationDetector?;
|
|
5
|
+
private devToolsDetector?;
|
|
6
|
+
private iframeEmbeddingDetector?;
|
|
7
|
+
private printProtector?;
|
|
8
|
+
private contextMenuProtector?;
|
|
9
|
+
private dispatchSuspiciousActivity;
|
|
10
|
+
constructor(config?: IContentProtectionConfig);
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface NavigatorPrintProtectionConfig {
|
|
2
|
+
disable?: boolean;
|
|
3
|
+
watermark?: string;
|
|
4
|
+
onPrintAttempt?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class PrintProtector {
|
|
7
|
+
private styleElement;
|
|
8
|
+
private beforePrintHandler;
|
|
9
|
+
private onPrintAttempt?;
|
|
10
|
+
constructor(config?: NavigatorPrintProtectionConfig);
|
|
11
|
+
private setupPrintProtection;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type WorkerConsoleMethod<Args extends any[]> = (...args: Args) => Promise<{
|
|
2
|
+
time: number;
|
|
3
|
+
}>;
|
|
4
|
+
export declare class WorkerConsole {
|
|
5
|
+
static workerScript: string;
|
|
6
|
+
private readonly worker;
|
|
7
|
+
private readonly blobUrl;
|
|
8
|
+
private callbacks;
|
|
9
|
+
readonly log: WorkerConsoleMethod<Parameters<Console['log']>>;
|
|
10
|
+
readonly table: WorkerConsoleMethod<Parameters<Console['table']>>;
|
|
11
|
+
readonly clear: WorkerConsoleMethod<Parameters<Console['clear']>>;
|
|
12
|
+
constructor(worker: Worker, blobUrl: string);
|
|
13
|
+
private send;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Loader, ModuleName } from "@readium/navigator-html-injectables";
|
|
2
2
|
import { FrameComms } from "../epub/frame/FrameComms";
|
|
3
|
+
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
|
|
3
4
|
export declare class WebPubFrameManager {
|
|
4
5
|
private frame;
|
|
5
6
|
private loader;
|
|
@@ -7,9 +8,12 @@ export declare class WebPubFrameManager {
|
|
|
7
8
|
private comms;
|
|
8
9
|
private hidden;
|
|
9
10
|
private destroyed;
|
|
11
|
+
private readonly contentProtectionConfig;
|
|
12
|
+
private readonly keyboardPeripheralsConfig;
|
|
10
13
|
private currModules;
|
|
11
|
-
constructor(source: string);
|
|
14
|
+
constructor(source: string, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
|
|
12
15
|
load(modules?: ModuleName[]): Promise<Window>;
|
|
16
|
+
private applyContentProtection;
|
|
13
17
|
destroy(): Promise<void>;
|
|
14
18
|
hide(): Promise<void>;
|
|
15
19
|
show(atProgress?: number): Promise<void>;
|
|
@@ -2,6 +2,7 @@ import { ModuleName } from "@readium/navigator-html-injectables";
|
|
|
2
2
|
import { Locator, Publication } from "@readium/shared";
|
|
3
3
|
import { WebPubFrameManager } from "./WebPubFrameManager";
|
|
4
4
|
import { Injector } from "../injection/Injector";
|
|
5
|
+
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
|
|
5
6
|
export declare class WebPubFramePoolManager {
|
|
6
7
|
private readonly container;
|
|
7
8
|
private _currentFrame;
|
|
@@ -12,9 +13,11 @@ export declare class WebPubFramePoolManager {
|
|
|
12
13
|
private pendingUpdates;
|
|
13
14
|
private currentBaseURL;
|
|
14
15
|
private readonly injector?;
|
|
16
|
+
private readonly contentProtectionConfig;
|
|
17
|
+
private readonly keyboardPeripheralsConfig;
|
|
15
18
|
constructor(container: HTMLElement, cssProperties?: {
|
|
16
19
|
[key: string]: string;
|
|
17
|
-
}, injector?: Injector | null);
|
|
20
|
+
}, injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
|
|
18
21
|
destroy(): Promise<void>;
|
|
19
22
|
update(pub: Publication, locator: Locator, modules: ModuleName[]): Promise<void>;
|
|
20
23
|
setCSSProperties(properties: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Link, Locator, Publication, ReadingProgression } from "@readium/shared";
|
|
2
2
|
import { VisualNavigator, VisualNavigatorViewport } from "../Navigator";
|
|
3
3
|
import { Configurable } from "../preferences/Configurable";
|
|
4
|
-
import { BasicTextSelection, CommsEventKey, FrameClickEvent } from "@readium/navigator-html-injectables";
|
|
4
|
+
import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, KeyboardEventData, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
|
|
5
5
|
import { WebPubFrameManager } from "./WebPubFrameManager";
|
|
6
6
|
import { ManagerEventKey } from "../epub/EpubNavigator";
|
|
7
7
|
import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences";
|
|
@@ -9,10 +9,13 @@ import { IWebPubDefaults } from "./preferences/WebPubDefaults";
|
|
|
9
9
|
import { WebPubSettings } from "./preferences/WebPubSettings";
|
|
10
10
|
import { IPreferencesEditor } from "../preferences/PreferencesEditor";
|
|
11
11
|
import { IInjectablesConfig } from "../injection/Injectable";
|
|
12
|
+
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
|
|
12
13
|
export interface WebPubNavigatorConfiguration {
|
|
13
14
|
preferences: IWebPubPreferences;
|
|
14
15
|
defaults: IWebPubDefaults;
|
|
15
16
|
injectables?: IInjectablesConfig;
|
|
17
|
+
contentProtection?: IContentProtectionConfig;
|
|
18
|
+
keyboardPeripherals?: IKeyboardPeripheralsConfig;
|
|
16
19
|
}
|
|
17
20
|
export interface WebPubNavigatorListeners {
|
|
18
21
|
frameLoaded: (wnd: Window) => void;
|
|
@@ -24,6 +27,9 @@ export interface WebPubNavigatorListeners {
|
|
|
24
27
|
customEvent: (key: string, data: unknown) => void;
|
|
25
28
|
handleLocator: (locator: Locator) => boolean;
|
|
26
29
|
textSelected: (selection: BasicTextSelection) => void;
|
|
30
|
+
contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
|
|
31
|
+
contextMenu: (data: ContextMenuEvent) => void;
|
|
32
|
+
peripheral: (data: KeyboardEventData) => void;
|
|
27
33
|
}
|
|
28
34
|
export declare class WebPubNavigator extends VisualNavigator implements Configurable<WebPubSettings, WebPubPreferences> {
|
|
29
35
|
private readonly pub;
|
|
@@ -38,6 +44,12 @@ export declare class WebPubNavigator extends VisualNavigator implements Configur
|
|
|
38
44
|
private _css;
|
|
39
45
|
private _preferencesEditor;
|
|
40
46
|
private readonly _injector;
|
|
47
|
+
private readonly _contentProtection;
|
|
48
|
+
private readonly _keyboardPeripherals;
|
|
49
|
+
private readonly _navigatorProtector;
|
|
50
|
+
private readonly _keyboardPeripheralsManager;
|
|
51
|
+
private readonly _suspiciousActivityListener;
|
|
52
|
+
private readonly _keyboardPeripheralListener;
|
|
41
53
|
private webViewport;
|
|
42
54
|
constructor(container: HTMLElement, pub: Publication, listeners: WebPubNavigatorListeners, initialPosition?: Locator | undefined, configuration?: WebPubNavigatorConfiguration);
|
|
43
55
|
load(): Promise<void>;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|