unified-video-framework 1.4.377 → 1.4.379

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 (33) hide show
  1. package/package.json +1 -1
  2. package/packages/core/dist/interfaces/IDRMProtection.d.ts +90 -0
  3. package/packages/core/dist/interfaces/IDRMProtection.d.ts.map +1 -0
  4. package/packages/core/dist/interfaces/IDRMProtection.js +15 -0
  5. package/packages/core/dist/interfaces/IDRMProtection.js.map +1 -0
  6. package/packages/core/dist/interfaces.d.ts +1 -0
  7. package/packages/core/dist/interfaces.d.ts.map +1 -1
  8. package/packages/core/dist/interfaces.js +1 -0
  9. package/packages/core/dist/interfaces.js.map +1 -1
  10. package/packages/core/src/interfaces/IDRMProtection.ts +285 -0
  11. package/packages/core/src/interfaces.ts +2 -0
  12. package/packages/react-native/dist/drm/AndroidDRMProtection.d.ts +21 -0
  13. package/packages/react-native/dist/drm/AndroidDRMProtection.d.ts.map +1 -0
  14. package/packages/react-native/dist/drm/AndroidDRMProtection.js +184 -0
  15. package/packages/react-native/dist/drm/AndroidDRMProtection.js.map +1 -0
  16. package/packages/react-native/dist/drm/iOSDRMProtection.d.ts +21 -0
  17. package/packages/react-native/dist/drm/iOSDRMProtection.d.ts.map +1 -0
  18. package/packages/react-native/dist/drm/iOSDRMProtection.js +172 -0
  19. package/packages/react-native/dist/drm/iOSDRMProtection.js.map +1 -0
  20. package/packages/react-native/src/drm/AndroidDRMProtection.ts +419 -0
  21. package/packages/react-native/src/drm/iOSDRMProtection.ts +415 -0
  22. package/packages/web/dist/WebPlayer.js +1 -1
  23. package/packages/web/dist/drm/WebDRMProtection.d.ts +37 -0
  24. package/packages/web/dist/drm/WebDRMProtection.d.ts.map +1 -0
  25. package/packages/web/dist/drm/WebDRMProtection.js +378 -0
  26. package/packages/web/dist/drm/WebDRMProtection.js.map +1 -0
  27. package/packages/web/dist/index.d.ts +1 -0
  28. package/packages/web/dist/index.d.ts.map +1 -1
  29. package/packages/web/dist/index.js +2 -1
  30. package/packages/web/dist/index.js.map +1 -1
  31. package/packages/web/src/drm/WebDRMProtection.ts +596 -0
  32. package/packages/web/src/index.ts +3 -0
  33. package/scripts/fix-imports.js +24 -18
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AndroidDRMProtection = void 0;
4
+ const react_native_1 = require("react-native");
5
+ const core_1 = require("@unified-video/core");
6
+ const { DRMProtectionModule } = react_native_1.NativeModules;
7
+ const drmEventEmitter = new react_native_1.NativeEventEmitter(DRMProtectionModule);
8
+ class AndroidDRMProtection {
9
+ constructor() {
10
+ this.listeners = [];
11
+ this.config = { enabled: false };
12
+ this.status = {
13
+ isProtected: false,
14
+ drmSystem: 'none',
15
+ isScreenRecordingBlocked: false,
16
+ isAudioCaptureBlocked: false,
17
+ isScreenshotBlocked: false,
18
+ isCasting: false,
19
+ screenRecordingDetected: false,
20
+ mirroringDetected: false,
21
+ };
22
+ }
23
+ async initialize(config) {
24
+ this.config = {
25
+ blockScreenRecording: true,
26
+ blockAudioCapture: true,
27
+ blockScreenshots: true,
28
+ allowCasting: true,
29
+ blockMirroring: true,
30
+ widevineSecurityLevel: 'L1',
31
+ ...config,
32
+ };
33
+ if (!this.config.enabled) {
34
+ console.log('[DRM-Android] Protection disabled');
35
+ return;
36
+ }
37
+ console.log('[DRM-Android] Initializing...', this.config);
38
+ try {
39
+ if (this.config.blockScreenshots || this.config.blockScreenRecording) {
40
+ await DRMProtectionModule.enableFlagSecure(true);
41
+ this.status.isScreenshotBlocked = true;
42
+ this.status.isScreenRecordingBlocked = true;
43
+ console.log('[DRM-Android] FLAG_SECURE enabled');
44
+ }
45
+ if (this.config.licenseServerUrl) {
46
+ await this.initializeWidevine();
47
+ }
48
+ if (this.config.blockMirroring) {
49
+ await this.startMirroringDetection();
50
+ }
51
+ if (this.config.allowCasting) {
52
+ await this.initializeChromecast();
53
+ }
54
+ this.setupEventListeners();
55
+ this.status.isProtected = true;
56
+ console.log('[DRM-Android] Protection initialized');
57
+ }
58
+ catch (error) {
59
+ console.error('[DRM-Android] Initialization failed:', error);
60
+ throw error;
61
+ }
62
+ }
63
+ async initializeWidevine() {
64
+ console.log('[DRM-Android] Initializing Widevine...');
65
+ const widevineConfig = {
66
+ licenseServerUrl: this.config.licenseServerUrl,
67
+ licenseHeaders: this.config.licenseHeaders,
68
+ securityLevel: this.config.widevineSecurityLevel,
69
+ };
70
+ const result = await DRMProtectionModule.initializeWidevine(widevineConfig);
71
+ if (result.success) {
72
+ this.status.drmSystem = 'widevine';
73
+ this.status.securityLevel = result.securityLevel;
74
+ console.log(`[DRM-Android] Widevine initialized with security level: ${result.securityLevel}`);
75
+ if (result.securityLevel === 'L3' && this.config.widevineSecurityLevel === 'L1') {
76
+ console.warn('[DRM-Android] ⚠️ Requested L1 but got L3 - device may not support hardware DRM');
77
+ }
78
+ }
79
+ else {
80
+ throw {
81
+ code: core_1.DRMErrorCode.WIDEVINE_NOT_AVAILABLE,
82
+ message: 'Widevine initialization failed',
83
+ platform: 'android',
84
+ recoverable: false,
85
+ };
86
+ }
87
+ }
88
+ async startMirroringDetection() {
89
+ console.log('[DRM-Android] Starting mirroring detection...');
90
+ await DRMProtectionModule.startMirroringDetection();
91
+ }
92
+ async initializeChromecast() {
93
+ console.log('[DRM-Android] Initializing Chromecast...');
94
+ await DRMProtectionModule.initializeChromecast({
95
+ appId: 'CC1AD845',
96
+ });
97
+ }
98
+ setupEventListeners() {
99
+ this.listeners.push(drmEventEmitter.addListener('onScreenRecordingDetected', () => {
100
+ console.warn('[DRM-Android] ⚠️ Screen recording detected!');
101
+ this.status.screenRecordingDetected = true;
102
+ this.config.onScreenRecordingDetected?.();
103
+ }));
104
+ this.listeners.push(drmEventEmitter.addListener('onMirroringDetected', (event) => {
105
+ console.warn('[DRM-Android] ⚠️ Display mirroring detected:', event.displayName);
106
+ this.status.mirroringDetected = true;
107
+ this.config.onMirroringDetected?.();
108
+ }));
109
+ this.listeners.push(drmEventEmitter.addListener('onCastingStarted', (event) => {
110
+ console.log('[DRM-Android] Casting started:', event.deviceName);
111
+ this.status.isCasting = true;
112
+ this.status.castDevice = {
113
+ name: event.deviceName,
114
+ type: 'chromecast',
115
+ };
116
+ this.config.onCastingStarted?.(event.deviceName, 'chromecast');
117
+ }));
118
+ this.listeners.push(drmEventEmitter.addListener('onCastingEnded', () => {
119
+ console.log('[DRM-Android] Casting ended');
120
+ this.status.isCasting = false;
121
+ this.status.castDevice = undefined;
122
+ this.config.onCastingEnded?.();
123
+ }));
124
+ this.listeners.push(drmEventEmitter.addListener('onLicenseAcquired', (event) => {
125
+ console.log('[DRM-Android] License acquired');
126
+ this.status.licenseExpiration = event.expirationTime ? new Date(event.expirationTime) : undefined;
127
+ this.config.onLicenseAcquired?.();
128
+ }));
129
+ this.listeners.push(drmEventEmitter.addListener('onDRMError', (error) => {
130
+ console.error('[DRM-Android] DRM Error:', error);
131
+ this.config.onDRMError?.(error);
132
+ }));
133
+ }
134
+ getStatus() {
135
+ return { ...this.status };
136
+ }
137
+ setEnabled(enabled) {
138
+ this.config.enabled = enabled;
139
+ DRMProtectionModule.setEnabled(enabled);
140
+ }
141
+ setFeature(feature, enabled) {
142
+ this.config[feature] = enabled;
143
+ switch (feature) {
144
+ case 'blockScreenshots':
145
+ case 'blockScreenRecording':
146
+ DRMProtectionModule.enableFlagSecure(enabled);
147
+ this.status.isScreenshotBlocked = enabled;
148
+ this.status.isScreenRecordingBlocked = enabled;
149
+ break;
150
+ }
151
+ }
152
+ async startCasting(deviceId) {
153
+ await DRMProtectionModule.startCasting(deviceId);
154
+ }
155
+ async stopCasting() {
156
+ await DRMProtectionModule.stopCasting();
157
+ }
158
+ async getAvailableCastDevices() {
159
+ const devices = await DRMProtectionModule.getAvailableCastDevices();
160
+ return devices.map((device) => ({
161
+ id: device.id,
162
+ name: device.name,
163
+ type: 'chromecast',
164
+ isAvailable: device.isAvailable,
165
+ capabilities: {
166
+ supportsVideo: true,
167
+ supportsAudio: true,
168
+ supportsDRM: device.supportsDRM,
169
+ maxResolution: device.maxResolution,
170
+ },
171
+ }));
172
+ }
173
+ async renewLicense() {
174
+ await DRMProtectionModule.renewLicense();
175
+ }
176
+ dispose() {
177
+ this.listeners.forEach((listener) => listener.remove());
178
+ this.listeners = [];
179
+ DRMProtectionModule.dispose();
180
+ this.status.isProtected = false;
181
+ }
182
+ }
183
+ exports.AndroidDRMProtection = AndroidDRMProtection;
184
+ //# sourceMappingURL=AndroidDRMProtection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidDRMProtection.js","sourceRoot":"","sources":["../../src/drm/AndroidDRMProtection.ts"],"names":[],"mappings":";;;AAWA,+CAAiE;AACjE,8CAM6B;AAE7B,MAAM,EAAE,mBAAmB,EAAE,GAAG,4BAAa,CAAC;AAC9C,MAAM,eAAe,GAAG,IAAI,iCAAkB,CAAC,mBAAmB,CAAC,CAAC;AAKpE,MAAa,oBAAoB;IAK/B;QAFQ,cAAS,GAAU,EAAE,CAAC;QAG5B,IAAI,CAAC,MAAM,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG;YACZ,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,MAAM;YACjB,wBAAwB,EAAE,KAAK;YAC/B,qBAAqB,EAAE,KAAK;YAC5B,mBAAmB,EAAE,KAAK;YAC1B,SAAS,EAAE,KAAK;YAChB,uBAAuB,EAAE,KAAK;YAC9B,iBAAiB,EAAE,KAAK;SACzB,CAAC;IACJ,CAAC;IAKD,KAAK,CAAC,UAAU,CAAC,MAA4B;QAC3C,IAAI,CAAC,MAAM,GAAG;YACZ,oBAAoB,EAAE,IAAI;YAC1B,iBAAiB,EAAE,IAAI;YACvB,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;YACpB,qBAAqB,EAAE,IAAI;YAC3B,GAAG,MAAM;SACV,CAAC;QAEF,I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class iOSDRMProtection implements IDRMProtection {
3
+ private config;
4
+ private status;
5
+ private listeners;
6
+ constructor();
7
+ initialize(config: IDRMProtectionConfig): Promise<void>;
8
+ private initializeFairPlay;
9
+ private startScreenCaptureDetection;
10
+ private initializeAirPlay;
11
+ private setupEventListeners;
12
+ getStatus(): IDRMProtectionStatus;
13
+ setEnabled(enabled: boolean): void;
14
+ setFeature(feature: keyof IDRMProtectionConfig, enabled: boolean): void;
15
+ startCasting(deviceId: string): Promise<void>;
16
+ stopCasting(): Promise<void>;
17
+ getAvailableCastDevices(): Promise<CastDevice[]>;
18
+ renewLicense(): Promise<void>;
19
+ dispose(): void;
20
+ }
21
+ //# sourceMappingURL=iOSDRMProtection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iOSDRMProtection.d.ts","sourceRoot":"","sources":["../../src/drm/iOSDRMProtection.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EAEX,MAAM,qBAAqB,CAAC;AAQ7B,qBAAa,gBAAiB,YAAW,cAAc;IACrD,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAa;;IAmBxB,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;YA+C/C,kBAAkB;YA2BlB,2BAA2B;YAU3B,iBAAiB;IAW/B,OAAO,CAAC,mBAAmB;IA8D3B,SAAS,IAAI,oBAAoB;IAOjC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQlC,UAAU,CAAC,OAAO,EAAE,MAAM,oBAAoB,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAejE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,uBAAuB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAmBhD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAOnC,OAAO,IAAI,IAAI;CAMhB"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.iOSDRMProtection = void 0;
4
+ const react_native_1 = require("react-native");
5
+ const core_1 = require("@unified-video/core");
6
+ const { DRMProtectionModule } = react_native_1.NativeModules;
7
+ const drmEventEmitter = new react_native_1.NativeEventEmitter(DRMProtectionModule);
8
+ class iOSDRMProtection {
9
+ constructor() {
10
+ this.listeners = [];
11
+ this.config = { enabled: false };
12
+ this.status = {
13
+ isProtected: false,
14
+ drmSystem: 'none',
15
+ isScreenRecordingBlocked: false,
16
+ isAudioCaptureBlocked: false,
17
+ isScreenshotBlocked: false,
18
+ isCasting: false,
19
+ screenRecordingDetected: false,
20
+ mirroringDetected: false,
21
+ };
22
+ }
23
+ async initialize(config) {
24
+ this.config = {
25
+ blockScreenRecording: true,
26
+ blockAudioCapture: true,
27
+ blockScreenshots: true,
28
+ allowCasting: true,
29
+ blockMirroring: true,
30
+ ...config,
31
+ };
32
+ if (!this.config.enabled) {
33
+ console.log('[DRM-iOS] Protection disabled');
34
+ return;
35
+ }
36
+ console.log('[DRM-iOS] Initializing...', this.config);
37
+ try {
38
+ if (this.config.licenseServerUrl && this.config.certificateUrl) {
39
+ await this.initializeFairPlay();
40
+ }
41
+ if (this.config.blockScreenRecording) {
42
+ await this.startScreenCaptureDetection();
43
+ }
44
+ if (this.config.allowCasting) {
45
+ await this.initializeAirPlay();
46
+ }
47
+ this.setupEventListeners();
48
+ this.status.isProtected = true;
49
+ console.log('[DRM-iOS] Protection initialized');
50
+ }
51
+ catch (error) {
52
+ console.error('[DRM-iOS] Initialization failed:', error);
53
+ throw error;
54
+ }
55
+ }
56
+ async initializeFairPlay() {
57
+ console.log('[DRM-iOS] Initializing FairPlay...');
58
+ const fairPlayConfig = {
59
+ licenseServerUrl: this.config.licenseServerUrl,
60
+ certificateUrl: this.config.certificateUrl,
61
+ licenseHeaders: this.config.licenseHeaders,
62
+ };
63
+ const result = await DRMProtectionModule.initializeFairPlay(fairPlayConfig);
64
+ if (result.success) {
65
+ this.status.drmSystem = 'fairplay';
66
+ console.log('[DRM-iOS] FairPlay initialized successfully');
67
+ }
68
+ else {
69
+ throw {
70
+ code: core_1.DRMErrorCode.FAIRPLAY_NOT_AVAILABLE,
71
+ message: 'FairPlay initialization failed',
72
+ platform: 'ios',
73
+ recoverable: false,
74
+ };
75
+ }
76
+ }
77
+ async startScreenCaptureDetection() {
78
+ console.log('[DRM-iOS] Starting screen capture detection...');
79
+ await DRMProtectionModule.startScreenCaptureDetection();
80
+ this.status.isScreenRecordingBlocked = true;
81
+ }
82
+ async initializeAirPlay() {
83
+ console.log('[DRM-iOS] Initializing AirPlay...');
84
+ await DRMProtectionModule.initializeAirPlay({
85
+ allowMirroring: false,
86
+ });
87
+ }
88
+ setupEventListeners() {
89
+ this.listeners.push(drmEventEmitter.addListener('onScreenCaptureDetected', () => {
90
+ console.warn('[DRM-iOS] ⚠️ Screen capture detected!');
91
+ this.status.screenRecordingDetected = true;
92
+ this.config.onScreenRecordingDetected?.();
93
+ }));
94
+ this.listeners.push(drmEventEmitter.addListener('onExternalDisplayDetected', (event) => {
95
+ console.warn('[DRM-iOS] ⚠️ External display detected:', event);
96
+ this.status.mirroringDetected = true;
97
+ this.config.onMirroringDetected?.();
98
+ }));
99
+ this.listeners.push(drmEventEmitter.addListener('onAirPlayStarted', (event) => {
100
+ console.log('[DRM-iOS] AirPlay started:', event.deviceName);
101
+ this.status.isCasting = true;
102
+ this.status.castDevice = {
103
+ name: event.deviceName,
104
+ type: 'airplay',
105
+ };
106
+ this.config.onCastingStarted?.(event.deviceName, 'airplay');
107
+ }));
108
+ this.listeners.push(drmEventEmitter.addListener('onAirPlayEnded', () => {
109
+ console.log('[DRM-iOS] AirPlay ended');
110
+ this.status.isCasting = false;
111
+ this.status.castDevice = undefined;
112
+ this.config.onCastingEnded?.();
113
+ }));
114
+ this.listeners.push(drmEventEmitter.addListener('onLicenseAcquired', () => {
115
+ console.log('[DRM-iOS] FairPlay license acquired');
116
+ this.config.onLicenseAcquired?.();
117
+ }));
118
+ this.listeners.push(drmEventEmitter.addListener('onDRMError', (error) => {
119
+ console.error('[DRM-iOS] DRM Error:', error);
120
+ this.config.onDRMError?.(error);
121
+ }));
122
+ }
123
+ getStatus() {
124
+ return { ...this.status };
125
+ }
126
+ setEnabled(enabled) {
127
+ this.config.enabled = enabled;
128
+ DRMProtectionModule.setEnabled(enabled);
129
+ }
130
+ setFeature(feature, enabled) {
131
+ this.config[feature] = enabled;
132
+ switch (feature) {
133
+ case 'blockScreenRecording':
134
+ if (enabled) {
135
+ this.startScreenCaptureDetection();
136
+ }
137
+ break;
138
+ }
139
+ }
140
+ async startCasting(deviceId) {
141
+ await DRMProtectionModule.startAirPlay(deviceId);
142
+ }
143
+ async stopCasting() {
144
+ await DRMProtectionModule.stopAirPlay();
145
+ }
146
+ async getAvailableCastDevices() {
147
+ const devices = await DRMProtectionModule.getAvailableAirPlayDevices();
148
+ return devices.map((device) => ({
149
+ id: device.id,
150
+ name: device.name,
151
+ type: 'airplay',
152
+ isAvailable: device.isAvailable,
153
+ capabilities: {
154
+ supportsVideo: true,
155
+ supportsAudio: true,
156
+ supportsDRM: device.supportsFairPlay,
157
+ maxResolution: device.maxResolution,
158
+ },
159
+ }));
160
+ }
161
+ async renewLicense() {
162
+ await DRMProtectionModule.renewFairPlayLicense();
163
+ }
164
+ dispose() {
165
+ this.listeners.forEach((listener) => listener.remove());
166
+ this.listeners = [];
167
+ DRMProtectionModule.dispose();
168
+ this.status.isProtected = false;
169
+ }
170
+ }
171
+ exports.iOSDRMProtection = iOSDRMProtection;
172
+ //# sourceMappingURL=iOSDRMProtection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iOSDRMProtection.js","sourceRoot":"","sources":["../../src/drm/iOSDRMProtection.ts"],"names":[],"mappings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