unified-video-framework 1.4.413 → 1.4.414

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 (106) hide show
  1. package/package.json +6 -1
  2. package/packages/core/src/BasePlayer.d.ts +61 -0
  3. package/packages/core/src/BasePlayer.d.ts.map +1 -0
  4. package/packages/core/src/BasePlayer.js +175 -0
  5. package/packages/core/src/BasePlayer.js.map +1 -0
  6. package/packages/core/src/VideoPlayerFactory.d.ts +8 -0
  7. package/packages/core/src/VideoPlayerFactory.d.ts.map +1 -0
  8. package/packages/core/src/VideoPlayerFactory.js +95 -0
  9. package/packages/core/src/VideoPlayerFactory.js.map +1 -0
  10. package/packages/core/src/analytics/adapters/PlayerAnalyticsAdapter.d.ts +18 -0
  11. package/packages/core/src/analytics/adapters/PlayerAnalyticsAdapter.d.ts.map +1 -0
  12. package/packages/core/src/analytics/adapters/PlayerAnalyticsAdapter.js +117 -0
  13. package/packages/core/src/analytics/adapters/PlayerAnalyticsAdapter.js.map +1 -0
  14. package/packages/core/src/analytics/core/AnalyticsProvider.d.ts +18 -0
  15. package/packages/core/src/analytics/core/AnalyticsProvider.d.ts.map +1 -0
  16. package/packages/core/src/analytics/core/AnalyticsProvider.js +99 -0
  17. package/packages/core/src/analytics/core/AnalyticsProvider.js.map +1 -0
  18. package/packages/core/src/analytics/core/DynamicAnalyticsManager.d.ts +20 -0
  19. package/packages/core/src/analytics/core/DynamicAnalyticsManager.d.ts.map +1 -0
  20. package/packages/core/src/analytics/core/DynamicAnalyticsManager.js +161 -0
  21. package/packages/core/src/analytics/core/DynamicAnalyticsManager.js.map +1 -0
  22. package/packages/core/src/analytics/core/EventBatcher.d.ts +32 -0
  23. package/packages/core/src/analytics/core/EventBatcher.d.ts.map +1 -0
  24. package/packages/core/src/analytics/core/EventBatcher.js +98 -0
  25. package/packages/core/src/analytics/core/EventBatcher.js.map +1 -0
  26. package/packages/core/src/analytics/core/PlayerAnalytics.d.ts +19 -0
  27. package/packages/core/src/analytics/core/PlayerAnalytics.d.ts.map +1 -0
  28. package/packages/core/src/analytics/core/PlayerAnalytics.js +80 -0
  29. package/packages/core/src/analytics/core/PlayerAnalytics.js.map +1 -0
  30. package/packages/core/src/analytics/index.d.ts +13 -0
  31. package/packages/core/src/analytics/index.d.ts.map +1 -0
  32. package/packages/core/src/analytics/index.js +13 -0
  33. package/packages/core/src/analytics/index.js.map +1 -0
  34. package/packages/core/src/analytics/types/AnalyticsTypes.d.ts +239 -0
  35. package/packages/core/src/analytics/types/AnalyticsTypes.d.ts.map +1 -0
  36. package/packages/core/src/analytics/types/AnalyticsTypes.js +8 -0
  37. package/packages/core/src/analytics/types/AnalyticsTypes.js.map +1 -0
  38. package/packages/core/src/analytics/utils/DeviceDetection.d.ts +27 -0
  39. package/packages/core/src/analytics/utils/DeviceDetection.d.ts.map +1 -0
  40. package/packages/core/src/analytics/utils/DeviceDetection.js +184 -0
  41. package/packages/core/src/analytics/utils/DeviceDetection.js.map +1 -0
  42. package/packages/core/src/chapter-manager.d.ts +39 -0
  43. package/packages/core/src/chapter-manager.d.ts.map +1 -0
  44. package/packages/core/src/chapter-manager.js +173 -0
  45. package/packages/core/src/chapter-manager.js.map +1 -0
  46. package/packages/core/src/index.d.ts +10 -0
  47. package/packages/core/src/index.d.ts.map +1 -0
  48. package/packages/core/src/index.js +8 -0
  49. package/packages/core/src/index.js.map +1 -0
  50. package/packages/core/src/interfaces/IVideoPlayer.d.ts +229 -0
  51. package/packages/core/src/interfaces/IVideoPlayer.d.ts.map +1 -0
  52. package/packages/core/src/interfaces/IVideoPlayer.js +2 -0
  53. package/packages/core/src/interfaces/IVideoPlayer.js.map +1 -0
  54. package/packages/core/src/interfaces.d.ts +455 -0
  55. package/packages/core/src/interfaces.d.ts.map +1 -0
  56. package/packages/core/src/interfaces.js +32 -0
  57. package/packages/core/src/interfaces.js.map +1 -0
  58. package/packages/core/src/utils/EventEmitter.d.ts +14 -0
  59. package/packages/core/src/utils/EventEmitter.d.ts.map +1 -0
  60. package/packages/core/src/utils/EventEmitter.js +55 -0
  61. package/packages/core/src/utils/EventEmitter.js.map +1 -0
  62. package/packages/web/dist/drm/DRMManager.d.ts +1 -1
  63. package/packages/web/dist/drm/DRMManager.d.ts.map +1 -1
  64. package/packages/web/dist/drm/DRMManager.js +7 -7
  65. package/packages/web/dist/drm/DRMManager.js.map +1 -1
  66. package/packages/web/dist/drm/providers/BunnyNetProvider.d.ts +1 -1
  67. package/packages/web/dist/drm/providers/BunnyNetProvider.d.ts.map +1 -1
  68. package/packages/web/dist/drm/providers/BunnyNetProvider.js +13 -13
  69. package/packages/web/dist/drm/providers/BunnyNetProvider.js.map +1 -1
  70. package/packages/web/dist/drm/providers/GenericProvider.d.ts +1 -1
  71. package/packages/web/dist/drm/providers/GenericProvider.d.ts.map +1 -1
  72. package/packages/web/dist/drm/providers/GenericProvider.js +8 -6
  73. package/packages/web/dist/drm/providers/GenericProvider.js.map +1 -1
  74. package/packages/web/dist/drm/systems/FairPlayDRM.d.ts.map +1 -1
  75. package/packages/web/dist/drm/systems/FairPlayDRM.js +2 -2
  76. package/packages/web/dist/drm/systems/FairPlayDRM.js.map +1 -1
  77. package/packages/web/dist/drm/systems/PlayReadyDRM.d.ts.map +1 -1
  78. package/packages/web/dist/drm/systems/PlayReadyDRM.js +7 -7
  79. package/packages/web/dist/drm/systems/PlayReadyDRM.js.map +1 -1
  80. package/packages/web/dist/drm/systems/WidevineDRM.d.ts.map +1 -1
  81. package/packages/web/dist/drm/systems/WidevineDRM.js +2 -2
  82. package/packages/web/dist/drm/systems/WidevineDRM.js.map +1 -1
  83. package/packages/web/dist/drm/types/BunnyNetTypes.d.ts +1 -1
  84. package/packages/web/dist/drm/types/BunnyNetTypes.d.ts.map +1 -1
  85. package/packages/web/dist/drm/types/DRMTypes.d.ts +1 -1
  86. package/packages/web/dist/drm/types/DRMTypes.d.ts.map +1 -1
  87. package/packages/web/dist/drm/types/DRMTypes.js +5 -5
  88. package/packages/web/dist/drm/types/DRMTypes.js.map +1 -1
  89. package/packages/web/dist/drm/utils/BrowserDetector.d.ts +1 -1
  90. package/packages/web/dist/drm/utils/BrowserDetector.d.ts.map +1 -1
  91. package/packages/web/dist/drm/utils/BrowserDetector.js +10 -10
  92. package/packages/web/dist/drm/utils/BrowserDetector.js.map +1 -1
  93. package/packages/web/src/drm/DRMManager.ts +214 -213
  94. package/packages/web/src/drm/index.ts +37 -37
  95. package/packages/web/src/drm/providers/BunnyNetProvider.ts +171 -170
  96. package/packages/web/src/drm/providers/GenericProvider.ts +151 -148
  97. package/packages/web/src/drm/systems/BaseDRM.ts +68 -68
  98. package/packages/web/src/drm/systems/FairPlayDRM.ts +306 -305
  99. package/packages/web/src/drm/systems/PlayReadyDRM.ts +132 -131
  100. package/packages/web/src/drm/systems/WidevineDRM.ts +106 -105
  101. package/packages/web/src/drm/types/BunnyNetTypes.ts +35 -35
  102. package/packages/web/src/drm/types/DRMTypes.ts +92 -91
  103. package/packages/web/src/drm/utils/BrowserDetector.ts +233 -232
  104. package/packages/web/src/drm/utils/CertificateManager.ts +86 -86
  105. package/packages/web/src/drm/utils/DRMErrorHandler.ts +84 -84
  106. package/packages/web/src/drm/utils/LicenseRequestHandler.ts +180 -180
