rx-player 4.2.0-dev.2024080600 → 4.2.0-dev.2024080900

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 (39) hide show
  1. package/VERSION +1 -1
  2. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  3. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts +6 -1
  4. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts.map +1 -1
  5. package/dist/commonjs/main_thread/decrypt/attach_media_keys.js +2 -1
  6. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  7. package/dist/commonjs/main_thread/decrypt/content_decryptor.js +2 -1
  8. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts +17 -5
  9. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts.map +1 -1
  10. package/dist/commonjs/main_thread/decrypt/find_key_system.js +35 -26
  11. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts +5 -0
  12. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  13. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +4 -2
  14. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts +5 -0
  15. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts.map +1 -1
  16. package/dist/es2017/main_thread/api/public_api.js +2 -2
  17. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts +6 -1
  18. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts.map +1 -1
  19. package/dist/es2017/main_thread/decrypt/attach_media_keys.js +2 -1
  20. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  21. package/dist/es2017/main_thread/decrypt/content_decryptor.js +2 -1
  22. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts +17 -5
  23. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts.map +1 -1
  24. package/dist/es2017/main_thread/decrypt/find_key_system.js +40 -35
  25. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts +5 -0
  26. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  27. package/dist/es2017/main_thread/decrypt/get_media_keys.js +3 -1
  28. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts +5 -0
  29. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts.map +1 -1
  30. package/dist/rx-player.js +15 -15
  31. package/package.json +1 -1
  32. package/src/main_thread/api/public_api.ts +2 -2
  33. package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +376 -102
  34. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +4 -23
  35. package/src/main_thread/decrypt/attach_media_keys.ts +7 -0
  36. package/src/main_thread/decrypt/content_decryptor.ts +3 -1
  37. package/src/main_thread/decrypt/find_key_system.ts +53 -43
  38. package/src/main_thread/decrypt/get_media_keys.ts +8 -1
  39. package/src/main_thread/decrypt/utils/media_keys_infos_store.ts +6 -0
@@ -41,6 +41,22 @@ const incompatibleMKSAErrorMessage =
41
41
  "INCOMPATIBLE_KEYSYSTEMS: No key system compatible " +
42
42
  "with your wanted configuration has been found in the current browser.";
43
43
 
