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
3
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 1.0.0 to 1.0.1

CHANGELOG.md

8

dist/eme-encryption-scheme-polyfill.js
/*!
* @license
* EME Encryption Scheme Polyfill
* @license Apache-2.0
* Copyright 2019 Google LLC */
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
!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).EncryptionSchemePolyfill=e()}}(function(){var e={};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(){navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_)},e.guessSupportedScheme_=function(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-recommended":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)},e.probeRMKSA_=function(t,r){try{var n=this;return i(e.originalRMKSA_.call(n,t,r),function(i){var a=i.getConfiguration(),o=a.videoCapabilities&&a.videoCapabilities[0],s=a.audioCapabilities&&a.audioCapabilities[0];return void 0!==(o||s).encryptionScheme?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(n,t,r))})}catch(a){return Promise.reject(a)}},e.polyfillRMKSA_=function(t,n){try{var a=e.guessSupportedScheme_(t),o=[],s=n,l=Array.isArray(s),c=0;for(s=l?s:s[Symbol.iterator]();;){var u;if(l){if(c>=s.length)break;u=s[c++]}else{if((c=s.next()).done)break;u=c.value}var f=u,p=e.filterCapabilities_(f.videoCapabilities,a),d=e.filterCapabilities_(f.audioCapabilities,a);if(f.videoCapabilities&&f.videoCapabilities.length&&!p.length)return;if(f.audioCapabilities&&f.audioCapabilities.length&&!d.length)return;var y=Object.assign({},f);y.videoCapabilities=p,y.audioCapabilities=d,o.push(y)}if(!o.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,o),function(e){return new r(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}(),r=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),r=0;for(i=t?i:i[Symbol.iterator]();;){var n;if(t){if(r>=i.length)break;n=i[r++]}else{if((r=i.next()).done)break;n=r.value}n.encryptionScheme=this.scheme_}}if(e.audioCapabilities){var a=e.audioCapabilities,o=Array.isArray(a),s=0;for(a=o?a:a[Symbol.iterator]();;){var l;if(o){if(s>=a.length)break;l=a[s++]}else{if((s=a.next()).done)break;l=s.value}l.encryptionScheme=this.scheme_}}return e},i.createMediaKeys=function(){return this.mksa_.createMediaKeys()},e}();return t.originalRMKSA_,void 0!==e&&(e=t),e});
!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).EmeEncryptionSchemePolyfill=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(){navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration&&(e.originalRMKSA_=navigator.requestMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=e.probeRMKSA_)},e.guessSupportedScheme_=function(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-recommended":(console.warn("EmeEncryptionSchemePolyfill: Unknown key system:",e,"Please contribute!"),null)},e.probeRMKSA_=function(t,r){try{var n=this;return i(e.originalRMKSA_.call(n,t,r),function(i){var o=i.getConfiguration(),a=o.videoCapabilities&&o.videoCapabilities[0],s=o.audioCapabilities&&o.audioCapabilities[0];return void 0!==(a||s).encryptionScheme?(navigator.requestMediaKeySystemAccess=e.originalRMKSA_,i):(navigator.requestMediaKeySystemAccess=e.polyfillRMKSA_,e.polyfillRMKSA_.call(n,t,r))})}catch(o){return Promise.reject(o)}},e.polyfillRMKSA_=function(t,n){try{var o=e.guessSupportedScheme_(t),a=[],s=n,l=Array.isArray(s),c=0;for(s=l?s:s[Symbol.iterator]();;){var u;if(l){if(c>=s.length)break;u=s[c++]}else{if((c=s.next()).done)break;u=c.value}var f=u,p=e.filterCapabilities_(f.videoCapabilities,o),d=e.filterCapabilities_(f.audioCapabilities,o);if(f.videoCapabilities&&f.videoCapabilities.length&&!p.length);else if(f.audioCapabilities&&f.audioCapabilities.length&&!d.length);else{var y=Object.assign({},f);y.videoCapabilities=p,y.audioCapabilities=d,a.push(y)}}if(!a.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,a),function(e){return new r(e,o)})}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}(),r=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),r=0;for(i=t?i:i[Symbol.iterator]();;){var n;if(t){if(r>=i.length)break;n=i[r++]}else{if((r=i.next()).done)break;n=r.value}n.encryptionScheme=this.scheme_}}if(e.audioCapabilities){var o=e.audioCapabilities,a=Array.isArray(o),s=0;for(o=a?o:o[Symbol.iterator]();;){var l;if(a){if(s>=o.length)break;l=o[s++]}else{if((s=o.next()).done)break;l=s.value}l.encryptionScheme=this.scheme_}}return e},i.createMediaKeys=function(){return this.mksa_.createMediaKeys()},e}();return t.originalRMKSA_,e.exports&&(e.exports=t),e=e.exports});
/*!
* @license
* EME Encryption Scheme Polyfill
* @license Apache-2.0
* Copyright 2019 Google LLC */
// This special header is retained in minified bundle, and only adds ~100 bytes.
/**
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-License-Identifier: Apache-2.0
*/
// This special header is retained in minified bundle, and only adds ~120 bytes.

@@ -30,4 +16,4 @@ /**

*
* In source form, this is compatible with the Closure Compiler and the CommonJS
* module format. It can also be directly included via a script tag.
* In source form, this is compatible with the Closure Compiler, CommonJS, and
* AMD module formats. It can also be directly included via a script tag.
*

@@ -137,3 +123,3 @@ * The minified bundle is a standalone module compatible with the CommonJS and

// specified in the supportedConfigurations given by the application.
if (firstCapability.encryptionScheme !== undefined) {
if (firstCapability['encryptionScheme'] !== undefined) {
// The browser supports the encryptionScheme field!

@@ -204,5 +190,3 @@ // No need for a patch. Revert back to the original implementation.

// is unusable.
continue;
}
if (configuration.audioCapabilities &&
} else if (configuration.audioCapabilities &&
configuration.audioCapabilities.length &&

@@ -212,11 +196,11 @@ !filteredAudioCapabilities.length) {

// is unusable.
continue;
} else {
// Recreate a clone of the configuration and modify that. This way, we
// don't modify the application-provided config objects.
/** @type {!MediaKeySystemConfiguration} */
const clonedConfiguration = Object.assign({}, configuration);
clonedConfiguration.videoCapabilities = filteredVideoCapabilities;
clonedConfiguration.audioCapabilities = filteredAudioCapabilities;
filteredSupportedConfigurations.push(clonedConfiguration);
}
// Recreate a clone of the configuration and modify that. This way, we
// don't modify the application-provided config objects.
const clonedConfiguration = Object.assign({}, configuration);
clonedConfiguration.videoCapabilities = filteredVideoCapabilities;
clonedConfiguration.audioCapabilities = filteredAudioCapabilities;
filteredSupportedConfigurations.push(clonedConfiguration);
}

