Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eme-encryption-scheme-polyfill

Package Overview
Dependencies
Maintainers
3
Versions
16
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.1.2 to 2.1.3

9

CHANGELOG.md
# Changelog
## [2.1.3](https://github.com/shaka-project/eme-encryption-scheme-polyfill/compare/v2.1.2...v2.1.3) (2024-05-14)
### Bug Fixes
* **demo:** Log demo errors to the console ([#68](https://github.com/shaka-project/eme-encryption-scheme-polyfill/issues/68)) ([ccfb179](https://github.com/shaka-project/eme-encryption-scheme-polyfill/commit/ccfb1793ca80594a368cb669b97fa3ce0c50a09c))
* **demo:** Upgrade UI combo box component ([#67](https://github.com/shaka-project/eme-encryption-scheme-polyfill/issues/67)) ([0d51ba6](https://github.com/shaka-project/eme-encryption-scheme-polyfill/commit/0d51ba6b96ccadf556d8f6ef90501906258d3186))
* Populate requested scheme into output, not default scheme ([#69](https://github.com/shaka-project/eme-encryption-scheme-polyfill/issues/69)) ([aa79c72](https://github.com/shaka-project/eme-encryption-scheme-polyfill/commit/aa79c72fdab050d98c682fee2b0b1d2bcdeb47d6))
## [2.1.2](https://github.com/shaka-project/eme-encryption-scheme-polyfill/compare/v2.1.1...v2.1.2) (2024-05-07)

@@ -5,0 +14,0 @@

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 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 p(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(!p(c,o))return t(l);if(!p(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":(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)}function p(e,t){return!e||e==t||!("cbcs"!=e&&"cbcs-1-9"!=e||!v.isRecentFirefox&&!v.isChromecast)}u.originalRMKSA_,l.originalDecodingInfo_;var v=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){u.install(),l.install()}}]),e}();return v.isChromecast=navigator.userAgent.includes("CrKey"),v.isRecentFirefox=parseInt(navigator.userAgent.split("Firefox/").pop(),10)>=100,e.exports&&(e.exports=v),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 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(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 u=r.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 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}(),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 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 u=y(c),l={powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:o};if(!p(a,u))return i(l);if(!p(r,u))return i(l)}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||!v.isRecentFirefox&&!v.isChromecast)}u.originalRMKSA_,l.originalDecodingInfo_;var v=function(){function e(){a(this,e)}return c(e,null,[{key:"install",value:function(){u.install(),l.install()}}]),e}();return v.isChromecast=navigator.userAgent.includes("CrKey"),v.isRecentFirefox=parseInt(navigator.userAgent.split("Firefox/").pop(),10)>=100,e.exports&&(e.exports=v),e=e.exports}));

@@ -181,6 +181,11 @@ /*!

this, keySystem, filteredSupportedConfigurations);
// Wrap the MKSA object in ours to provide the missing field in the
// returned configuration.
const videoScheme = filteredSupportedConfigurations[0]
.videoCapabilities[0].encryptionScheme;
const audioScheme = filteredSupportedConfigurations[0]
.audioCapabilities[0].encryptionScheme;
return new EmeEncryptionSchemePolyfillMediaKeySystemAccess(
mediaKeySystemAccess, supportedScheme);
mediaKeySystemAccess, videoScheme, audioScheme);
}

@@ -349,3 +354,4 @@

let supportedScheme = null;
let videoScheme = null;
let audioScheme = null;

@@ -357,8 +363,8 @@ if (requestedConfiguration.keySystemConfiguration) {

const audioScheme = keySystemConfig.audio &&
audioScheme = keySystemConfig.audio &&
keySystemConfig.audio.encryptionScheme;
const videoScheme = keySystemConfig.video &&
videoScheme = keySystemConfig.video &&
keySystemConfig.video.encryptionScheme;
supportedScheme = guessSupportedScheme(keySystem);
const supportedScheme = guessSupportedScheme(keySystem);

@@ -393,3 +399,3 @@ const notSupportedResult = {

new EmeEncryptionSchemePolyfillMediaKeySystemAccess(
capabilities.keySystemAccess, supportedScheme);
capabilities.keySystemAccess, videoScheme, audioScheme);
} else if (requestedConfiguration.keySystemConfiguration) {

@@ -446,2 +452,3 @@ // If the result is supported and the content is encrypted, we should have

contentType: decodingConfig.audio.contentType,
encryptionScheme: mediaCapKeySystemConfig.audio.encryptionScheme,
};

@@ -455,2 +462,3 @@ audioCapabilities.push(capability);

contentType: decodingConfig.video.contentType,
encryptionScheme: mediaCapKeySystemConfig.video.encryptionScheme,
};

@@ -496,5 +504,8 @@ videoCapabilities.push(capability);

* to wrap.
* @param {?string} scheme The encryption scheme to add to the configuration.
* @param {?string|undefined} videoScheme The encryption scheme to add to the
* configuration for video.
* @param {?string|undefined} audioScheme The encryption scheme to add to the
* configuration for audio.
*/
constructor(mksa, scheme) {
constructor(mksa, videoScheme, audioScheme) {
/**

@@ -510,4 +521,10 @@ * @const {!MediaKeySystemAccess}

*/
this.scheme_ = scheme;
this.videoScheme_ = videoScheme || null;
/**
* @const {?string}
* @private
*/
this.audioScheme_ = audioScheme || null;
/** @const {string} */

@@ -529,3 +546,3 @@ this.keySystem = mksa.keySystem;

for (const capability of configuration.videoCapabilities) {
capability['encryptionScheme'] = this.scheme_;
capability['encryptionScheme'] = this.videoScheme_;
}

@@ -536,3 +553,3 @@ }

for (const capability of configuration.audioCapabilities) {
capability['encryptionScheme'] = this.scheme_;
capability['encryptionScheme'] = this.audioScheme_;
}

@@ -612,3 +629,3 @@ }

/**
* @param {(string|undefined)} scheme Encryption scheme to check
* @param {(string|undefined|null)} scheme Encryption scheme to check
* @param {?string} supportedScheme A guess at the encryption scheme this

@@ -615,0 +632,0 @@ * supports.

{
"name": "eme-encryption-scheme-polyfill",
"description": "A polyfill for the encryptionScheme field in EME",
"version": "2.1.2",
"version": "2.1.3",
"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