@@ -1,170 +1,171 @@
1
- /**
2
- * Bunny.net DRM Provider
3
- * Helper utilities for Bunny.net MediaCage DRM integration
4
- */
5
-
6
- import { DRMType, DRMConfig } from '@unified-video/core';
7
- import { ExtendedDRMConfig } from '../types/DRMTypes';
8
- import { BunnyNetConfig, BUNNY_NET_ENDPOINTS } from '../types/BunnyNetTypes';
9
-
10
- export class BunnyNetProvider {
11
- /**
12
- * Generate complete DRM config from Bunny.net credentials
13
- */
14
- static createDRMConfig(config: BunnyNetConfig): ExtendedDRMConfig {
15
- const { libraryId, videoId, drmType = DRMType.WIDEVINE } = config;
16
-
17
- const drmConfig: ExtendedDRMConfig = {
18
- type: drmType,
19
- licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
20
- provider: 'bunny',
21
- libraryId,
22
- videoId,
23
- };
24
-
25
- // Add FairPlay-specific settings
26
- if (drmType === DRMType.FAIRPLAY) {
27
- drmConfig.certificateUrl = this.getCertificateUrl(libraryId);
28
- drmConfig.fairplayOptions = {
29
- certificateUrl: this.getCertificateUrl(libraryId),
30
- licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
31
- };
32
- }
33
-
34
- // Add Widevine-specific settings
35
- if (drmType === DRMType.WIDEVINE) {
36
- drmConfig.widevineOptions = {
37
- licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
38
- };
39
- }
40
-
41
- // Add PlayReady-specific settings
42
- if (drmType === DRMType.PLAYREADY) {
43
- drmConfig.playreadyOptions = {
44
- licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
45
- };
46
- }
47
-
48
- return drmConfig;
49
- }
50
-
51
- /**
52
- * Get license URL for specific DRM type
53
- */
54
- static getLicenseUrl(drmType: DRMType, libraryId: string, videoId: string): string {
55
- switch (drmType) {
56
- case DRMType.WIDEVINE:
57
- return BUNNY_NET_ENDPOINTS.WIDEVINE_LICENSE(libraryId, videoId);
58
-
59
- case DRMType.FAIRPLAY:
60
- return BUNNY_NET_ENDPOINTS.FAIRPLAY_LICENSE(libraryId, videoId);
61
-
62
- case DRMType.PLAYREADY:
63
- return BUNNY_NET_ENDPOINTS.PLAYREADY_LICENSE(libraryId, videoId);
64
-
65
- default:
66
- throw new Error(`Unsupported DRM type for Bunny.net: ${drmType}`);
67
- }
68
- }
69
-
70
- /**
71
- * Get certificate URL (FairPlay only)
72
- */
73
- static getCertificateUrl(libraryId: string): string {
74
- return BUNNY_NET_ENDPOINTS.FAIRPLAY_CERTIFICATE(libraryId);
75
- }
76
-
77
- /**
78
- * Validate Bunny.net DRM configuration
79
- */
80
- static validateConfig(config: BunnyNetConfig): { valid: boolean; error?: string } {
81
- if (!config.libraryId || !config.videoId) {
82
- return {
83
- valid: false,
84
- error: 'Bunny.net DRM requires libraryId and videoId',
85
- };
86
- }
87
-
88
- if (!/^\d+$/.test(config.libraryId)) {
89
- return {
90
- valid: false,
91
- error: 'libraryId must be a numeric string',
92
- };
93
- }
94
-
95
- return { valid: true };
96
- }
97
-
98
- /**
99
- * Auto-detect if a DRM config is for Bunny.net
100
- */
101
- static isBunnyNetConfig(config: DRMConfig): boolean {
102
- return !!(
103
- config.licenseUrl?.includes('bunnycdn.com') ||
104
- config.certificateUrl?.includes('bunnycdn.com') ||
105
- config.fairplayOptions?.licenseUrl?.includes('bunnycdn.com') ||
106
- config.fairplayOptions?.certificateUrl?.includes('bunnycdn.com') ||
107
- config.widevineOptions?.licenseUrl?.includes('bunnycdn.com') ||
108
- config.playreadyOptions?.licenseUrl?.includes('bunnycdn.com')
109
- );
110
- }
111
-
112
- /**
113
- * Extract library and video IDs from Bunny.net URLs
114
- */
115
- static extractIdsFromUrl(url: string): { libraryId?: string; videoId?: string } {
116
- if (!url) return {};
117
-
118
- const widevineMatch = url.match(/WidevineLicense\/([^/]+)\/([^/?]+)/);
119
- const fairplayLicenseMatch = url.match(/FairPlay\/([^/]+)\/license.*videoId=([^&]+)/);
120
- const fairplayCertMatch = url.match(/FairPlay\/([^/]+)\/certificate/);
121
- const playreadyMatch = url.match(/PlayReadyLicense\/([^/]+)\/([^/?]+)/);
122
-
123
- if (widevineMatch) {
124
- return { libraryId: widevineMatch[1], videoId: widevineMatch[2] };
125
- }
126
- if (fairplayLicenseMatch) {
127
- return { libraryId: fairplayLicenseMatch[1], videoId: fairplayLicenseMatch[2] };
128
- }
129
- if (fairplayCertMatch) {
130
- return { libraryId: fairplayCertMatch[1] };
131
- }
132
- if (playreadyMatch) {
133
- return { libraryId: playreadyMatch[1], videoId: playreadyMatch[2] };
134
- }
135
-
136
- return {};
137
- }
138
-
139
- /**
140
- * Create multi-DRM config for Bunny.net (auto-detects browser)
141
- */
142
- static createMultiDRMConfig(libraryId: string, videoId: string): ExtendedDRMConfig {
143
- // Primary Widevine config with FairPlay fallback
144
- const config: ExtendedDRMConfig = {
145
- type: DRMType.WIDEVINE,
146
- licenseUrl: this.getLicenseUrl(DRMType.WIDEVINE, libraryId, videoId),
147
- provider: 'bunny',
148
- libraryId,
149
- videoId,
150
-
151
- // Widevine options
152
- widevineOptions: {
153
- licenseUrl: this.getLicenseUrl(DRMType.WIDEVINE, libraryId, videoId),
154
- },
155
-
156
- // FairPlay options (for Safari fallback)
157
- fairplayOptions: {
158
- certificateUrl: this.getCertificateUrl(libraryId),
159
- licenseUrl: this.getLicenseUrl(DRMType.FAIRPLAY, libraryId, videoId),
160
- },
161
-
162
- // PlayReady options (for Edge fallback)
163
- playreadyOptions: {
164
- licenseUrl: this.getLicenseUrl(DRMType.PLAYREADY, libraryId, videoId),
165
- },
166
- };
167
-
168
- return config;
169
- }
170
- }
1
+ /**
2
+ * Bunny.net DRM Provider
3
+ * Helper utilities for Bunny.net MediaCage DRM integration
4
+ */
5
+
6
+ import type { DRMType, DRMConfig } from '@unified-video/core';
7
+ import { DRMType as DRMTypeEnum } from '@unified-video/core';
8
+ import { ExtendedDRMConfig } from '../types/DRMTypes';
9
+ import { BunnyNetConfig, BUNNY_NET_ENDPOINTS } from '../types/BunnyNetTypes';
10
+
11
+ export class BunnyNetProvider {
12
+ /**
13
+ * Generate complete DRM config from Bunny.net credentials
14
+ */
15
+ static createDRMConfig(config: BunnyNetConfig): ExtendedDRMConfig {
16
+ const { libraryId, videoId, drmType = DRMTypeEnum.WIDEVINE } = config;
17
+
18
+ const drmConfig: ExtendedDRMConfig = {
19
+ type: drmType,
20
+ licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
21
+ provider: 'bunny',
22
+ libraryId,
23
+ videoId,
24
+ };
25
+
26
+ // Add FairPlay-specific settings
27
+ if (drmType === DRMTypeEnum.FAIRPLAY) {
28
+ drmConfig.certificateUrl = this.getCertificateUrl(libraryId);
29
+ drmConfig.fairplayOptions = {
30
+ certificateUrl: this.getCertificateUrl(libraryId),
31
+ licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
32
+ };
33
+ }
34
+
35
+ // Add Widevine-specific settings
36
+ if (drmType === DRMTypeEnum.WIDEVINE) {
37
+ drmConfig.widevineOptions = {
38
+ licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
39
+ };
40
+ }
41
+
42
+ // Add PlayReady-specific settings
43
+ if (drmType === DRMTypeEnum.PLAYREADY) {
44
+ drmConfig.playreadyOptions = {
45
+ licenseUrl: this.getLicenseUrl(drmType, libraryId, videoId),
46
+ };
47
+ }
48
+
49
+ return drmConfig;
50
+ }
51
+
52
+ /**
53
+ * Get license URL for specific DRM type
54
+ */
55
+ static getLicenseUrl(drmType: DRMType, libraryId: string, videoId: string): string {
56
+ switch (drmType) {
57
+ case DRMTypeEnum.WIDEVINE:
58
+ return BUNNY_NET_ENDPOINTS.WIDEVINE_LICENSE(libraryId, videoId);
59
+
60
+ case DRMTypeEnum.FAIRPLAY:
61
+ return BUNNY_NET_ENDPOINTS.FAIRPLAY_LICENSE(libraryId, videoId);
62
+
63
+ case DRMTypeEnum.PLAYREADY:
64
+ return BUNNY_NET_ENDPOINTS.PLAYREADY_LICENSE(libraryId, videoId);
65
+
66
+ default:
67
+ throw new Error(`Unsupported DRM type for Bunny.net: ${drmType}`);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Get certificate URL (FairPlay only)
73
+ */
74
+ static getCertificateUrl(libraryId: string): string {
75
+ return BUNNY_NET_ENDPOINTS.FAIRPLAY_CERTIFICATE(libraryId);
76
+ }
77
+
78
+ /**
79
+ * Validate Bunny.net DRM configuration
80
+ */
81
+ static validateConfig(config: BunnyNetConfig): { valid: boolean; error?: string } {
82
+ if (!config.libraryId || !config.videoId) {
83
+ return {
84
+ valid: false,
85
+ error: 'Bunny.net DRM requires libraryId and videoId',
86
+ };
87
+ }
88
+
89
+ if (!/^\d+$/.test(config.libraryId)) {
90
+ return {
91
+ valid: false,
92
+ error: 'libraryId must be a numeric string',
93
+ };
94
+ }
95
+
96
+ return { valid: true };
97
+ }
98
+
99
+ /**
100
+ * Auto-detect if a DRM config is for Bunny.net
101
+ */
102
+ static isBunnyNetConfig(config: DRMConfig): boolean {
103
+ return !!(
104
+ config.licenseUrl?.includes('bunnycdn.com') ||
105
+ config.certificateUrl?.includes('bunnycdn.com') ||
106
+ config.fairplayOptions?.licenseUrl?.includes('bunnycdn.com') ||
107
+ config.fairplayOptions?.certificateUrl?.includes('bunnycdn.com') ||
108
+ config.widevineOptions?.licenseUrl?.includes('bunnycdn.com') ||
109
+ config.playreadyOptions?.licenseUrl?.includes('bunnycdn.com')
110
+ );
111
+ }
112
+
113
+ /**
114
+ * Extract library and video IDs from Bunny.net URLs
115
+ */
116
+ static extractIdsFromUrl(url: string): { libraryId?: string; videoId?: string } {
117
+ if (!url) return {};
118
+
119
+ const widevineMatch = url.match(/WidevineLicense\/([^/]+)\/([^/?]+)/);
120
+ const fairplayLicenseMatch = url.match(/FairPlay\/([^/]+)\/license.*videoId=([^&]+)/);
121
+ const fairplayCertMatch = url.match(/FairPlay\/([^/]+)\/certificate/);
122
+ const playreadyMatch = url.match(/PlayReadyLicense\/([^/]+)\/([^/?]+)/);
123
+
124
+ if (widevineMatch) {
125
+ return { libraryId: widevineMatch[1], videoId: widevineMatch[2] };
126
+ }
127
+ if (fairplayLicenseMatch) {
128
+ return { libraryId: fairplayLicenseMatch[1], videoId: fairplayLicenseMatch[2] };
129
+ }
130
+ if (fairplayCertMatch) {
131
+ return { libraryId: fairplayCertMatch[1] };
132
+ }
133
+ if (playreadyMatch) {
134
+ return { libraryId: playreadyMatch[1], videoId: playreadyMatch[2] };
135
+ }
136
+
137
+ return {};
138
+ }
139
+
140
+ /**
141
+ * Create multi-DRM config for Bunny.net (auto-detects browser)
142
+ */
143
+ static createMultiDRMConfig(libraryId: string, videoId: string): ExtendedDRMConfig {
144
+ // Primary Widevine config with FairPlay fallback
145
+ const config: ExtendedDRMConfig = {
146
+ type: DRMTypeEnum.WIDEVINE,
147
+ licenseUrl: this.getLicenseUrl(DRMTypeEnum.WIDEVINE, libraryId, videoId),
148
+ provider: 'bunny',
149
+ libraryId,
150
+ videoId,
151
+
152
+ // Widevine options
153
+ widevineOptions: {
154
+ licenseUrl: this.getLicenseUrl(DRMTypeEnum.WIDEVINE, libraryId, videoId),
155
+ },
156
+
157
+ // FairPlay options (for Safari fallback)
158
+ fairplayOptions: {
159
+ certificateUrl: this.getCertificateUrl(libraryId),
160
+ licenseUrl: this.getLicenseUrl(DRMTypeEnum.FAIRPLAY, libraryId, videoId),
161
+ },
162
+
163
+ // PlayReady options (for Edge fallback)
164
+ playreadyOptions: {
165
+ licenseUrl: this.getLicenseUrl(DRMTypeEnum.PLAYREADY, libraryId, videoId),
166
+ },
167
+ };
168
+
169
+ return config;
170
+ }
171
+ }
@@ -1,148 +1,151 @@
1
- /**
2
- * Generic DRM Provider
3
- * Helper utilities for generic DRM configurations
4
- */
5
-
6
- import { DRMType, DRMConfig } from '@unified-video/core';
7
- import { ExtendedDRMConfig } from '../types/DRMTypes';
8
-
9
- export class GenericProvider {
10
- /**
11
- * Create generic DRM config with sensible defaults
12
- */
13
- static createDRMConfig(config: {
14
- drmType: DRMType;
15
- licenseUrl: string;
16
- certificateUrl?: string;
17
- headers?: Record<string, string>;
18
- customData?: string;
19
- }): ExtendedDRMConfig {
20
- const drmConfig: ExtendedDRMConfig = {
21
- type: config.drmType,
22
- licenseUrl: config.licenseUrl,
23
- certificateUrl: config.certificateUrl,
24
- headers: config.headers,
25
- customData: config.customData,
26
- provider: 'generic',
27
- };
28
-
29
- // Add type-specific options
30
- switch (config.drmType) {
31
- case DRMType.FAIRPLAY:
32
- if (config.certificateUrl) {
33
- drmConfig.fairplayOptions = {
34
- certificateUrl: config.certificateUrl,
35
- licenseUrl: config.licenseUrl,
36
- };
37
- }
38
- break;
39
-
40
- case DRMType.WIDEVINE:
41
- drmConfig.widevineOptions = {
42
- licenseUrl: config.licenseUrl,
43
- };
44
- break;
45
-
46
- case DRMType.PLAYREADY:
47
- drmConfig.playreadyOptions = {
48
- licenseUrl: config.licenseUrl,
49
- customData: config.customData,
50
- };
51
- break;
52
- }
53
-
54
- return drmConfig;
55
- }
56
-
57
- /**
58
- * Validate generic DRM configuration
59
- */
60
- static validateConfig(config: DRMConfig): { valid: boolean; error?: string } {
61
- if (!config.type) {
62
- return {
63
- valid: false,
64
- error: 'DRM type is required',
65
- };
66
- }
67
-
68
- if (!config.licenseUrl) {
69
- return {
70
- valid: false,
71
- error: 'License URL is required',
72
- };
73
- }
74
-
75
- // FairPlay requires certificate URL
76
- if (config.type === DRMType.FAIRPLAY) {
77
- const certificateUrl = config.certificateUrl || config.fairplayOptions?.certificateUrl;
78
- if (!certificateUrl) {
79
- return {
80
- valid: false,
81
- error: 'FairPlay requires certificateUrl',
82
- };
83
- }
84
- }
85
-
86
- // Validate URL format
87
- try {
88
- new URL(config.licenseUrl);
89
- } catch (e) {
90
- return {
91
- valid: false,
92
- error: 'Invalid license URL format',
93
- };
94
- }
95
-
96
- if (config.certificateUrl) {
97
- try {
98
- new URL(config.certificateUrl);
99
- } catch (e) {
100
- return {
101
- valid: false,
102
- error: 'Invalid certificate URL format',
103
- };
104
- }
105
- }
106
-
107
- return { valid: true };
108
- }
109
-
110
- /**
111
- * Create multi-DRM config for generic provider
112
- */
113
- static createMultiDRMConfig(config: {
114
- widevine: { licenseUrl: string };
115
- fairplay: { licenseUrl: string; certificateUrl: string };
116
- playready?: { licenseUrl: string; customData?: string };
117
- headers?: Record<string, string>;
118
- }): ExtendedDRMConfig {
119
- // Primary Widevine config with FairPlay and PlayReady fallbacks
120
- const drmConfig: ExtendedDRMConfig = {
121
- type: DRMType.WIDEVINE,
122
- licenseUrl: config.widevine.licenseUrl,
123
- provider: 'generic',
124
- headers: config.headers,
125
-
126
- // Widevine options
127
- widevineOptions: {
128
- licenseUrl: config.widevine.licenseUrl,
129
- },
130
-
131
- // FairPlay options
132
- fairplayOptions: {
133
- certificateUrl: config.fairplay.certificateUrl,
134
- licenseUrl: config.fairplay.licenseUrl,
135
- },
136
-
137
- // PlayReady options (optional)
138
- playreadyOptions: config.playready
139
- ? {
140
- licenseUrl: config.playready.licenseUrl,
141
- customData: config.playready.customData,
142
- }
143
- : undefined,
144
- };
145
-
146
- return drmConfig;
147
- }
148
- }
1
+ /**
2
+ * Generic DRM Provider
3
+ * Helper utilities for generic DRM configurations
4
+ */
5
+
6
+ import type { DRMType, DRMConfig } from '@unified-video/core';
7
+ import { ExtendedDRMConfig } from '../types/DRMTypes';
8
+
9
+ export class GenericProvider {
10
+ /**
11
+ * Create generic DRM config with sensible defaults
12
+ */
13
+ static createDRMConfig(config: {
14
+ drmType: DRMType;
15
+ licenseUrl: string;
16
+ certificateUrl?: string;
17
+ headers?: Record<string, string>;
18
+ customData?: string;
19
+ }): ExtendedDRMConfig {
20
+ const drmConfig: ExtendedDRMConfig = {
21
+ type: config.drmType,
22
+ licenseUrl: config.licenseUrl,
23
+ certificateUrl: config.certificateUrl,
24
+ headers: config.headers,
25
+ customData: config.customData,
26
+ provider: 'generic',
27
+ };
28
+
29
+ // Add type-specific options
30
+ const DRMTypeEnum = require('../../../core/src/interfaces').DRMType;
31
+ switch (config.drmType) {
32
+ case DRMTypeEnum.FAIRPLAY:
33
+ if (config.certificateUrl) {
34
+ drmConfig.fairplayOptions = {
35
+ certificateUrl: config.certificateUrl,
36
+ licenseUrl: config.licenseUrl,
37
+ };
38
+ }
39
+ break;
40
+
41
+ case DRMTypeEnum.WIDEVINE:
42
+ drmConfig.widevineOptions = {
43
+ licenseUrl: config.licenseUrl,
44
+ };
45
+ break;
46
+
47
+ case DRMTypeEnum.PLAYREADY:
48
+ drmConfig.playreadyOptions = {
49
+ licenseUrl: config.licenseUrl,
50
+ customData: config.customData,
51
+ };
52
+ break;
53
+ }
54
+
55
+ return drmConfig;
56
+ }
57
+
58
+ /**
59
+ * Validate generic DRM configuration
60
+ */
61
+ static validateConfig(config: DRMConfig): { valid: boolean; error?: string } {
62
+ if (!config.type) {
63
+ return {
64
+ valid: false,
65
+ error: 'DRM type is required',
66
+ };
67
+ }
68
+
69
+ if (!config.licenseUrl) {
70
+ return {
71
+ valid: false,
72
+ error: 'License URL is required',
73
+ };
74
+ }
75
+
76
+ // FairPlay requires certificate URL
77
+ const DRMTypeEnum = require('../../../core/src/interfaces').DRMType;
78
+ if (config.type === DRMTypeEnum.FAIRPLAY) {
79
+ const certificateUrl = config.certificateUrl || config.fairplayOptions?.certificateUrl;
80
+ if (!certificateUrl) {
81
+ return {
82
+ valid: false,
83
+ error: 'FairPlay requires certificateUrl',
84
+ };
85
+ }
86
+ }
87
+
88
+ // Validate URL format
89
+ try {
90
+ new URL(config.licenseUrl);
91
+ } catch (e) {
92
+ return {
93
+ valid: false,
94
+ error: 'Invalid license URL format',
95
+ };
96
+ }
97
+
98
+ if (config.certificateUrl) {
99
+ try {
100
+ new URL(config.certificateUrl);
101
+ } catch (e) {
102
+ return {
103
+ valid: false,
104
+ error: 'Invalid certificate URL format',
105
+ };
106
+ }
107
+ }
108
+
109
+ return { valid: true };
110
+ }
111
+
112
+ /**
113
+ * Create multi-DRM config for generic provider
114
+ */
115
+ static createMultiDRMConfig(config: {
116
+ widevine: { licenseUrl: string };
117
+ fairplay: { licenseUrl: string; certificateUrl: string };
118
+ playready?: { licenseUrl: string; customData?: string };
119
+ headers?: Record<string, string>;
120
+ }): ExtendedDRMConfig {
121
+ // Primary Widevine config with FairPlay and PlayReady fallbacks
122
+ const DRMTypeEnum = require('../../../core/src/interfaces').DRMType;
123
+ const drmConfig: ExtendedDRMConfig = {
124
+ type: DRMTypeEnum.WIDEVINE,
125
+ licenseUrl: config.widevine.licenseUrl,
126
+ provider: 'generic',
127
+ headers: config.headers,
128
+
129
+ // Widevine options
130
+ widevineOptions: {
131
+ licenseUrl: config.widevine.licenseUrl,
132
+ },
133
+
134
+ // FairPlay options
135
+ fairplayOptions: {
136
+ certificateUrl: config.fairplay.certificateUrl,
137
+ licenseUrl: config.fairplay.licenseUrl,
138
+ },
139
+
140
+ // PlayReady options (optional)
141
+ playreadyOptions: config.playready
142
+ ? {
143
+ licenseUrl: config.playready.licenseUrl,
144
+ customData: config.playready.customData,
145
+ }
146
+ : undefined,
147
+ };
148
+
149
+ return drmConfig;
150
+ }
151
+ }