New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eme-encryption-scheme-polyfill

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eme-encryption-scheme-polyfill - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

2

dist/eme-encryption-scheme-polyfill.js

@@ -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 r(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 o(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)?o(e,void 0):void 0}}(e))||i&&e&&"number"==typeof e.length){t&&(e=t);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(){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 o(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 r=this;return i(e.originalRMKSA_.call(r,t,n),(function(i){return d(i)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(r,t,n))}))}catch(o){return Promise.reject(o)}}},{key:"polyfillRMKSA_",value:function(t,n){try{var o,a=y(t),s=[],c=r(n);try{for(c.s();!(o=c.n()).done;){var l=o.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 r=this;return i(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_,t((function(){if(!s)return i(e.getMediaKeySystemAccess_(n),(function(e){return o.keySystemAccess=e,a=!0,o}))}),(function(i){return a?i:e.polyfillDecodingInfo_.call(r,n)})))}))}catch(o){return Promise.reject(o)}}},{key:"polyfillDecodingInfo_",value:function(r){try{var o=null,a=null;if(r.keySystemConfiguration){var s=r.keySystemConfiguration,c=s.keySystem;a=s.audio&&s.audio.encryptionScheme,o=s.video&&s.video.encryptionScheme;var l=y(c),u={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:r};if(!p(a,l))return i(u);if(!p(o,l))return i(u)}return i(e.originalDecodingInfo_.call(this,r),(function(s){return t((function(){if(!s.keySystemAccess)return function(t){var o=function(){if(r.keySystemConfiguration)return i(e.getMediaKeySystemAccess_(r),(function(e){s.keySystemAccess=e}))}();if(o&&o.then)return o.then(n)}();s.keySystemAccess=new f(s.keySystemAccess,o,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(r){return Promise.reject(r)}}},{key:"convertToMediaKeySystemConfig_",value:function(e){var i=e.keySystemConfiguration,t=[],n=[];if(i.audio){var r={robustness:i.audio.robustness||"",contentType:e.audio.contentType,encryptionScheme:i.audio.encryptionScheme};t.push(r)}if(i.video){var o={robustness:i.video.robustness||"",contentType:e.video.contentType,encryptionScheme:i.video.encryptionScheme};n.push(o)}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=r(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,o=r(e.audioCapabilities);try{for(o.s();!(n=o.n()).done;)n.value.encryptionScheme=this.audioScheme_}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":e.startsWith("com.huawei")?"cenc":(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],r=t||n;return!(!r||void 0===r.encryptionScheme)}function p(e,i){return!e||e==i||!("cbcs"!=e&&"cbcs-1-9"!=e||!(m.isRecentFirefox||m.isRecentWebOS||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,m.isRecentWebOS=function(){var e=navigator.userAgent||"";if(!e.includes("Web0S"))return!1;var i=e.match(/Chrome\/(\d+)/);return!!i&&parseInt(i[1],10)>=79}(),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 r(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 o(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)?o(e,void 0):void 0}}(e))||i&&e&&"number"==typeof e.length){t&&(e=t);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(){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 o(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 u=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 r=this;return i(e.originalRMKSA_.call(r,t,n),(function(i){return d(i)?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(r,t,n))}))}catch(o){return Promise.reject(o)}}},{key:"polyfillRMKSA_",value:function(t,n){try{var o,a=y(t),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(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}(),l=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 r=this;return i(e.originalDecodingInfo_.call(r,n),(function(o){var a=!1;if(!o.supported)return o;if(!n.keySystemConfiguration)return o;var s=o.keySystemAccess;return s&&d(s)?(navigator.mediaCapabilities.decodingInfo=e.originalDecodingInfo_,o):(navigator.mediaCapabilities.decodingInfo=e.polyfillDecodingInfo_,t((function(){if(!s)return i(e.getMediaKeySystemAccess_(n),(function(e){return o.keySystemAccess=e,a=!0,o}))}),(function(i){return a?i:e.polyfillDecodingInfo_.call(r,n)})))}))}catch(o){return Promise.reject(o)}}},{key:"polyfillDecodingInfo_",value:function(r){try{var o=null,a=null;if(r.keySystemConfiguration){var s=r.keySystemConfiguration,c=s.keySystem;a=s.audio&&s.audio.encryptionScheme,o=s.video&&s.video.encryptionScheme;var u=y(c),l={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:r};if(!p(a,u))return i(l);if(!p(o,u))return i(l)}return i(e.originalDecodingInfo_.call(this,r),(function(s){return t((function(){if(!s.keySystemAccess)return function(t){var o=function(){if(r.keySystemConfiguration)return i(e.getMediaKeySystemAccess_(r),(function(e){s.keySystemAccess=e}))}();if(o&&o.then)return o.then(n)}();s.keySystemAccess=new f(s.keySystemAccess,o,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(r){return Promise.reject(r)}}},{key:"convertToMediaKeySystemConfig_",value:function(e){var i=e.keySystemConfiguration,t=[],n=[];if(i.audio){var r={robustness:i.audio.robustness||"",contentType:e.audio.contentType,encryptionScheme:i.audio.encryptionScheme};t.push(r)}if(i.video){var o={robustness:i.video.robustness||"",contentType:e.video.contentType,encryptionScheme:i.video.encryptionScheme};n.push(o)}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=r(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,o=r(e.audioCapabilities);try{for(o.s();!(n=o.n()).done;)n.value.encryptionScheme=this.audioScheme_}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":e.startsWith("com.huawei")?"cenc":(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],r=t||n;return!(!r||void 0===r.encryptionScheme)}function p(e,i){return!e||e==i||!("cbcs"!=e&&"cbcs-1-9"!=e||!(m.isRecentFirefox||m.isRecentWebOS||m.isChromecast))}u.originalRMKSA_,l.originalDecodingInfo_;var m=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){u.install(),l.install()}}]),e}();return m.isChromecast=navigator.userAgent.includes("CrKey"),m.isRecentFirefox=parseInt(navigator.userAgent.split("Firefox/").pop(),10)>=100,m.isRecentWebOS=function(){var e=navigator.userAgent||"";if(!e.includes("Web0S"))return!1;var i=e.match(/Chrome\/(\d+)/);return!!i&&parseInt(i[1],10)>=79}(),e.exports&&(e.exports=m),e=e.exports}));

@@ -306,2 +306,7 @@ /*!

// If the config is not supported, we don't need to try anything else.
if (!capabilities.supported) {
return capabilities;
}
if (!requestedConfiguration.keySystemConfiguration) {

@@ -308,0 +313,0 @@ // This was not a query regarding encrypted content. The results are

{
"name": "eme-encryption-scheme-polyfill",
"description": "A polyfill for the encryptionScheme field in EME",
"version": "2.2.0",
"version": "2.2.1",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": "Google",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc