master
John Lauer rust/: the tree 2.0.594 is built from, pushed whole (pup-bridge#117); ship.sh pushes it on every release from now on ccda43b 1mo ago
(() => {
  try {
    const orig = navigator.requestMediaKeySystemAccess && navigator.requestMediaKeySystemAccess.bind(navigator);
    if (!orig) return;
    const shim = function requestMediaKeySystemAccess(keySystem, configs) {
      return orig(keySystem, configs).catch((e) => {
        if (keySystem === 'com.widevine.alpha') {
          const cfg = (configs && configs[0]) || {};
          return Promise.resolve({
            keySystem,
            getConfiguration: () => ({
              label: cfg.label || '',
              initDataTypes: cfg.initDataTypes || ['cenc'],
              audioCapabilities: cfg.audioCapabilities || [{ contentType: 'audio/mp4; codecs="mp4a.40.2"', robustness: 'SW_SECURE_CRYPTO' }],
              videoCapabilities: cfg.videoCapabilities || [{ contentType: 'video/mp4; codecs="avc1.42E01E"', robustness: 'SW_SECURE_CRYPTO' }],
              distinctiveIdentifier: 'optional', persistentState: 'optional', sessionTypes: ['temporary'],
            }),
            createMediaKeys: () => orig(keySystem, configs).then((a) => a.createMediaKeys()),
          });
        }
        throw e;
      });
    };
    // Detectors call Function.prototype.toString on APIs they suspect are overridden. Present this shim (and the
    // patched toString itself) as native code so the override is not itself the tell.
    const FT = Function.prototype.toString;
    const native = new Map();
    native.set(shim, 'function requestMediaKeySystemAccess() { [native code] }');
    const patchedToString = function toString() { const s = native.get(this); return s !== undefined ? s : FT.call(this); };
    native.set(patchedToString, 'function toString() { [native code] }');
    Object.defineProperty(Function.prototype, 'toString', { value: patchedToString, writable: true, configurable: true });
    Object.defineProperty(navigator, 'requestMediaKeySystemAccess', { value: shim, writable: true, configurable: true });
  } catch (e) {}
})();