eme-encryption-scheme-polyfill
Advanced tools
Comparing version 2.1.0 to 2.1.1
# Changelog | ||
## [2.1.1](https://github.com/shaka-project/eme-encryption-scheme-polyfill/compare/v2.1.0...v2.1.1) (2022-08-10) | ||
### Bug Fixes | ||
* Fix ES6 transpilation ([#49](https://github.com/shaka-project/eme-encryption-scheme-polyfill/issues/49)) ([b170e12](https://github.com/shaka-project/eme-encryption-scheme-polyfill/commit/b170e12db57f772470eb98dbbb5327b1a03caabc)), closes [#48](https://github.com/shaka-project/eme-encryption-scheme-polyfill/issues/48) | ||
## [2.1.0](https://github.com/shaka-project/eme-encryption-scheme-polyfill/compare/v2.0.5...v2.1.0) (2022-07-22) | ||
@@ -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,t){if(t)return i?i(e()):e();try{var n=Promise.resolve(e());return i?n.then(i):n}catch(o){return Promise.reject(o)}}function n(e,i){var t=e();return t&&t.then?t.then(i):i(t)}function o(){}class s{static install(){s.originalRMKSA_||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(s.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=s.probeRMKSA_)}static probeRMKSA_(e,n){const o=this;return t((function(){return i(s.originalRMKSA_.call(o,e,n),(function(i){return l(i)?(navigator.requestMediaKeySystemAccess=s.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=s.polyfillRMKSA_,s.polyfillRMKSA_.call(o,e,n))}))}))}static polyfillRMKSA_(e,n){const o=this;return t((function(){const t=c(e),a=[];for(const e of n){const i=s.filterCapabilities_(e.videoCapabilities,t),n=s.filterCapabilities_(e.audioCapabilities,t);if(e.videoCapabilities&&e.videoCapabilities.length&&!i.length);else if(e.audioCapabilities&&e.audioCapabilities.length&&!n.length);else{const t=Object.assign({},e);t.videoCapabilities=i,t.audioCapabilities=n,a.push(t)}}if(!a.length){const e=new Error("Unsupported keySystem or supportedConfigurations.");throw e.name="NotSupportedError",e.code=DOMException.NOT_SUPPORTED_ERR,e}return i(s.originalRMKSA_.call(o,e,a),(function(e){return new r(e,t)}))}))}static filterCapabilities_(e,i){return e?e.filter(e=>!e.encryptionScheme||e.encryptionScheme==i):e}}class a{static install(){a.originalDecodingInfo_||navigator.mediaCapabilities&&(a.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,navigator.mediaCapabilities.decodingInfo=a.probeDecodingInfo_)}static probeDecodingInfo_(e){const o=this;return t((function(){return i(a.originalDecodingInfo_.call(o,e),(function(t){let s=!1;if(!e.keySystemConfiguration)return t;const r=t.keySystemAccess;return r&&l(r)?(navigator.mediaCapabilities.decodingInfo=a.originalDecodingInfo_,t):(navigator.mediaCapabilities.decodingInfo=a.polyfillDecodingInfo_,n((function(){if(!r)return i(a.getMediaKeySystemAccess_(e),(function(e){return t.keySystemAccess=e,s=!0,t}))}),(function(i){return s?i:a.polyfillDecodingInfo_.call(o,e)})))}))}))}static polyfillDecodingInfo_(e){const s=this;return t((function(){let t=null;if(e.keySystemConfiguration){const n=e.keySystemConfiguration,o=n.keySystem,s=n.audio&&n.audio.encryptionScheme,a=n.video&&n.video.encryptionScheme;t=c(o);const r={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:e};if(s&&s!=t)return i(r);if(a&&a!=t)return i(r)}return i(a.originalDecodingInfo_.call(s,e),(function(s){return n((function(){if(!s.keySystemAccess)return function(t){var n=function(){if(e.keySystemConfiguration)return i(a.getMediaKeySystemAccess_(e),(function(e){s.keySystemAccess=e}))}();if(n&&n.then)return n.then(o)}();s.keySystemAccess=new r(s.keySystemAccess,t)}),(function(){return s}))}))}))}static getMediaKeySystemAccess_(e){return t((function(){const t=a.convertToMediaKeySystemConfig_(e);return i(navigator.requestMediaKeySystemAccess(e.keySystemConfiguration.keySystem,[t]))}))}static convertToMediaKeySystemConfig_(e){const i=e.keySystemConfiguration,t=[],n=[];if(i.audio){const n={robustness:i.audio.robustness||"",contentType:e.audio.contentType};t.push(n)}if(i.video){const t={robustness:i.video.robustness||"",contentType:e.video.contentType};n.push(t)}const o={initDataTypes:i.initDataType?[i.initDataType]:[],distinctiveIdentifier:i.distinctiveIdentifier,persistentState:i.persistentState,sessionTypes:i.sessionTypes};return t.length&&(o.audioCapabilities=t),n.length&&(o.videoCapabilities=n),o}}class r{constructor(e,i){this.mksa_=e,this.scheme_=i,this.keySystem=e.keySystem}getConfiguration(){const e=this.mksa_.getConfiguration();if(e.videoCapabilities)for(const i of e.videoCapabilities)i.encryptionScheme=this.scheme_;if(e.audioCapabilities)for(const i of e.audioCapabilities)i.encryptionScheme=this.scheme_;return e}createMediaKeys(){return this.mksa_.createMediaKeys()}}function c(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-1-9":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)}function l(e){const i=e.getConfiguration(),t=i.videoCapabilities&&i.videoCapabilities[0],n=i.audioCapabilities&&i.audioCapabilities[0],o=t||n;return!(!o||void 0===o.encryptionScheme)}s.originalRMKSA_,a.originalDecodingInfo_;return e.exports&&(e.exports=class{static install(){s.install(),a.install()}}),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 t(e,t,i){return i?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function i(e,t){var i=e();return i&&i.then?i.then(t):t(i)}function n(){}function r(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(e){if("string"==typeof e)return o(e,void 0);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?o(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}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(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==i.return||i.return()}finally{if(c)throw a}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,i){return t&&s(e.prototype,t),i&&s(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}var u=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){e.originalRMKSA_||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_)}},{key:"probeRMKSA_",value:function(i,n){try{var r=this;return t(e.originalRMKSA_.call(r,i,n),(function(t){return d(t)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,t):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(r,i,n))}))}catch(o){return Promise.reject(o)}}},{key:"polyfillRMKSA_",value:function(i,n){try{var o,a=y(i),s=[],c=r(n);try{for(c.s();!(o=c.n()).done;){var u=o.value,l=e.filterCapabilities_(u.videoCapabilities,a),d=e.filterCapabilities_(u.audioCapabilities,a);if(u.videoCapabilities&&u.videoCapabilities.length&&!l.length);else if(u.audioCapabilities&&u.audioCapabilities.length&&!d.length);else{var p=Object.assign({},u);p.videoCapabilities=l,p.audioCapabilities=d,s.push(p)}}}catch(m){c.e(m)}finally{c.f()}if(!s.length){var v=new Error("Unsupported keySystem or supportedConfigurations.");throw v.name="NotSupportedError",v.code=DOMException.NOT_SUPPORTED_ERR,v}return t(e.originalRMKSA_.call(this,i,s),(function(e){return new f(e,a)}))}catch(g){return Promise.reject(g)}}},{key:"filterCapabilities_",value:function(e,t){return e?e.filter((function(e){return!e.encryptionScheme||e.encryptionScheme==t})):e}}]),e}(),l=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){e.originalDecodingInfo_||navigator.mediaCapabilities&&(e.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,navigator.mediaCapabilities.decodingInfo=e.probeDecodingInfo_)}},{key:"probeDecodingInfo_",value:function(n){try{var r=this;return t(e.originalDecodingInfo_.call(r,n),(function(o){var a=!1;if(!n.keySystemConfiguration)return o;var s=o.keySystemAccess;return s&&d(s)?(navigator.mediaCapabilities.decodingInfo=e.originalDecodingInfo_,o):(navigator.mediaCapabilities.decodingInfo=e.polyfillDecodingInfo_,i((function(){if(!s)return t(e.getMediaKeySystemAccess_(n),(function(e){return o.keySystemAccess=e,a=!0,o}))}),(function(t){return a?t:e.polyfillDecodingInfo_.call(r,n)})))}))}catch(o){return Promise.reject(o)}}},{key:"polyfillDecodingInfo_",value:function(r){try{var o=null;if(r.keySystemConfiguration){var a=r.keySystemConfiguration,s=a.keySystem,c=a.audio&&a.audio.encryptionScheme,u=a.video&&a.video.encryptionScheme;o=y(s);var l={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:r};if(c&&c!=o)return t(l);if(u&&u!=o)return t(l)}return t(e.originalDecodingInfo_.call(this,r),(function(a){return i((function(){if(!a.keySystemAccess)return function(i){var o=function(){if(r.keySystemConfiguration)return t(e.getMediaKeySystemAccess_(r),(function(e){a.keySystemAccess=e}))}();if(o&&o.then)return o.then(n)}();a.keySystemAccess=new f(a.keySystemAccess,o)}),(function(){return a}))}))}catch(d){return Promise.reject(d)}}},{key:"getMediaKeySystemAccess_",value:function(i){try{var n=e.convertToMediaKeySystemConfig_(i);return t(navigator.requestMediaKeySystemAccess(i.keySystemConfiguration.keySystem,[n]))}catch(r){return Promise.reject(r)}}},{key:"convertToMediaKeySystemConfig_",value:function(e){var t=e.keySystemConfiguration,i=[],n=[];if(t.audio){var r={robustness:t.audio.robustness||"",contentType:e.audio.contentType};i.push(r)}if(t.video){var o={robustness:t.video.robustness||"",contentType:e.video.contentType};n.push(o)}var a={initDataTypes:t.initDataType?[t.initDataType]:[],distinctiveIdentifier:t.distinctiveIdentifier,persistentState:t.persistentState,sessionTypes:t.sessionTypes};return i.length&&(a.audioCapabilities=i),n.length&&(a.videoCapabilities=n),a}}]),e}(),f=function(){function e(t,i){a(this,e),this.mksa_=t,this.scheme_=i,this.keySystem=t.keySystem}return c(e,[{key:"getConfiguration",value:function(){var e=this.mksa_.getConfiguration();if(e.videoCapabilities){var t,i=r(e.videoCapabilities);try{for(i.s();!(t=i.n()).done;)t.value.encryptionScheme=this.scheme_}catch(a){i.e(a)}finally{i.f()}}if(e.audioCapabilities){var n,o=r(e.audioCapabilities);try{for(o.s();!(n=o.n()).done;)n.value.encryptionScheme=this.scheme_}catch(a){o.e(a)}finally{o.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-1-9":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)}function d(e){var t=e.getConfiguration(),i=t.videoCapabilities&&t.videoCapabilities[0],n=t.audioCapabilities&&t.audioCapabilities[0],r=i||n;return!(!r||void 0===r.encryptionScheme)}u.originalRMKSA_,l.originalDecodingInfo_;var p=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){u.install(),l.install()}}]),e}();return e.exports&&(e.exports=p),e=e.exports})); |
{ | ||
"name": "eme-encryption-scheme-polyfill", | ||
"description": "A polyfill for the encryptionScheme field in EME", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"license": "Apache-2.0", | ||
@@ -21,3 +21,3 @@ "author": "Google", | ||
"closure-compiler-check": "google-closure-compiler -O ADVANCED --generate_exports --js_output_file /dev/null --jscomp_error '*' closure-compiler-check/* index.js", | ||
"build": "browserify index.js -s EncryptionSchemePolyfills -t babelify -t stripify -p tinyify -p browserify-header -o dist/eme-encryption-scheme-polyfill.js", | ||
"build": "browserify index.js -s EncryptionSchemePolyfills -t [ babelify --presets [ @babel/preset-env ] ] -t stripify -p tinyify -p browserify-header -o dist/eme-encryption-scheme-polyfill.js", | ||
"prepublishOnly": "npm test" | ||
@@ -24,0 +24,0 @@ }, |
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
48729