eme-encryption-scheme-polyfill
Advanced tools
Comparing version 2.1.4 to 2.1.5
# Changelog | ||
## [2.1.5](https://github.com/shaka-project/eme-encryption-scheme-polyfill/compare/v2.1.4...v2.1.5) (2024-05-21) | ||
### Bug Fixes | ||
* Fix access to null properties ([#73](https://github.com/shaka-project/eme-encryption-scheme-polyfill/issues/73)) ([339842e](https://github.com/shaka-project/eme-encryption-scheme-polyfill/commit/339842e94372d2f1b5d9605b88b38908fc2a6459)) | ||
## [2.1.4](https://github.com/shaka-project/eme-encryption-scheme-polyfill/compare/v2.1.3...v2.1.4) (2024-05-16) | ||
@@ -5,0 +12,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)}function t(e,i){var t=e();return t&&t.then?t.then(i):i(t)}function n(){}function o(e,i){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,i){if(e){if("string"==typeof e)return r(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,void 0):void 0}}(e))||i&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==t.return||t.return()}finally{if(c)throw a}}}}function r(e,i){(null==i||i>e.length)&&(i=e.length);for(var t=0,n=new Array(i);t<i;t++)n[t]=e[t];return n}function a(e,i){if(!(e instanceof i))throw new TypeError("Cannot call a class as a function")}function s(e,i){for(var t=0;t<i.length;t++){var n=i[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,i,t){return i&&s(e.prototype,i),t&&s(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var l=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){e.originalRMKSA_||navigator.emeEncryptionSchemePolyfilled||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_,navigator.emeEncryptionSchemePolyfilled=!0)}},{key:"probeRMKSA_",value:function(t,n){try{var o=this;return i(e.originalRMKSA_.call(o,t,n),(function(i){return d(i)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(o,t,n))}))}catch(r){return Promise.reject(r)}}},{key:"polyfillRMKSA_",value:function(t,n){try{var r,a=y(t),s=[],c=o(n);try{for(c.s();!(r=c.n()).done;){var l=r.value,u=e.filterCapabilities_(l.videoCapabilities,a),d=e.filterCapabilities_(l.audioCapabilities,a);if(l.videoCapabilities&&l.videoCapabilities.length&&!u.length);else if(l.audioCapabilities&&l.audioCapabilities.length&&!d.length);else{var p=Object.assign({},l);p.videoCapabilities=u,p.audioCapabilities=d,s.push(p)}}}catch(v){c.e(v)}finally{c.f()}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){var i=s[0].videoCapabilities[0].encryptionScheme,t=s[0].audioCapabilities[0].encryptionScheme;return new f(e,i,t)}))}catch(g){return Promise.reject(g)}}},{key:"filterCapabilities_",value:function(e,i){return e?e.filter((function(e){return p(e.encryptionScheme,i)})):e}}]),e}(),u=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){e.originalDecodingInfo_||navigator.mediaCapabilitiesEncryptionSchemePolyfilled||navigator.mediaCapabilities&&(e.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,navigator.mediaCapabilities.decodingInfo=e.probeDecodingInfo_,navigator.mediaCapabilitiesEncryptionSchemePolyfilled=!0)}},{key:"probeDecodingInfo_",value:function(n){try{var o=this;return i(e.originalDecodingInfo_.call(o,n),(function(r){var a=!1;if(!n.keySystemConfiguration)return r;var s=r.keySystemAccess;return s&&d(s)?(navigator.mediaCapabilities.decodingInfo=e.originalDecodingInfo_,r):(navigator.mediaCapabilities.decodingInfo=e.polyfillDecodingInfo_,t((function(){if(!s)return i(e.getMediaKeySystemAccess_(n),(function(e){return r.keySystemAccess=e,a=!0,r}))}),(function(i){return a?i:e.polyfillDecodingInfo_.call(o,n)})))}))}catch(r){return Promise.reject(r)}}},{key:"polyfillDecodingInfo_",value:function(o){try{var r=null,a=null;if(o.keySystemConfiguration){var s=o.keySystemConfiguration,c=s.keySystem;a=s.audio&&s.audio.encryptionScheme,r=s.video&&s.video.encryptionScheme;var l=y(c),u={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:o};if(!p(a,l))return i(u);if(!p(r,l))return i(u)}return i(e.originalDecodingInfo_.call(this,o),(function(s){return t((function(){if(!s.keySystemAccess)return function(t){var r=function(){if(o.keySystemConfiguration)return i(e.getMediaKeySystemAccess_(o),(function(e){s.keySystemAccess=e}))}();if(r&&r.then)return r.then(n)}();s.keySystemAccess=new f(s.keySystemAccess,r,a)}),(function(){return s}))}))}catch(d){return Promise.reject(d)}}},{key:"getMediaKeySystemAccess_",value:function(t){try{var n=e.convertToMediaKeySystemConfig_(t);return i(navigator.requestMediaKeySystemAccess(t.keySystemConfiguration.keySystem,[n]))}catch(o){return Promise.reject(o)}}},{key:"convertToMediaKeySystemConfig_",value:function(e){var i=e.keySystemConfiguration,t=[],n=[];if(i.audio){var o={robustness:i.audio.robustness||"",contentType:e.audio.contentType,encryptionScheme:i.audio.encryptionScheme};t.push(o)}if(i.video){var r={robustness:i.video.robustness||"",contentType:e.video.contentType,encryptionScheme:i.video.encryptionScheme};n.push(r)}var a={initDataTypes:i.initDataType?[i.initDataType]:[],distinctiveIdentifier:i.distinctiveIdentifier,persistentState:i.persistentState,sessionTypes:i.sessionTypes};return t.length&&(a.audioCapabilities=t),n.length&&(a.videoCapabilities=n),a}}]),e}(),f=function(){function e(i,t,n){a(this,e),this.mksa_=i,this.videoScheme_=t||null,this.audioScheme_=n||null,this.keySystem=i.keySystem}return c(e,[{key:"getConfiguration",value:function(){var e=this.mksa_.getConfiguration();if(e.videoCapabilities){var i,t=o(e.videoCapabilities);try{for(t.s();!(i=t.n()).done;)i.value.encryptionScheme=this.videoScheme_}catch(a){t.e(a)}finally{t.f()}}if(e.audioCapabilities){var n,r=o(e.audioCapabilities);try{for(r.s();!(n=r.n()).done;)n.value.encryptionScheme=this.audioScheme_}catch(a){r.e(a)}finally{r.f()}}return e}},{key:"createMediaKeys",value:function(){return this.mksa_.createMediaKeys()}}]),e}();function y(e){return e.startsWith("com.widevine")||e.startsWith("com.microsoft")||e.startsWith("com.chromecast")||e.startsWith("com.adobe")||e.startsWith("org.w3")?"cenc":e.startsWith("com.apple")?"cbcs":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)}function d(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)}function p(e,i){return!e||e==i||!("cbcs"!=e&&"cbcs-1-9"!=e||!m.isRecentFirefox&&!m.isChromecast)}l.originalRMKSA_,u.originalDecodingInfo_;var m=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){l.install(),u.install()}}]),e}();return m.isChromecast=navigator.userAgent.includes("CrKey"),m.isRecentFirefox=parseInt(navigator.userAgent.split("Firefox/").pop(),10)>=100,e.exports&&(e.exports=m),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)}function t(e,i){var t=e();return t&&t.then?t.then(i):i(t)}function n(){}function o(e,i){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,i){if(e){if("string"==typeof e)return r(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,void 0):void 0}}(e))||i&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==t.return||t.return()}finally{if(c)throw a}}}}function r(e,i){(null==i||i>e.length)&&(i=e.length);for(var t=0,n=new Array(i);t<i;t++)n[t]=e[t];return n}function a(e,i){if(!(e instanceof i))throw new TypeError("Cannot call a class as a function")}function s(e,i){for(var t=0;t<i.length;t++){var n=i[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,i,t){return i&&s(e.prototype,i),t&&s(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var l=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){e.originalRMKSA_||navigator.emeEncryptionSchemePolyfilled||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_,navigator.emeEncryptionSchemePolyfilled=!0)}},{key:"probeRMKSA_",value:function(t,n){try{var o=this;return i(e.originalRMKSA_.call(o,t,n),(function(i){return d(i)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(o,t,n))}))}catch(r){return Promise.reject(r)}}},{key:"polyfillRMKSA_",value:function(t,n){try{var r,a=y(t),s=[],c=o(n);try{for(c.s();!(r=c.n()).done;){var l=r.value,u=e.filterCapabilities_(l.videoCapabilities,a),d=e.filterCapabilities_(l.audioCapabilities,a);if(l.videoCapabilities&&l.videoCapabilities.length&&!u.length);else if(l.audioCapabilities&&l.audioCapabilities.length&&!d.length);else{var p=Object.assign({},l);p.videoCapabilities=u,p.audioCapabilities=d,s.push(p)}}}catch(v){c.e(v)}finally{c.f()}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){var i=null,t=null;return s[0]&&(s[0].videoCapabilities&&(i=s[0].videoCapabilities[0].encryptionScheme),s[0].audioCapabilities&&(t=s[0].audioCapabilities[0].encryptionScheme)),new f(e,i,t)}))}catch(g){return Promise.reject(g)}}},{key:"filterCapabilities_",value:function(e,i){return e?e.filter((function(e){return p(e.encryptionScheme,i)})):e}}]),e}(),u=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){e.originalDecodingInfo_||navigator.mediaCapabilitiesEncryptionSchemePolyfilled||navigator.mediaCapabilities&&(e.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,navigator.mediaCapabilities.decodingInfo=e.probeDecodingInfo_,navigator.mediaCapabilitiesEncryptionSchemePolyfilled=!0)}},{key:"probeDecodingInfo_",value:function(n){try{var o=this;return i(e.originalDecodingInfo_.call(o,n),(function(r){var a=!1;if(!n.keySystemConfiguration)return r;var s=r.keySystemAccess;return s&&d(s)?(navigator.mediaCapabilities.decodingInfo=e.originalDecodingInfo_,r):(navigator.mediaCapabilities.decodingInfo=e.polyfillDecodingInfo_,t((function(){if(!s)return i(e.getMediaKeySystemAccess_(n),(function(e){return r.keySystemAccess=e,a=!0,r}))}),(function(i){return a?i:e.polyfillDecodingInfo_.call(o,n)})))}))}catch(r){return Promise.reject(r)}}},{key:"polyfillDecodingInfo_",value:function(o){try{var r=null,a=null;if(o.keySystemConfiguration){var s=o.keySystemConfiguration,c=s.keySystem;a=s.audio&&s.audio.encryptionScheme,r=s.video&&s.video.encryptionScheme;var l=y(c),u={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:o};if(!p(a,l))return i(u);if(!p(r,l))return i(u)}return i(e.originalDecodingInfo_.call(this,o),(function(s){return t((function(){if(!s.keySystemAccess)return function(t){var r=function(){if(o.keySystemConfiguration)return i(e.getMediaKeySystemAccess_(o),(function(e){s.keySystemAccess=e}))}();if(r&&r.then)return r.then(n)}();s.keySystemAccess=new f(s.keySystemAccess,r,a)}),(function(){return s}))}))}catch(d){return Promise.reject(d)}}},{key:"getMediaKeySystemAccess_",value:function(t){try{var n=e.convertToMediaKeySystemConfig_(t);return i(navigator.requestMediaKeySystemAccess(t.keySystemConfiguration.keySystem,[n]))}catch(o){return Promise.reject(o)}}},{key:"convertToMediaKeySystemConfig_",value:function(e){var i=e.keySystemConfiguration,t=[],n=[];if(i.audio){var o={robustness:i.audio.robustness||"",contentType:e.audio.contentType,encryptionScheme:i.audio.encryptionScheme};t.push(o)}if(i.video){var r={robustness:i.video.robustness||"",contentType:e.video.contentType,encryptionScheme:i.video.encryptionScheme};n.push(r)}var a={initDataTypes:i.initDataType?[i.initDataType]:[],distinctiveIdentifier:i.distinctiveIdentifier,persistentState:i.persistentState,sessionTypes:i.sessionTypes};return t.length&&(a.audioCapabilities=t),n.length&&(a.videoCapabilities=n),a}}]),e}(),f=function(){function e(i,t,n){a(this,e),this.mksa_=i,this.videoScheme_=t||null,this.audioScheme_=n||null,this.keySystem=i.keySystem}return c(e,[{key:"getConfiguration",value:function(){var e=this.mksa_.getConfiguration();if(e.videoCapabilities){var i,t=o(e.videoCapabilities);try{for(t.s();!(i=t.n()).done;)i.value.encryptionScheme=this.videoScheme_}catch(a){t.e(a)}finally{t.f()}}if(e.audioCapabilities){var n,r=o(e.audioCapabilities);try{for(r.s();!(n=r.n()).done;)n.value.encryptionScheme=this.audioScheme_}catch(a){r.e(a)}finally{r.f()}}return e}},{key:"createMediaKeys",value:function(){return this.mksa_.createMediaKeys()}}]),e}();function y(e){return e.startsWith("com.widevine")||e.startsWith("com.microsoft")||e.startsWith("com.chromecast")||e.startsWith("com.adobe")||e.startsWith("org.w3")?"cenc":e.startsWith("com.apple")?"cbcs":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)}function d(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)}function p(e,i){return!e||e==i||!("cbcs"!=e&&"cbcs-1-9"!=e||!m.isRecentFirefox&&!m.isChromecast)}l.originalRMKSA_,u.originalDecodingInfo_;var m=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){l.install(),u.install()}}]),e}();return m.isChromecast=navigator.userAgent.includes("CrKey"),m.isRecentFirefox=parseInt(navigator.userAgent.split("Firefox/").pop(),10)>=100,e.exports&&(e.exports=m),e=e.exports})); |
16
index.js
@@ -190,6 +190,14 @@ /*! | ||
// returned configuration. | ||
const videoScheme = filteredSupportedConfigurations[0] | ||
.videoCapabilities[0].encryptionScheme; | ||
const audioScheme = filteredSupportedConfigurations[0] | ||
.audioCapabilities[0].encryptionScheme; | ||
let videoScheme = null; | ||
let audioScheme = null; | ||
if (filteredSupportedConfigurations[0]) { | ||
if (filteredSupportedConfigurations[0].videoCapabilities) { | ||
videoScheme = filteredSupportedConfigurations[0] | ||
.videoCapabilities[0].encryptionScheme; | ||
} | ||
if (filteredSupportedConfigurations[0].audioCapabilities) { | ||
audioScheme = filteredSupportedConfigurations[0] | ||
.audioCapabilities[0].encryptionScheme; | ||
} | ||
} | ||
return new EmeEncryptionSchemePolyfillMediaKeySystemAccess( | ||
@@ -196,0 +204,0 @@ mediaKeySystemAccess, videoScheme, audioScheme); |
{ | ||
"name": "eme-encryption-scheme-polyfill", | ||
"description": "A polyfill for the encryptionScheme field in EME", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google", |
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
54312
657