From a4dbf39c4aa4df580c8e9e6eb64cdab93cebc6e7 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 17 Aug 2017 18:11:46 +0200 Subject: [PATCH] fix pdf display problems in chrome --- www/common/media-tag.js | 2 +- www/common/pdfjs/web/viewer.js | 4 ++-- www/file/main.js | 26 ++++++++++++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/www/common/media-tag.js b/www/common/media-tag.js index cad996916..042cb5200 100644 --- a/www/common/media-tag.js +++ b/www/common/media-tag.js @@ -1 +1 @@ -(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define([],factory);else if(typeof exports==="object")exports["MediaTag"]=factory();else root["MediaTag"]=factory()})(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId]){return installedModules[moduleId].exports}var module=installedModules[moduleId]={i:moduleId,l:false,exports:{}};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.l=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.d=function(exports,name,getter){if(!__webpack_require__.o(exports,name)){Object.defineProperty(exports,name,{configurable:false,enumerable:true,get:getter})}};__webpack_require__.n=function(module){var getter=module&&module.__esModule?function getDefault(){return module["default"]}:function getModuleExports(){return module};__webpack_require__.d(getter,"a",getter);return getter};__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)};__webpack_require__.p="";return __webpack_require__(__webpack_require__.s=63)}([function(module,exports,__webpack_require__){"use strict";var Identifier={IMAGE:"image",AUDIO:"audio",VIDEO:"video",PDF:"pdf",DASH:"dash",DOWNLOAD:"download",CRYPTO:"crypto",CLEAR_KEY:"clear-key",MEDIA_OBJECT:"media-object"};module.exports=Identifier},function(module,exports,__webpack_require__){"use strict";var Type={MATCHER:"matcher",RENDERER:"renderer",FILTER:"filter",SANITIZER:"sanitizer"};module.exports=Type},function(module,exports,__webpack_require__){"use strict";var ProcessingEngine=__webpack_require__(31);var MatchingEngine=__webpack_require__(33);var PluginStore=__webpack_require__(34);var UriStore=__webpack_require__(35);var MediaTag=__webpack_require__(36);function MediaTagAPI(elements){if(elements instanceof Array){var mediaObjects=[];elements.forEach(function(element){if(element.mediaObject){mediaObjects.push(element.mediaObject)}else{var _mediaTag=new MediaTag(element,MediaTagAPI.processingEngine);_mediaTag.mediaObjects.forEach(function(mediaObject){mediaObjects.push(MediaTagAPI.processingEngine.start(mediaObject))})}});return mediaObjects}var element=elements;var mediaTag=new MediaTag(element,MediaTagAPI.processingEngine);mediaTag.mediaObjects.forEach(function(mediaObject){MediaTagAPI.processingEngine.start(mediaObject)})}MediaTagAPI.pluginStore=MediaTagAPI.pluginStore||new PluginStore;MediaTagAPI.uriStore=MediaTagAPI.uriStore||new UriStore("../plugins");MediaTagAPI.processingEngine=MediaTagAPI.processingEngine||new ProcessingEngine(MediaTagAPI.pluginStore);MediaTagAPI.matchingEngine=MediaTagAPI.matchingEngine||new MatchingEngine(MediaTagAPI.pluginStore,MediaTagAPI.uriStore);MediaTagAPI.loadingEngine=null;module.exports=MediaTagAPI},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i=0){CryptoFilter.mediaTypes.splice(index,1)}};CryptoFilter.removeAllAllowedMediaTypes=function(mediaTypes){mediaTypes.forEach(function(mediaType){CryptoFilter.removeAllowedMediaType(mediaType)})};CryptoFilter.isAllowedMediaType=function(mediaType){return CryptoFilter.mediaTypes.some(function(type){return type===mediaType})};module.exports=CryptoFilter},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i0}}]);return AttributesObject}();module.exports=AttributesObject},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var Errors={PluginExists:function(_Error){_inherits(PluginExists,_Error);function PluginExists(objPlugin){_classCallCheck(this,PluginExists);return _possibleConstructorReturn(this,(PluginExists.__proto__||Object.getPrototypeOf(PluginExists)).call(this,'Plugin with same "'+objPlugin.identifier+'" identifier found.'))}return PluginExists}(Error),TypeNotFound:function(_Error2){_inherits(TypeNotFound,_Error2);function TypeNotFound(){_classCallCheck(this,TypeNotFound);return _possibleConstructorReturn(this,(TypeNotFound.__proto__||Object.getPrototypeOf(TypeNotFound)).call(this,"Media Tag could not find the content type of an instance.}."))}return TypeNotFound}(Error),FilterExists:function(_Error3){_inherits(FilterExists,_Error3);function FilterExists(filter){_classCallCheck(this,FilterExists);return _possibleConstructorReturn(this,(FilterExists.__proto__||Object.getPrototypeOf(FilterExists)).call(this,'Filter with same "'+filter.identifier+' identifier found."'))}return FilterExists}(Error),FetchFail:function(_Error4){_inherits(FetchFail,_Error4);function FetchFail(response){_classCallCheck(this,FetchFail);return _possibleConstructorReturn(this,(FetchFail.__proto__||Object.getPrototypeOf(FetchFail)).call(this,'Could not fetch "'+response.url+'", received "'+response.status+": "+response.statusText+'".'))}return FetchFail}(Error),InvalidCryptoKey:function(_Error5){_inherits(InvalidCryptoKey,_Error5);function InvalidCryptoKey(){_classCallCheck(this,InvalidCryptoKey);return _possibleConstructorReturn(this,(InvalidCryptoKey.__proto__||Object.getPrototypeOf(InvalidCryptoKey)).call(this,"Invalid cryptographic key."))}return InvalidCryptoKey}(Error),InvalidCryptoLib:function(_Error6){_inherits(InvalidCryptoLib,_Error6);function InvalidCryptoLib(){_classCallCheck(this,InvalidCryptoLib);return _possibleConstructorReturn(this,(InvalidCryptoLib.__proto__||Object.getPrototypeOf(InvalidCryptoLib)).call(this,"Invalid cryptographic algorithm name."))}return InvalidCryptoLib}(Error),FailedCrypto:function(_Error7){_inherits(FailedCrypto,_Error7);function FailedCrypto(err){_classCallCheck(this,FailedCrypto);return _possibleConstructorReturn(this,(FailedCrypto.__proto__||Object.getPrototypeOf(FailedCrypto)).call(this,"Failed to decrypt file"+(err&&err.message?" "+err.message:"")+"."))}return FailedCrypto}(Error)};module.exports=Errors},function(module,exports,__webpack_require__){"use strict";var MediaTag=__webpack_require__(21);var ImagePlugin=__webpack_require__(43);var AudioPlugin=__webpack_require__(44);var VideoPlugin=__webpack_require__(45);var PdfPlugin=__webpack_require__(46);var DashPlugin=__webpack_require__(47);var DownloadPlugin=__webpack_require__(48);var CryptoFilter=__webpack_require__(7);var ClearKeyFilter=__webpack_require__(49);var MediaObjectSanitizer=__webpack_require__(50);MediaTag.pluginStore.store(new ImagePlugin);MediaTag.pluginStore.store(new AudioPlugin);MediaTag.pluginStore.store(new VideoPlugin);MediaTag.pluginStore.store(new PdfPlugin);MediaTag.pluginStore.store(new DashPlugin);MediaTag.pluginStore.store(new DownloadPlugin);MediaTag.pluginStore.store(new CryptoFilter);MediaTag.pluginStore.store(new ClearKeyFilter);MediaTag.pluginStore.store(new MediaObjectSanitizer);var Salsa20Poly1305Algorithm=__webpack_require__(51);var CryptpadAlgorithm=__webpack_require__(52);CryptoFilter.functionStore.store("salsa20poly1305",Salsa20Poly1305Algorithm);CryptoFilter.functionStore.store("cryptpad",CryptpadAlgorithm);var defaultPlugin=new DownloadPlugin("

MediaTag cannot find a plugin able to renderer your content

","Download");MediaTag.processingEngine.setDefaultPlugin(defaultPlugin);MediaTag.CryptoFilter=CryptoFilter;var allowedMediaTypes=["image/png","image/jpeg","image/jpg","image/gif","audio/mp3","audio/ogg","audio/wav","audio/webm","video/mp4","video/ogg","video/webm","application/pdf","application/dash+xml","download"];MediaTag.CryptoFilter.setAllowedMediaTypes(allowedMediaTypes);var Configuration=__webpack_require__(53);var Permission=__webpack_require__(14);var Identifier=__webpack_require__(0);var configuration=new Configuration;MediaTag.PdfPlugin=PdfPlugin;MediaTag.PdfPlugin.viewer="/pdfjs/web/viewer.html";MediaTag.processingEngine.configure(configuration);module.exports=MediaTag},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var Type=__webpack_require__(1);var Occurrence=__webpack_require__(5);var Plugin=__webpack_require__(6);var Sanitizer=function(_Plugin){_inherits(Sanitizer,_Plugin);function Sanitizer(identifier){_classCallCheck(this,Sanitizer);return _possibleConstructorReturn(this,(Sanitizer.__proto__||Object.getPrototypeOf(Sanitizer)).call(this,identifier,Type.SANITIZER,Occurrence.EVERY))}return Sanitizer}(Plugin);module.exports=Sanitizer},function(module,exports,__webpack_require__){"use strict";var ImageMatcher=__webpack_require__(22);var AudioMatcher=__webpack_require__(23);var VideoMatcher=__webpack_require__(24);var PdfMatcher=__webpack_require__(25);var DashMatcher=__webpack_require__(26);var DownloadMatcher=__webpack_require__(27);var CryptoMatcher=__webpack_require__(28);var ClearKeyMatcher=__webpack_require__(29);var MediaObjectMatcher=__webpack_require__(30);var MediaTag=__webpack_require__(2);MediaTag.pluginStore.store(new ImageMatcher);MediaTag.pluginStore.store(new AudioMatcher);MediaTag.pluginStore.store(new VideoMatcher);MediaTag.pluginStore.store(new PdfMatcher);MediaTag.pluginStore.store(new DashMatcher);MediaTag.pluginStore.store(new DownloadMatcher);MediaTag.pluginStore.store(new CryptoMatcher);MediaTag.pluginStore.store(new ClearKeyMatcher);MediaTag.pluginStore.store(new MediaObjectMatcher);module.exports=MediaTag},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i=ProcessingEngine.STACK_LIMIT){console.error(this.snapshots[stackId]);throw new Error("Plugin stack size exceed")}if(this.snapshots[stackId].length>=ProcessingEngine.SNAPSHOT_LIMIT){console.error(this.snapshots[stackId]);throw new Error("Plugin snapshots size exceed")}var rendererCount=0;this.stacks[stackId].forEach(function(plugin){if(plugin.type===Type.RENDERER){rendererCount++}});if(rendererCount>1){console.error(this.snapshots[stackId]);throw new Error("More of one renderer in the stack")}if(this.stacks[stackId].length===0&&!this.stats[stackId][Type.RENDERER]){if(!this.defaultPlugin){throw new Error("No default plugin assignated")}this.stacks[stackId].unshift(this.defaultPlugin)}}},{key:"return",value:function _return(mediaObject){var stackId=mediaObject.getId();var plugin=this.unstack(mediaObject);if(!plugin){return}try{if(!this.stats[stackId]){this.stats[stackId]={}}if(this.stats[stackId][plugin.type]){this.stats[stackId][plugin.type]+=1}else{this.stats[stackId][plugin.type]=1}}catch(err){console.error(err,this.snapshots[stackId])}if(this.stacks[stackId].length===0&&plugin.type===Type.RENDERER){this.run(mediaObject)}else if(plugin.type!==Type.SANITIZER){this.fill(mediaObject)}this.snapshot(mediaObject);this.check(mediaObject);this.run(mediaObject)}},{key:"process",value:function process(mediaObject){var stackId=mediaObject.getId();var size=this.stacks[stackId].length;var plugin=this.stacks[stackId][size-1];if(plugin){plugin.process(mediaObject)}else{console.log(this.stacks);throw new Error("Impossible to run a undefined plugin")}}},{key:"isStacked",value:function isStacked(mediaObject,plugin){var stackId=mediaObject.getId();if(this.stacks[stackId]){if(this.stacks[stackId].includes(plugin)){return true}}return false}},{key:"setDefaultPlugin",value:function setDefaultPlugin(plugin){this.defaultPlugin=plugin}}]);return ProcessingEngine}();ProcessingEngine.STACK_LIMIT=100;ProcessingEngine.SNAPSHOT_LIMIT=100;module.exports=ProcessingEngine},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){activate(mediaTag.mediaObjects[index-1],mediaTag)}}},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i1){return array[0]}return window.location.protocol}},{key:"hostname",value:function hostname(AttributeObject){var array=AttributeObject.getAttribute("src").split("://");if(array.length>1){return array[1].split("/")[0]}return window.location.hostname}},{key:"source",value:function source(AttributeObject){var source=AttributeObject.getAttribute("src");return source}},{key:"schemes",value:function schemes(AttributeObject){return/\w+:/.exec(AttributeObject.getAttribute("src"))}},{key:"sources",value:function sources(AttributeObject){var sources=AttributeObject.getAttribute("sources")||AttributeObject.getAttribute("srcs");if(sources){return JSON.parse(sources)}return null}},{key:"actions",value:function actions(AttributeObject){var actions=AttributeObject.getAttribute("actions");if(actions){return JSON.parse(actions)}return null}},{key:"parse",value:function parse(AttributeObject){return{protocol:Parser.protocol(AttributeObject),hostname:Parser.hostname(AttributeObject),src:Parser.source(AttributeObject),type:Parser.type(AttributeObject),extension:Parser.extension(AttributeObject),mime:Parser.mime(AttributeObject),sources:Parser.sources(AttributeObject),actions:Parser.actions(AttributeObject)}}}]);return Parser}();module.exports=Parser},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i1){if(PARANOIA){if(typeof N[l]!=="number"){throw new Error("E_UNSAFE_TYPE")}if(N[l]>255){throw new Error("E_OUT_OF_BOUNDS")}}if(N[l]!==255){return void N[l]++}N[l]=0;if(l===0){throw new Error("E_NONCE_TOO_LARGE")}}}},{key:"encodePrefix",value:function encodePrefix(p){return[65280,255].map(function(n,i){return(p&n)>>(1-i)*8})}},{key:"decodePrefix",value:function decodePrefix(A){return A[0]<<8|A[1]}},{key:"joinChunks",value:function joinChunks(chunks){return new Blob(chunks)}},{key:"slice",value:function slice(u8){return Array.prototype.slice.call(u8)}},{key:"getRandomKeyStr",value:function getRandomKeyStr(){var Nacl=window.nacl;var rdm=Nacl.randomBytes(18);return Nacl.util.encodeBase64(rdm)}},{key:"getKeyFromStr",value:function getKeyFromStr(str){return window.nacl.util.decodeBase64(str)}},{key:"encrypt",value:function encrypt(){}},{key:"decrypt",value:function decrypt(u8,key,done){var Nacl=window.nacl;var progress=function progress(offset){var ev=new Event("decryptionProgress");ev.percent=offset/u8.length*100;window.document.dispatchEvent(ev)};var nonce=Cryptopad.createNonce();var i=0;var prefix=u8.subarray(0,2);var metadataLength=Cryptopad.decodePrefix(prefix);var res={metadata:undefined};var metaBox=new Uint8Array(u8.subarray(2,2+metadataLength));var metaChunk=Nacl.secretbox.open(metaBox,nonce,key);Cryptopad.increment(nonce);try{res.metadata=JSON.parse(Nacl.util.encodeUTF8(metaChunk))}catch(e){return done("E_METADATA_DECRYPTION")}if(!res.metadata){return done("NO_METADATA")}var takeChunk=function takeChunk(cb){setTimeout(function(){var start=i*cypherChunkLength+2+metadataLength;var end=start+cypherChunkLength;i++;var box=new Uint8Array(u8.subarray(start,end));var plaintext=Nacl.secretbox.open(box,nonce,key);Cryptopad.increment(nonce);if(!plaintext){return void cb("DECRYPTION_FAILURE")}progress(Math.min(end,u8.length));cb(void 0,plaintext)})};var chunks=[];var again=function again(){takeChunk(function(e,plaintext){if(e){return setTimeout(function(){done(e)})}if(plaintext){if(i*cypherChunkLength=0){CryptoFilter.mediaTypes.splice(index,1)}};CryptoFilter.removeAllAllowedMediaTypes=function(mediaTypes){mediaTypes.forEach(function(mediaType){CryptoFilter.removeAllowedMediaType(mediaType)})};CryptoFilter.isAllowedMediaType=function(mediaType){return CryptoFilter.mediaTypes.some(function(type){return type===mediaType})};module.exports=CryptoFilter},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i0}}]);return AttributesObject}();module.exports=AttributesObject},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var Errors={PluginExists:function(_Error){_inherits(PluginExists,_Error);function PluginExists(objPlugin){_classCallCheck(this,PluginExists);return _possibleConstructorReturn(this,(PluginExists.__proto__||Object.getPrototypeOf(PluginExists)).call(this,'Plugin with same "'+objPlugin.identifier+'" identifier found.'))}return PluginExists}(Error),TypeNotFound:function(_Error2){_inherits(TypeNotFound,_Error2);function TypeNotFound(){_classCallCheck(this,TypeNotFound);return _possibleConstructorReturn(this,(TypeNotFound.__proto__||Object.getPrototypeOf(TypeNotFound)).call(this,"Media Tag could not find the content type of an instance.}."))}return TypeNotFound}(Error),FilterExists:function(_Error3){_inherits(FilterExists,_Error3);function FilterExists(filter){_classCallCheck(this,FilterExists);return _possibleConstructorReturn(this,(FilterExists.__proto__||Object.getPrototypeOf(FilterExists)).call(this,'Filter with same "'+filter.identifier+' identifier found."'))}return FilterExists}(Error),FetchFail:function(_Error4){_inherits(FetchFail,_Error4);function FetchFail(response){_classCallCheck(this,FetchFail);return _possibleConstructorReturn(this,(FetchFail.__proto__||Object.getPrototypeOf(FetchFail)).call(this,'Could not fetch "'+response.url+'", received "'+response.status+": "+response.statusText+'".'))}return FetchFail}(Error),InvalidCryptoKey:function(_Error5){_inherits(InvalidCryptoKey,_Error5);function InvalidCryptoKey(){_classCallCheck(this,InvalidCryptoKey);return _possibleConstructorReturn(this,(InvalidCryptoKey.__proto__||Object.getPrototypeOf(InvalidCryptoKey)).call(this,"Invalid cryptographic key."))}return InvalidCryptoKey}(Error),InvalidCryptoLib:function(_Error6){_inherits(InvalidCryptoLib,_Error6);function InvalidCryptoLib(){_classCallCheck(this,InvalidCryptoLib);return _possibleConstructorReturn(this,(InvalidCryptoLib.__proto__||Object.getPrototypeOf(InvalidCryptoLib)).call(this,"Invalid cryptographic algorithm name."))}return InvalidCryptoLib}(Error),FailedCrypto:function(_Error7){_inherits(FailedCrypto,_Error7);function FailedCrypto(err){_classCallCheck(this,FailedCrypto);return _possibleConstructorReturn(this,(FailedCrypto.__proto__||Object.getPrototypeOf(FailedCrypto)).call(this,"Failed to decrypt file"+(err&&err.message?" "+err.message:"")+"."))}return FailedCrypto}(Error)};module.exports=Errors},function(module,exports,__webpack_require__){"use strict";var MediaTag=__webpack_require__(21);var ImagePlugin=__webpack_require__(43);var AudioPlugin=__webpack_require__(44);var VideoPlugin=__webpack_require__(45);var PdfPlugin=__webpack_require__(46);var DashPlugin=__webpack_require__(47);var DownloadPlugin=__webpack_require__(48);var CryptoFilter=__webpack_require__(7);var ClearKeyFilter=__webpack_require__(49);var MediaObjectSanitizer=__webpack_require__(50);MediaTag.pluginStore.store(new ImagePlugin);MediaTag.pluginStore.store(new AudioPlugin);MediaTag.pluginStore.store(new VideoPlugin);MediaTag.pluginStore.store(new PdfPlugin);MediaTag.pluginStore.store(new DashPlugin);MediaTag.pluginStore.store(new DownloadPlugin);MediaTag.pluginStore.store(new CryptoFilter);MediaTag.pluginStore.store(new ClearKeyFilter);MediaTag.pluginStore.store(new MediaObjectSanitizer);var Salsa20Poly1305Algorithm=__webpack_require__(51);var CryptpadAlgorithm=__webpack_require__(52);CryptoFilter.functionStore.store("salsa20poly1305",Salsa20Poly1305Algorithm);CryptoFilter.functionStore.store("cryptpad",CryptpadAlgorithm);var defaultPlugin=new DownloadPlugin("

MediaTag cannot find a plugin able to renderer your content

","Download");MediaTag.processingEngine.setDefaultPlugin(defaultPlugin);MediaTag.CryptoFilter=CryptoFilter;var allowedMediaTypes=["image/png","image/jpeg","image/jpg","image/gif","audio/mp3","audio/ogg","audio/wav","audio/webm","video/mp4","video/ogg","video/webm","application/pdf","application/dash+xml","download"];MediaTag.CryptoFilter.setAllowedMediaTypes(allowedMediaTypes);var Configuration=__webpack_require__(53);var Permission=__webpack_require__(14);var Identifier=__webpack_require__(0);var configuration=new Configuration;MediaTag.PdfPlugin=PdfPlugin;MediaTag.PdfPlugin.viewer="/pdfjs/web/viewer.html";MediaTag.processingEngine.configure(configuration);module.exports=MediaTag},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var Type=__webpack_require__(1);var Occurrence=__webpack_require__(5);var Plugin=__webpack_require__(6);var Sanitizer=function(_Plugin){_inherits(Sanitizer,_Plugin);function Sanitizer(identifier){_classCallCheck(this,Sanitizer);return _possibleConstructorReturn(this,(Sanitizer.__proto__||Object.getPrototypeOf(Sanitizer)).call(this,identifier,Type.SANITIZER,Occurrence.EVERY))}return Sanitizer}(Plugin);module.exports=Sanitizer},function(module,exports,__webpack_require__){"use strict";var ImageMatcher=__webpack_require__(22);var AudioMatcher=__webpack_require__(23);var VideoMatcher=__webpack_require__(24);var PdfMatcher=__webpack_require__(25);var DashMatcher=__webpack_require__(26);var DownloadMatcher=__webpack_require__(27);var CryptoMatcher=__webpack_require__(28);var ClearKeyMatcher=__webpack_require__(29);var MediaObjectMatcher=__webpack_require__(30);var MediaTag=__webpack_require__(2);MediaTag.pluginStore.store(new ImageMatcher);MediaTag.pluginStore.store(new AudioMatcher);MediaTag.pluginStore.store(new VideoMatcher);MediaTag.pluginStore.store(new PdfMatcher);MediaTag.pluginStore.store(new DashMatcher);MediaTag.pluginStore.store(new DownloadMatcher);MediaTag.pluginStore.store(new CryptoMatcher);MediaTag.pluginStore.store(new ClearKeyMatcher);MediaTag.pluginStore.store(new MediaObjectMatcher);module.exports=MediaTag},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i=ProcessingEngine.STACK_LIMIT){console.error(this.snapshots[stackId]);throw new Error("Plugin stack size exceed")}if(this.snapshots[stackId].length>=ProcessingEngine.SNAPSHOT_LIMIT){console.error(this.snapshots[stackId]);throw new Error("Plugin snapshots size exceed")}var rendererCount=0;this.stacks[stackId].forEach(function(plugin){if(plugin.type===Type.RENDERER){rendererCount++}});if(rendererCount>1){console.error(this.snapshots[stackId]);throw new Error("More of one renderer in the stack")}if(this.stacks[stackId].length===0&&!this.stats[stackId][Type.RENDERER]){if(!this.defaultPlugin){throw new Error("No default plugin assignated")}this.stacks[stackId].unshift(this.defaultPlugin)}}},{key:"return",value:function _return(mediaObject){var stackId=mediaObject.getId();var plugin=this.unstack(mediaObject);if(!plugin){return}try{if(!this.stats[stackId]){this.stats[stackId]={}}if(this.stats[stackId][plugin.type]){this.stats[stackId][plugin.type]+=1}else{this.stats[stackId][plugin.type]=1}}catch(err){console.error(err,this.snapshots[stackId])}if(this.stacks[stackId].length===0&&plugin.type===Type.RENDERER){this.run(mediaObject)}else if(plugin.type!==Type.SANITIZER){this.fill(mediaObject)}this.snapshot(mediaObject);this.check(mediaObject);this.run(mediaObject)}},{key:"process",value:function process(mediaObject){var stackId=mediaObject.getId();var size=this.stacks[stackId].length;var plugin=this.stacks[stackId][size-1];if(plugin){plugin.process(mediaObject)}else{console.log(this.stacks);throw new Error("Impossible to run a undefined plugin")}}},{key:"isStacked",value:function isStacked(mediaObject,plugin){var stackId=mediaObject.getId();if(this.stacks[stackId]){if(this.stacks[stackId].includes(plugin)){return true}}return false}},{key:"setDefaultPlugin",value:function setDefaultPlugin(plugin){this.defaultPlugin=plugin}}]);return ProcessingEngine}();ProcessingEngine.STACK_LIMIT=100;ProcessingEngine.SNAPSHOT_LIMIT=100;module.exports=ProcessingEngine},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){activate(mediaTag.mediaObjects[index-1],mediaTag)}}},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i1){return array[0]}return window.location.protocol}},{key:"hostname",value:function hostname(AttributeObject){var array=AttributeObject.getAttribute("src").split("://");if(array.length>1){return array[1].split("/")[0]}return window.location.hostname}},{key:"source",value:function source(AttributeObject){var source=AttributeObject.getAttribute("src");return source}},{key:"schemes",value:function schemes(AttributeObject){return/\w+:/.exec(AttributeObject.getAttribute("src"))}},{key:"sources",value:function sources(AttributeObject){var sources=AttributeObject.getAttribute("sources")||AttributeObject.getAttribute("srcs");if(sources){return JSON.parse(sources)}return null}},{key:"actions",value:function actions(AttributeObject){var actions=AttributeObject.getAttribute("actions");if(actions){return JSON.parse(actions)}return null}},{key:"parse",value:function parse(AttributeObject){return{protocol:Parser.protocol(AttributeObject),hostname:Parser.hostname(AttributeObject),src:Parser.source(AttributeObject),type:Parser.type(AttributeObject),extension:Parser.extension(AttributeObject),mime:Parser.mime(AttributeObject),sources:Parser.sources(AttributeObject),actions:Parser.actions(AttributeObject)}}}]);return Parser}();module.exports=Parser},function(module,exports,__webpack_require__){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i1){if(PARANOIA){if(typeof N[l]!=="number"){throw new Error("E_UNSAFE_TYPE")}if(N[l]>255){throw new Error("E_OUT_OF_BOUNDS")}}if(N[l]!==255){return void N[l]++}N[l]=0;if(l===0){throw new Error("E_NONCE_TOO_LARGE")}}}},{key:"encodePrefix",value:function encodePrefix(p){return[65280,255].map(function(n,i){return(p&n)>>(1-i)*8})}},{key:"decodePrefix",value:function decodePrefix(A){return A[0]<<8|A[1]}},{key:"joinChunks",value:function joinChunks(chunks){return new Blob(chunks)}},{key:"slice",value:function slice(u8){return Array.prototype.slice.call(u8)}},{key:"getRandomKeyStr",value:function getRandomKeyStr(){var Nacl=window.nacl;var rdm=Nacl.randomBytes(18);return Nacl.util.encodeBase64(rdm)}},{key:"getKeyFromStr",value:function getKeyFromStr(str){return window.nacl.util.decodeBase64(str)}},{key:"encrypt",value:function encrypt(){}},{key:"decrypt",value:function decrypt(u8,key,done){var Nacl=window.nacl;var progress=function progress(offset){var ev=new Event("decryptionProgress");ev.percent=offset/u8.length*100;window.document.dispatchEvent(ev)};var nonce=Cryptopad.createNonce();var i=0;var prefix=u8.subarray(0,2);var metadataLength=Cryptopad.decodePrefix(prefix);var res={metadata:undefined};var metaBox=new Uint8Array(u8.subarray(2,2+metadataLength));var metaChunk=Nacl.secretbox.open(metaBox,nonce,key);Cryptopad.increment(nonce);try{res.metadata=JSON.parse(Nacl.util.encodeUTF8(metaChunk))}catch(e){return done("E_METADATA_DECRYPTION")}if(!res.metadata){return done("NO_METADATA")}var takeChunk=function takeChunk(cb){setTimeout(function(){var start=i*cypherChunkLength+2+metadataLength;var end=start+cypherChunkLength;i++;var box=new Uint8Array(u8.subarray(start,end));var plaintext=Nacl.secretbox.open(box,nonce,key);Cryptopad.increment(nonce);if(!plaintext){return void cb("DECRYPTION_FAILURE")}progress(Math.min(end,u8.length));cb(void 0,plaintext)})};var chunks=[];var again=function again(){takeChunk(function(e,plaintext){if(e){return setTimeout(function(){done(e)})}if(plaintext){if(i*cypherChunkLength