eme-encryption-scheme-polyfill
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -0,1 +1,9 @@ | ||
## 2.0.2 (2021-02-05) | ||
Bugfixes: | ||
- Fix infinite recursion when the MCap part of the polyfill is installed | ||
twice. | ||
- Fix exception when MCap returns a supported==false on encrypted content. | ||
## 2.0.1 (2020-02-21) | ||
@@ -2,0 +10,0 @@ |
@@ -8,2 +8,2 @@ /*! | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EncryptionSchemePolyfills=e()}}(function(){var e={exports:{}};function i(e,i,t){return t?i?i(e):e:(e&&e.then||(e=Promise.resolve(e)),i?e.then(i):e)}var t=function(){function e(){}return e.install=function(){e.originalRMKSA_||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_)},e.probeRMKSA_=function(t,n){try{var o=this;return i(e.originalRMKSA_.call(o,t,n),function(i){return a(i)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(o,t,n))})}catch(r){return Promise.reject(r)}},e.polyfillRMKSA_=function(t,n){try{var a=r(t),s=[],c=n,l=Array.isArray(c),f=0;for(c=l?c:c[Symbol.iterator]();;){var u;if(l){if(f>=c.length)break;u=c[f++]}else{if((f=c.next()).done)break;u=f.value}var d=u,y=e.filterCapabilities_(d.videoCapabilities,a),p=e.filterCapabilities_(d.audioCapabilities,a);if(d.videoCapabilities&&d.videoCapabilities.length&&!y.length);else if(d.audioCapabilities&&d.audioCapabilities.length&&!p.length);else{var g=Object.assign({},d);g.videoCapabilities=y,g.audioCapabilities=p,s.push(g)}}if(!s.length){var m=new Error("Unsupported keySystem or supportedConfigurations.");throw m.name="NotSupportedError",m.code=DOMException.NOT_SUPPORTED_ERR,m}return i(e.originalRMKSA_.call(this,t,s),function(e){return new o(e,a)})}catch(h){return Promise.reject(h)}},e.filterCapabilities_=function(e,i){return e?e.filter(function(e){return!e.encryptionScheme||e.encryptionScheme==i}):e},e}(),n=function(){function e(){}return e.install=function(){navigator.mediaCapabilities&&(e.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,navigator.mediaCapabilities.decodingInfo=e.probeDecodingInfo_)},e.probeDecodingInfo_=function(t){try{var n=this;return i(e.originalDecodingInfo_.call(n,t),function(i){return t.keySystemConfiguration?a(i.keySystemAccess)?(navigator.mediaCapabilities.decodingInfo=e.originalDecodingInfo_,i):(navigator.mediaCapabilities.decodingInfo=e.polyfillDecodingInfo_,e.polyfillDecodingInfo_.call(n,t)):i})}catch(o){return Promise.reject(o)}},e.polyfillDecodingInfo_=function(t){try{var n=null;if(t.keySystemConfiguration){var a=t.keySystemConfiguration,s=a.keySystem,c=a.audio&&a.audio.encryptionScheme,l=a.video&&a.video.encryptionScheme;n=r(s);var f={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:t};if(c&&c!=n)return f;if(l&&l!=n)return f}return i(e.originalDecodingInfo_.call(this,t),function(e){return e.keySystemAccess&&(e.keySystemAccess=new o(e.keySystemAccess,n)),e})}catch(u){return Promise.reject(u)}},e}(),o=function(){function e(e,i){this.mksa_=e,this.scheme_=i,this.keySystem=e.keySystem}var i=e.prototype;return i.getConfiguration=function(){var e=this.mksa_.getConfiguration();if(e.videoCapabilities){var i=e.videoCapabilities,t=Array.isArray(i),n=0;for(i=t?i:i[Symbol.iterator]();;){var o;if(t){if(n>=i.length)break;o=i[n++]}else{if((n=i.next()).done)break;o=n.value}o.encryptionScheme=this.scheme_}}if(e.audioCapabilities){var r=e.audioCapabilities,a=Array.isArray(r),s=0;for(r=a?r:r[Symbol.iterator]();;){var c;if(a){if(s>=r.length)break;c=r[s++]}else{if((s=r.next()).done)break;c=s.value}c.encryptionScheme=this.scheme_}}return e},i.createMediaKeys=function(){return this.mksa_.createMediaKeys()},e}();function r(e){return e.startsWith("com.widevine")?"cenc":e.startsWith("com.microsoft")?"cenc":e.startsWith("com.adobe")?"cenc":e.startsWith("org.w3")?"cenc":e.startsWith("com.apple")?"cbcs-1-9":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)}function a(e){var i=e.getConfiguration(),t=i.videoCapabilities&&i.videoCapabilities[0],n=i.audioCapabilities&&i.audioCapabilities[0],o=t||n;return!(!o||void 0===o.encryptionScheme)}t.originalRMKSA_,n.originalDecodingInfo_;var s=function(){function e(){}return e.install=function(){t.install(),n.install()},e}();return e.exports&&(e.exports=s),e=e.exports}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EncryptionSchemePolyfills=e()}}(function(){var e={exports:{}};function i(e,i,t){return t?i?i(e):e:(e&&e.then||(e=Promise.resolve(e)),i?e.then(i):e)}var t=function(){function e(){}return e.install=function(){e.originalRMKSA_||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_)},e.probeRMKSA_=function(t,n){try{var o=this;return i(e.originalRMKSA_.call(o,t,n),function(i){return a(i)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(o,t,n))})}catch(r){return Promise.reject(r)}},e.polyfillRMKSA_=function(t,n){try{var a=r(t),s=[],c=n,l=Array.isArray(c),f=0;for(c=l?c:c[Symbol.iterator]();;){var u;if(l){if(f>=c.length)break;u=c[f++]}else{if((f=c.next()).done)break;u=f.value}var y=u,d=e.filterCapabilities_(y.videoCapabilities,a),p=e.filterCapabilities_(y.audioCapabilities,a);if(y.videoCapabilities&&y.videoCapabilities.length&&!d.length);else if(y.audioCapabilities&&y.audioCapabilities.length&&!p.length);else{var g=Object.assign({},y);g.videoCapabilities=d,g.audioCapabilities=p,s.push(g)}}if(!s.length){var m=new Error("Unsupported keySystem or supportedConfigurations.");throw m.name="NotSupportedError",m.code=DOMException.NOT_SUPPORTED_ERR,m}return i(e.originalRMKSA_.call(this,t,s),function(e){return new o(e,a)})}catch(h){return Promise.reject(h)}},e.filterCapabilities_=function(e,i){return e?e.filter(function(e){return!e.encryptionScheme||e.encryptionScheme==i}):e},e}(),n=function(){function e(){}return e.install=function(){e.originalDecodingInfo_||navigator.mediaCapabilities&&(e.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,navigator.mediaCapabilities.decodingInfo=e.probeDecodingInfo_)},e.probeDecodingInfo_=function(t){try{var n=this;return i(e.originalDecodingInfo_.call(n,t),function(i){return t.keySystemConfiguration&&i.keySystemAccess?a(i.keySystemAccess)?(navigator.mediaCapabilities.decodingInfo=e.originalDecodingInfo_,i):(navigator.mediaCapabilities.decodingInfo=e.polyfillDecodingInfo_,e.polyfillDecodingInfo_.call(n,t)):i})}catch(o){return Promise.reject(o)}},e.polyfillDecodingInfo_=function(t){try{var n=null;if(t.keySystemConfiguration){var a=t.keySystemConfiguration,s=a.keySystem,c=a.audio&&a.audio.encryptionScheme,l=a.video&&a.video.encryptionScheme;n=r(s);var f={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:t};if(c&&c!=n)return f;if(l&&l!=n)return f}return i(e.originalDecodingInfo_.call(this,t),function(e){return e.keySystemAccess&&(e.keySystemAccess=new o(e.keySystemAccess,n)),e})}catch(u){return Promise.reject(u)}},e}(),o=function(){function e(e,i){this.mksa_=e,this.scheme_=i,this.keySystem=e.keySystem}var i=e.prototype;return i.getConfiguration=function(){var e=this.mksa_.getConfiguration();if(e.videoCapabilities){var i=e.videoCapabilities,t=Array.isArray(i),n=0;for(i=t?i:i[Symbol.iterator]();;){var o;if(t){if(n>=i.length)break;o=i[n++]}else{if((n=i.next()).done)break;o=n.value}o.encryptionScheme=this.scheme_}}if(e.audioCapabilities){var r=e.audioCapabilities,a=Array.isArray(r),s=0;for(r=a?r:r[Symbol.iterator]();;){var c;if(a){if(s>=r.length)break;c=r[s++]}else{if((s=r.next()).done)break;c=s.value}c.encryptionScheme=this.scheme_}}return e},i.createMediaKeys=function(){return this.mksa_.createMediaKeys()},e}();function r(e){return e.startsWith("com.widevine")?"cenc":e.startsWith("com.microsoft")?"cenc":e.startsWith("com.adobe")?"cenc":e.startsWith("org.w3")?"cenc":e.startsWith("com.apple")?"cbcs-1-9":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)}function a(e){var i=e.getConfiguration(),t=i.videoCapabilities&&i.videoCapabilities[0],n=i.audioCapabilities&&i.audioCapabilities[0],o=t||n;return!(!o||void 0===o.encryptionScheme)}t.originalRMKSA_,n.originalDecodingInfo_;var s=function(){function e(){}return e.install=function(){t.install(),n.install()},e}();return e.exports&&(e.exports=s),e=e.exports}); |
@@ -240,2 +240,6 @@ /*! | ||
static install() { | ||
if (McEncryptionSchemePolyfill.originalDecodingInfo_) { | ||
console.debug('McEncryptionSchemePolyfill: Already installed.'); | ||
return; | ||
} | ||
if (!navigator.mediaCapabilities) { | ||
@@ -280,3 +284,4 @@ console.debug('McEncryptionSchemePolyfill: MediaCapabilities not found'); | ||
if (!requestedConfiguration.keySystemConfiguration) { | ||
if (!requestedConfiguration.keySystemConfiguration || | ||
!capabilities.keySystemAccess) { | ||
// This was not a query regarding encrypted content. The results are | ||
@@ -283,0 +288,0 @@ // valid, but won't tell us anything about native support for |
{ | ||
"name": "eme-encryption-scheme-polyfill", | ||
"description": "A polyfill for the encryptionScheme field in EME", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "Apache-2.0", | ||
@@ -30,3 +30,3 @@ "author": "Google", | ||
"browserify-header": "^1.0.1", | ||
"eslint": "^6.6.0", | ||
"eslint": "^7.18.0", | ||
"eslint-config-google": "^0.14.0", | ||
@@ -33,0 +33,0 @@ "eslint-plugin-jsdoc": "^18.4.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40421
499