44
+ function removeCapabiltiesFromConfig(
45
+ baseConfig: MediaKeySystemConfiguration[],
46
+ ): MediaKeySystemConfiguration[] {
47
+ return baseConfig.map(
48
+ (config) =>
49
+ ({
50
+ ...config,
51
+ audioCapabilities: undefined,
52
+ videoCapabilities: undefined,
53
+ // Note: TypeScript is wrong here (2024-08-07), it thinks that
54
+ // `audioCapabilities` and `videoCapabilities` cannot be set to
55
+ // `undefined`, though they definitely can.
56
+ }) as unknown as MediaKeySystemConfiguration,
57
+ );
58
+ }
59
+
44
60
  /**
45
61
  * Check that the given `keySystemsConfigs` lead to an
46
62
  * `INCOMPATIBLE_KEYSYSTEMS` error.
@@ -97,8 +113,17 @@ describe("decrypt - global tests - media key system access", () => {
97
113
  await checkIncompatibleKeySystemsErrorMessage([
98
114
  { type: "foo", getLicense: getLicenseFn },
99
115
  ]);
100
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
101
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", defaultKSConfig);
116
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
117
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
118
+ 1,
119
+ "foo",
120
+ defaultKSConfig,
121
+ );
122
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
123
+ 2,
124
+ "foo",
125
+ removeCapabiltiesFromConfig(defaultKSConfig),
126
+ );
102
127
  });
103
128
 
104
129
  it("should throw if given multiple incompatible keySystemsConfigs", async () => {
@@ -114,7 +139,7 @@ describe("decrypt - global tests - media key system access", () => {
114
139
  { type: "baz", getLicense: neverCalledFn },
115
140
  ];
116
141
  await checkIncompatibleKeySystemsErrorMessage(config);
117
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(3);
142
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(6);
118
143
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
119
144
  1,
120
145
  "foo",
@@ -122,14 +147,29 @@ describe("decrypt - global tests - media key system access", () => {
122
147
  );
123
148
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
124
149
  2,
150
+ "foo",
151
+ removeCapabiltiesFromConfig(defaultKSConfig),
152
+ );
153
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
154
+ 3,
125
155
  "bar",
126
156
  defaultKSConfig,
127
157
  );
128
158
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
129
- 3,
159
+ 4,
160
+ "bar",
161
+ removeCapabiltiesFromConfig(defaultKSConfig),
162
+ );
163
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
164
+ 5,
130
165
  "baz",
131
166
  defaultKSConfig,
132
167
  );
168
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
169
+ 6,
170
+ "baz",
171
+ removeCapabiltiesFromConfig(defaultKSConfig),
172
+ );
133
173
  });
134
174
 
135
175
  it("should throw if given a single incompatible keySystemsConfigs", async () => {
@@ -142,8 +182,17 @@ describe("decrypt - global tests - media key system access", () => {
142
182
  await checkIncompatibleKeySystemsErrorMessage([
143
183
  { type: "foo", getLicense: neverCalledFn },
144
184
  ]);
145
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
146
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", defaultKSConfig);
185
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
186
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
187
+ 1,
188
+ "foo",
189
+ defaultKSConfig,
190
+ );
191
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
192
+ 2,
193
+ "foo",
194
+ removeCapabiltiesFromConfig(defaultKSConfig),
195
+ );
147
196
  });
148
197
 
149
198
  it('should set persistentState value if persistentState is set to "required"', async () => {
@@ -156,12 +205,21 @@ describe("decrypt - global tests - media key system access", () => {
156
205
  await checkIncompatibleKeySystemsErrorMessage([
157
206
  { type: "foo", getLicense: neverCalledFn, persistentState: "required" },
158
207
  ]);
159
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
208
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
160
209
 
161
- const expectedConfig = defaultKSConfig.map((conf) => {
210
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
162
211
  return { ...conf, persistentState: "required" };
163
212
  });
164
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
213
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
214
+ 1,
215
+ "foo",
216
+ expectedConfig,
217
+ );
218
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
219
+ 2,
220
+ "foo",
221
+ removeCapabiltiesFromConfig(expectedConfig),
222
+ );
165
223
  });
166
224
 
167
225
  it('should set persistentState value if persistentState is set to "not-allowed"', async () => {
@@ -178,12 +236,21 @@ describe("decrypt - global tests - media key system access", () => {
178
236
  persistentState: "not-allowed",
179
237
  },
180
238
  ]);
181
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
239
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
182
240
 
183
- const expectedConfig = defaultKSConfig.map((conf) => {
241
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
184
242
  return { ...conf, persistentState: "not-allowed" };
185
243
  });
186
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
244
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
245
+ 1,
246
+ "foo",
247
+ expectedConfig,
248
+ );
249
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
250
+ 2,
251
+ "foo",
252
+ removeCapabiltiesFromConfig(expectedConfig),
253
+ );
187
254
  });
188
255
 
189
256
  it('should set persistentState value if persistentState is set to "optional"', async () => {
@@ -196,12 +263,21 @@ describe("decrypt - global tests - media key system access", () => {
196
263
  await checkIncompatibleKeySystemsErrorMessage([
197
264
  { type: "foo", getLicense: neverCalledFn, persistentState: "optional" },
198
265
  ]);
199
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
266
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
200
267
 
201
- const expectedConfig = defaultKSConfig.map((conf) => {
268
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
202
269
  return { ...conf, persistentState: "optional" };
203
270
  });
204
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
271
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
272
+ 1,
273
+ "foo",
274
+ expectedConfig,
275
+ );
276
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
277
+ 2,
278
+ "foo",
279
+ removeCapabiltiesFromConfig(expectedConfig),
280
+ );
205
281
  });
206
282
 
207
283
  it('should set distinctiveIdentifier value if distinctiveIdentifier is set to "required"', async () => {
@@ -218,12 +294,21 @@ describe("decrypt - global tests - media key system access", () => {
218
294
  distinctiveIdentifier: "required",
219
295
  },
220
296
  ]);
221
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
297
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
222
298
 
223
- const expectedConfig = defaultKSConfig.map((conf) => {
299
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
224
300
  return { ...conf, distinctiveIdentifier: "required" };
225
301
  });
226
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
302
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
303
+ 1,
304
+ "foo",
305
+ expectedConfig,
306
+ );
307
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
308
+ 2,
309
+ "foo",
310
+ removeCapabiltiesFromConfig(expectedConfig),
311
+ );
227
312
  });
228
313
 
229
314
  it('should set distinctiveIdentifier value if distinctiveIdentifier is set to "not-allowed"', async () => {
@@ -240,12 +325,21 @@ describe("decrypt - global tests - media key system access", () => {
240
325
  distinctiveIdentifier: "not-allowed",
241
326
  },
242
327
  ]);
243
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
328
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
244
329
 
245
- const expectedConfig = defaultKSConfig.map((conf) => {
330
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
246
331
  return { ...conf, distinctiveIdentifier: "not-allowed" };
247
332
  });
248
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
333
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
334
+ 1,
335
+ "foo",
336
+ expectedConfig,
337
+ );
338
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
339
+ 2,
340
+ "foo",
341
+ removeCapabiltiesFromConfig(expectedConfig),
342
+ );
249
343
  });
250
344
 
251
345
  it('should set distinctiveIdentifier value if distinctiveIdentifier is set to "optional"', async () => {
@@ -262,12 +356,21 @@ describe("decrypt - global tests - media key system access", () => {
262
356
  distinctiveIdentifier: "optional",
263
357
  },
264
358
  ]);
265
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
359
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
266
360
 
267
- const expectedConfig = defaultKSConfig.map((conf) => {
361
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
268
362
  return { ...conf, distinctiveIdentifier: "optional" };
269
363
  });
270
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
364
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
365
+ 1,
366
+ "foo",
367
+ expectedConfig,
368
+ );
369
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
370
+ 2,
371
+ "foo",
372
+ removeCapabiltiesFromConfig(expectedConfig),
373
+ );
271
374
  });
272
375
 
273
376
  it("should want persistent sessions if persistentLicenseConfig is set", async () => {
@@ -288,16 +391,25 @@ describe("decrypt - global tests - media key system access", () => {
288
391
  await checkIncompatibleKeySystemsErrorMessage([
289
392
  { type: "foo", getLicense: neverCalledFn, persistentLicenseConfig },
290
393
  ]);
291
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
394
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
292
395
 
293
- const expectedConfig = defaultKSConfig.map((conf) => {
396
+ const expectedConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map((conf) => {
294
397
  return {
295
398
  ...conf,
296
399
  persistentState: "required",
297
400
  sessionTypes: ["temporary", "persistent-license"],
298
401
  };
299
402
  });
300
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", expectedConfig);
403
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
404
+ 1,
405
+ "foo",
406
+ expectedConfig,
407
+ );
408
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
409
+ 2,
410
+ "foo",
411
+ removeCapabiltiesFromConfig(expectedConfig),
412
+ );
301
413
  });
302
414
 
303
415
  it("should do nothing if persistentLicenseConfig is set to null", async () => {
@@ -310,8 +422,17 @@ describe("decrypt - global tests - media key system access", () => {
310
422
  await checkIncompatibleKeySystemsErrorMessage([
311
423
  { type: "foo", getLicense: neverCalledFn, persistentLicenseConfig: null },
312
424
  ]);
313
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
314
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", defaultKSConfig);
425
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
426
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
427
+ 1,
428
+ "foo",
429
+ defaultKSConfig,
430
+ );
431
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
432
+ 2,
433
+ "foo",
434
+ removeCapabiltiesFromConfig(defaultKSConfig),
435
+ );
315
436
  });
316
437
 
317
438
  it("should do nothing if persistentLicenseConfig is set to undefined", async () => {
@@ -328,8 +449,17 @@ describe("decrypt - global tests - media key system access", () => {
328
449
  persistentLicenseConfig: undefined,
329
450
  },
330
451
  ]);
331
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
332
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith("foo", defaultKSConfig);
452
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
453
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
454
+ 1,
455
+ "foo",
456
+ defaultKSConfig,
457
+ );
458
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
459
+ 2,
460
+ "foo",
461
+ removeCapabiltiesFromConfig(defaultKSConfig),
462
+ );
333
463
  });
334
464
 
335
465
  it("should translate a `clearkey` keySystem", async () => {
@@ -342,7 +472,7 @@ describe("decrypt - global tests - media key system access", () => {
342
472
  await checkIncompatibleKeySystemsErrorMessage([
343
473
  { type: "clearkey", getLicense: neverCalledFn },
344
474
  ]);
345
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
475
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(4);
346
476
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
347
477
  1,
348
478
  "webkit-org.w3.clearkey",
@@ -350,9 +480,19 @@ describe("decrypt - global tests - media key system access", () => {
350
480
  );
351
481
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
352
482
  2,
483
+ "webkit-org.w3.clearkey",
484
+ removeCapabiltiesFromConfig(defaultKSConfig),
485
+ );
486
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
487
+ 3,
353
488
  "org.w3.clearkey",
354
489
  defaultKSConfig,
355
490
  );
491
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
492
+ 4,
493
+ "org.w3.clearkey",
494
+ removeCapabiltiesFromConfig(defaultKSConfig),
495
+ );
356
496
  });
357
497
 
358
498
  it("should translate a `widevine` keySystem", async () => {
@@ -365,11 +505,17 @@ describe("decrypt - global tests - media key system access", () => {
365
505
  await checkIncompatibleKeySystemsErrorMessage([
366
506
  { type: "widevine", getLicense: neverCalledFn },
367
507
  ]);
368
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
369
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith(
508
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
509
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
510
+ 1,
370
511
  "com.widevine.alpha",
371
512
  defaultWidevineConfig,
372
513
  );
514
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
515
+ 2,
516
+ "com.widevine.alpha",
517
+ removeCapabiltiesFromConfig(defaultWidevineConfig),
518
+ );
373
519
  });
374
520
 
375
521
  it("should translate a `playready` keySystem", async () => {
@@ -382,7 +528,7 @@ describe("decrypt - global tests - media key system access", () => {
382
528
  await checkIncompatibleKeySystemsErrorMessage([
383
529
  { type: "playready", getLicense: neverCalledFn },
384
530
  ]);
385
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(4);
531
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(8);
386
532
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
387
533
  1,
388
534
  "com.microsoft.playready.recommendation",
@@ -390,19 +536,39 @@ describe("decrypt - global tests - media key system access", () => {
390
536
  );
391
537
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
392
538
  2,
539
+ "com.microsoft.playready.recommendation",
540
+ removeCapabiltiesFromConfig(defaultPRRecommendationKSConfig),
541
+ );
542
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
543
+ 3,
393
544
  "com.microsoft.playready",
394
545
  defaultKSConfig,
395
546
  );
396
547
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
397
- 3,
548
+ 4,
549
+ "com.microsoft.playready",
550
+ removeCapabiltiesFromConfig(defaultKSConfig),
551
+ );
552
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
553
+ 5,
398
554
  "com.chromecast.playready",
399
555
  defaultKSConfig,
400
556
  );
401
557
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
402
- 4,
558
+ 6,
559
+ "com.chromecast.playready",
560
+ removeCapabiltiesFromConfig(defaultKSConfig),
561
+ );
562
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
563
+ 7,
403
564
  "com.youtube.playready",
404
565
  defaultKSConfig,
405
566
  );
567
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
568
+ 8,
569
+ "com.youtube.playready",
570
+ removeCapabiltiesFromConfig(defaultKSConfig),
571
+ );
406
572
  });
407
573
 
408
574
  it("should translate a `fairplay` keySystem", async () => {
@@ -415,11 +581,15 @@ describe("decrypt - global tests - media key system access", () => {
415
581
  await checkIncompatibleKeySystemsErrorMessage([
416
582
  { type: "fairplay", getLicense: neverCalledFn },
417
583
  ]);
418
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
584
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
419
585
  expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith(
420
586
  "com.apple.fps.1_0",
421
587
  defaultKSConfig,
422
588
  );
589
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledWith(
590
+ "com.apple.fps.1_0",
591
+ removeCapabiltiesFromConfig(defaultKSConfig),
592
+ );
423
593
  });
424
594
 
425
595
  it("should translate a multiple keySystems at the same time", async () => {
@@ -433,7 +603,7 @@ describe("decrypt - global tests - media key system access", () => {
433
603
  { type: "playready", getLicense: neverCalledFn },
434
604
  { type: "clearkey", getLicense: neverCalledFn },
435
605
  ]);
436
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(6);
606
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(12);
437
607
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
438
608
  1,
439
609
  "com.microsoft.playready.recommendation",
@@ -441,29 +611,49 @@ describe("decrypt - global tests - media key system access", () => {
441
611
  );
442
612
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
443
613
  2,
444
- "com.microsoft.playready",
445
- defaultKSConfig,
614
+ "com.microsoft.playready.recommendation",
615
+ removeCapabiltiesFromConfig(defaultPRRecommendationKSConfig),
446
616
  );
447
617
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
448
618
  3,
449
- "com.chromecast.playready",
619
+ "com.microsoft.playready",
450
620
  defaultKSConfig,
451
621
  );
452
622
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
453
623
  4,
454
- "com.youtube.playready",
455
- defaultKSConfig,
624
+ "com.microsoft.playready",
625
+ removeCapabiltiesFromConfig(defaultKSConfig),
456
626
  );
457
627
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
458
628
  5,
459
- "webkit-org.w3.clearkey",
629
+ "com.chromecast.playready",
460
630
  defaultKSConfig,
461
631
  );
462
632
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
463
633
  6,
634
+ "com.chromecast.playready",
635
+ removeCapabiltiesFromConfig(defaultKSConfig),
636
+ );
637
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
638
+ 9,
639
+ "webkit-org.w3.clearkey",
640
+ defaultKSConfig,
641
+ );
642
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
643
+ 10,
644
+ "webkit-org.w3.clearkey",
645
+ removeCapabiltiesFromConfig(defaultKSConfig),
646
+ );
647
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
648
+ 11,
464
649
  "org.w3.clearkey",
465
650
  defaultKSConfig,
466
651
  );
652
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
653
+ 12,
654
+ "org.w3.clearkey",
655
+ removeCapabiltiesFromConfig(defaultKSConfig),
656
+ );
467
657
  });
468
658
 
469
659
  it("should translate a multiple keySystems at the same time with different configs", async () => {
@@ -492,7 +682,15 @@ describe("decrypt - global tests - media key system access", () => {
492
682
  getLicense: neverCalledFn,
493
683
  },
494
684
  ]);
495
- const expectedPRRecommendationPersistentConfig = defaultPRRecommendationKSConfig.map(
685
+ const expectedPRRecommendationPersistentConfig: MediaKeySystemConfiguration[] =
686
+ defaultPRRecommendationKSConfig.map((conf) => {
687
+ return {
688
+ ...conf,
689
+ persistentState: "required",
690
+ sessionTypes: ["temporary", "persistent-license"],
691
+ };
692
+ });
693
+ const expectedPersistentConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map(
496
694
  (conf) => {
497
695
  return {
498
696
  ...conf,
@@ -501,17 +699,12 @@ describe("decrypt - global tests - media key system access", () => {
501
699
  };
502
700
  },
503
701
  );
504
- const expectedPersistentConfig = defaultKSConfig.map((conf) => {
505
- return {
506
- ...conf,
507
- persistentState: "required",
508
- sessionTypes: ["temporary", "persistent-license"],
509
- };
510
- });
511
- const expectedIdentifierConfig = defaultKSConfig.map((conf) => {
512
- return { ...conf, distinctiveIdentifier: "required" };
513
- });
514
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(6);
702
+ const expectedIdentifierConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map(
703
+ (conf) => {
704
+ return { ...conf, distinctiveIdentifier: "required" };
705
+ },
706
+ );
707
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(12);
515
708
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
516
709
  1,
517
710
  "com.microsoft.playready.recommendation",
@@ -519,29 +712,59 @@ describe("decrypt - global tests - media key system access", () => {
519
712
  );
520
713
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
521
714
  2,
715
+ "com.microsoft.playready.recommendation",
716
+ removeCapabiltiesFromConfig(expectedPRRecommendationPersistentConfig),
717
+ );
718
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
719
+ 3,
522
720
  "com.microsoft.playready",
523
721
  expectedPersistentConfig,
524
722
  );
525
723
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
526
- 3,
724
+ 4,
725
+ "com.microsoft.playready",
726
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
727
+ );
728
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
729
+ 5,
527
730
  "com.chromecast.playready",
528
731
  expectedPersistentConfig,
529
732
  );
530
733
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
531
- 4,
734
+ 6,
735
+ "com.chromecast.playready",
736
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
737
+ );
738
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
739
+ 7,
532
740
  "com.youtube.playready",
533
741
  expectedPersistentConfig,
534
742
  );
535
743
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
536
- 5,
744
+ 8,
745
+ "com.youtube.playready",
746
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
747
+ );
748
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
749
+ 9,
537
750
  "webkit-org.w3.clearkey",
538
751
  expectedIdentifierConfig,
539
752
  );
540
753
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
541
- 6,
754
+ 10,
755
+ "webkit-org.w3.clearkey",
756
+ removeCapabiltiesFromConfig(expectedIdentifierConfig),
757
+ );
758
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
759
+ 11,
542
760
  "org.w3.clearkey",
543
761
  expectedIdentifierConfig,
544
762
  );
763
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
764
+ 12,
765
+ "org.w3.clearkey",
766
+ removeCapabiltiesFromConfig(expectedIdentifierConfig),
767
+ );
545
768
  });
546
769
 
547
770
  it("should set widevine robustnesses for a `com.widevine.alpha` keySystem", async () => {
@@ -565,19 +788,25 @@ describe("decrypt - global tests - media key system access", () => {
565
788
  getLicense: neverCalledFn,
566
789
  },
567
790
  ]);
568
- const expectedPersistentConfig = defaultWidevineConfig.map((conf) => {
569
- return {
570
- ...conf,
571
- persistentState: "required",
572
- sessionTypes: ["temporary", "persistent-license"],
573
- };
574
- });
575
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
791
+ const expectedPersistentConfig: MediaKeySystemConfiguration[] =
792
+ defaultWidevineConfig.map((conf) => {
793
+ return {
794
+ ...conf,
795
+ persistentState: "required",
796
+ sessionTypes: ["temporary", "persistent-license"],
797
+ };
798
+ });
799
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
576
800
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
577
801
  1,
578
802
  "com.widevine.alpha",
579
803
  expectedPersistentConfig,
580
804
  );
805
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
806
+ 2,
807
+ "com.widevine.alpha",
808
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
809
+ );
581
810
  });
582
811
 
583
812
  it("should set playready robustnesses for a `playready` keySystem", async () => {
@@ -606,24 +835,29 @@ describe("decrypt - global tests - media key system access", () => {
606
835
  getLicense: neverCalledFn,
607
836
  },
608
837
  ]);
609
- const expectedPersistentConfig = defaultKSConfig.map((conf) => {
610
- return {
611
- ...conf,
612
- persistentState: "required",
613
- sessionTypes: ["temporary", "persistent-license"],
614
- };
615
- });
616
- const expectedRecoPersistentConfig = defaultPRRecommendationKSConfig.map((conf) => {
617
- return {
618
- ...conf,
619
- persistentState: "required",
620
- sessionTypes: ["temporary", "persistent-license"],
621
- };
622
- });
623
- const expectedIdentifierConfig = defaultKSConfig.map((conf) => {
624
- return { ...conf, distinctiveIdentifier: "required" };
625
- });
626
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(6);
838
+ const expectedPersistentConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map(
839
+ (conf) => {
840
+ return {
841
+ ...conf,
842
+ persistentState: "required",
843
+ sessionTypes: ["temporary", "persistent-license"],
844
+ };
845
+ },
846
+ );
847
+ const expectedRecoPersistentConfig: MediaKeySystemConfiguration[] =
848
+ defaultPRRecommendationKSConfig.map((conf) => {
849
+ return {
850
+ ...conf,
851
+ persistentState: "required",
852
+ sessionTypes: ["temporary", "persistent-license"],
853
+ };
854
+ });
855
+ const expectedIdentifierConfig: MediaKeySystemConfiguration[] = defaultKSConfig.map(
856
+ (conf) => {
857
+ return { ...conf, distinctiveIdentifier: "required" };
858
+ },
859
+ );
860
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(12);
627
861
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
628
862
  1,
629
863
  "com.microsoft.playready.recommendation",
@@ -631,29 +865,59 @@ describe("decrypt - global tests - media key system access", () => {
631
865
  );
632
866
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
633
867
  2,
868
+ "com.microsoft.playready.recommendation",
869
+ removeCapabiltiesFromConfig(expectedRecoPersistentConfig),
870
+ );
871
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
872
+ 3,
634
873
  "com.microsoft.playready",
635
874
  expectedPersistentConfig,
636
875
  );
637
876
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
638
- 3,
877
+ 4,
878
+ "com.microsoft.playready",
879
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
880
+ );
881
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
882
+ 5,
639
883
  "com.chromecast.playready",
640
884
  expectedPersistentConfig,
641
885
  );
642
886
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
643
- 4,
887
+ 6,
888
+ "com.chromecast.playready",
889
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
890
+ );
891
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
892
+ 7,
644
893
  "com.youtube.playready",
645
894
  expectedPersistentConfig,
646
895
  );
647
896
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
648
- 5,
897
+ 8,
898
+ "com.youtube.playready",
899
+ removeCapabiltiesFromConfig(expectedPersistentConfig),
900
+ );
901
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
902
+ 9,
649
903
  "webkit-org.w3.clearkey",
650
904
  expectedIdentifierConfig,
651
905
  );
652
906
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
653
- 6,
907
+ 10,
908
+ "webkit-org.w3.clearkey",
909
+ removeCapabiltiesFromConfig(expectedIdentifierConfig),
910
+ );
911
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
912
+ 11,
654
913
  "org.w3.clearkey",
655
914
  expectedIdentifierConfig,
656
915
  );
916
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
917
+ 12,
918
+ "org.w3.clearkey",
919
+ removeCapabiltiesFromConfig(expectedIdentifierConfig),
920
+ );
657
921
  });
658
922
 
659
923
  it("should set playready robustnesses for a `com.microsoft.playready.recommendation` keySystem", async () => {
@@ -677,19 +941,25 @@ describe("decrypt - global tests - media key system access", () => {
677
941
  getLicense: neverCalledFn,
678
942
  },
679
943
  ]);
680
- const expectedRecoPersistentConfig = defaultPRRecommendationKSConfig.map((conf) => {
681
- return {
682
- ...conf,
683
- persistentState: "required",
684
- sessionTypes: ["temporary", "persistent-license"],
685
- };
686
- });
687
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(1);
944
+ const expectedRecoPersistentConfig: MediaKeySystemConfiguration[] =
945
+ defaultPRRecommendationKSConfig.map((conf) => {
946
+ return {
947
+ ...conf,
948
+ persistentState: "required",
949
+ sessionTypes: ["temporary", "persistent-license"],
950
+ };
951
+ });
952
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
688
953
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
689
954
  1,
690
955
  "com.microsoft.playready.recommendation",
691
956
  expectedRecoPersistentConfig,
692
957
  );
958
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
959
+ 2,
960
+ "com.microsoft.playready.recommendation",
961
+ removeCapabiltiesFromConfig(expectedRecoPersistentConfig),
962
+ );
693
963
  });
694
964
 
695
965
  it("should successfully create a MediaKeySystemAccess if given the right configuration", async () => {
@@ -723,11 +993,10 @@ describe("decrypt - global tests - media key system access", () => {
723
993
  });
724
994
 
725
995
  it("should successfully create a MediaKeySystemAccess if given multiple configurations where one works", async () => {
726
- let callNb = 0;
727
996
  const mockRequestMediaKeySystemAccess = vi
728
997
  .fn()
729
998
  .mockImplementation((keyType, conf) => {
730
- if (++callNb === 2) {
999
+ if (keyType === "some-other-working-key-system") {
731
1000
  return requestMediaKeySystemAccessNoMediaKeys(keyType, conf);
732
1001
  }
733
1002
  return Promise.reject("nope");
@@ -749,7 +1018,7 @@ describe("decrypt - global tests - media key system access", () => {
749
1018
  rej(error);
750
1019
  });
751
1020
  setTimeout(() => {
752
- expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(2);
1021
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenCalledTimes(3);
753
1022
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
754
1023
  1,
755
1024
  "com.widevine.alpha",
@@ -757,6 +1026,11 @@ describe("decrypt - global tests - media key system access", () => {
757
1026
  );
758
1027
  expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
759
1028
  2,
1029
+ "com.widevine.alpha",
1030
+ removeCapabiltiesFromConfig(defaultWidevineConfig),
1031
+ );
1032
+ expect(mockRequestMediaKeySystemAccess).toHaveBeenNthCalledWith(
1033
+ 3,
760
1034
  "some-other-working-key-system",
761
1035
  defaultKSConfig,
762
1036
  );