@@ -234,3 +218,3 @@

unsupportedError.name = 'NotSupportedError';
unsupportedError.code = DOMException.NOT_SUPPORTED_ERR;
unsupportedError['code'] = DOMException.NOT_SUPPORTED_ERR;
throw unsupportedError;

@@ -253,7 +237,7 @@ }

*
* @param {!Array.<MediaKeySystemMediaCapability>|undefined} capabilities
* @param {!Array.<!MediaKeySystemMediaCapability>|undefined} capabilities
* An array of capabilities, or null or undefined.
* @param {?string} supportedScheme The encryption scheme that we think is
* supported by the key system.
* @return {!Array.<MediaKeySystemMediaCapability>|undefined} A filtered
* @return {!Array.<!MediaKeySystemMediaCapability>|undefined} A filtered
* array of capabilities based on |supportedScheme|. May be undefined if

@@ -271,4 +255,4 @@ * the input was undefined.

// scheme we guessed for this UA.
return !capability.encryptionScheme ||
capability.encryptionScheme == supportedScheme;
return !capability['encryptionScheme'] ||
capability['encryptionScheme'] == supportedScheme;
});

@@ -318,3 +302,3 @@ }

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

@@ -325,3 +309,3 @@ }

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

@@ -352,9 +336,8 @@ }

// Support for CommonJS module format.
// Support for CommonJS and AMD module formats.
/** @suppress {undefinedVars} */
(() => {
if (typeof exports !== 'undefined') {
// eslint-disable-next-line no-undef
exports = EmeEncryptionSchemePolyfill;
if (typeof module !== 'undefined' && module.exports) {
module.exports = EmeEncryptionSchemePolyfill;
}
})();
{
"name": "eme-encryption-scheme-polyfill",
"description": "A polyfill for the encryptionScheme field in EME",
"version": "1.0.0",
"version": "1.0.1",
"license": "Apache-2.0",

@@ -19,4 +19,5 @@ "author": "Google",

"lint": "eslint index.js",
"build": "browserify index.js -s EncryptionSchemePolyfill -t babelify -t stripify -p tinyify -p browserify-header -o dist/eme-encryption-scheme-polyfill.js",
"prepublishOnly": "npm run-script lint && npm run-script build"
"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 EmeEncryptionSchemePolyfill -t babelify -t stripify -p tinyify -p browserify-header -o dist/eme-encryption-scheme-polyfill.js",
"prepublishOnly": "npm run-script lint && npm run-script closure-compiler-check && npm run-script build"
},

@@ -33,2 +34,3 @@ "devDependencies": {

"eslint-plugin-jsdoc": "^18.0.1",
"google-closure-compiler": "latest",
"stripify": "^6.0.0",

@@ -35,0 +37,0 @@ "tinyify": "^2.5.2"

@@ -5,4 +5,5 @@ # EME Encryption Scheme Polyfill

https://wicg.github.io/encrypted-media-encryption-scheme/
https://github.com/WICG/encrypted-media-encryption-scheme/issues/13
- https://wicg.github.io/encrypted-media-encryption-scheme/
- https://google.github.io/eme-encryption-scheme-polyfill/demo/
- https://github.com/WICG/encrypted-media-encryption-scheme/issues/13

@@ -9,0 +10,0 @@ Because this polyfill can't know what schemes the UA or CDM actually support,

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