diff --git a/www/common/media-tag.js b/www/common/media-tag.js index d2459d7ba..ad8600274 100644 --- a/www/common/media-tag.js +++ b/www/common/media-tag.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mediaTag=t():e.mediaTag=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=68)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1?{modules:t}:null}},{key:"findModuleChain",value:function(t){var n=e.findRequiredModuleIdentifiers(t),r=n.map(function(e){var t=u.getFilter(e)||a.getPlugin(e);if(t)return t;throw new Error("Module "+e+" not found")}),i=e.searchLogicCollision(r);if(i){var o=i.modules.map(function(e){return e.identifier});throw new Error("Has collision between ["+o+"]'s logics")}return r}},{key:"startup",value:function(t){if(o.hasLogics()===!1)return void console.warn("Guidelines havn't logics ... The orchestrator cannot do anything !");var n=t.getId();e.chains[n]=e.findModuleChain(t),e.history[n]={identifiers:[e.findRequiredModuleIdentifiers(t)],cycles:{}},e.chains[n].length>0&&e.run(t)}},{key:"coherence",value:function(t){var n=t.getId(),r=e.history[n].identifiers.length-1;if(Object.keys(e.history[n].cycles).some(function(t){return e.history[n].cycles[t]>e.allowedCycles}))throw console.log(e.history[n]),new Error("Maximum cycles exceed "+e.history[n].cycles);var i=e.history[n].identifiers[r-1].every(function(t){return e.history[n].identifiers[r].includes(t)})||e.history[n].identifiers[r-1][0]===e.history[n].identifiers[r][0],o=e.history[n].identifiers[r][0];i&&(console.info('Chain has not evolved since the last module execution, the module "%s" is skipped',o),e.chains[n].shift())}},{key:"run",value:function(t){var n=t.getId();e.chains[n][0]?e.chains[n][0].startup(t):console.warn("Attempts to run a empty chain ...","History : ",e.history[n])}},{key:"chain",value:function(t){e.update(t),e.coherence(t),e.run(t)}},{key:"update",value:function(t){var n=t.getId(),r=e.chains[n].shift();e.findModuleChain(t).filter(function(t){return!e.chains[n].includes(t)}).forEach(function(t){e.chains[n].unshift(t)});var i=e.history[n].cycles[r.identifier];e.history[n].cycles[r.identifier]="number"==typeof i?i+1:1;var o=e.chains[n].map(function(e){return e.identifier});e.history[n].identifiers.push(o)}}]),e}();c.chains={},c.history={},c.allowedCycles=1,c.forbiddenIdentifiers=[],c.printHistory=function(){var e=String();Object.keys(c.history).forEach(function(t){var n=c.history[t];e+="Cycle["+t+"]: \n",Object.keys(n.cycles).forEach(function(t){e+=t+": "+n.cycles[t]+"\n"}),e+="Identifiers["+t+"]: \n",n.identifiers.forEach(function(t){e+="[",t.forEach(function(t){e+=t+", "}),e+="]",e=e.replace(", ]","]\n")})}),console.log(e)},e.exports=c},,,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n0}}]),e}();o.logicsMap={},e.exports=o},function(e,t,n){"use strict";var r=n(11),i=n(27);r.registerPlugin(i);var o=n(29);r.registerPlugin(o);var u=n(25);r.registerPlugin(u);var a=n(26);r.registerPlugin(a);var c=n(28);r.registerPlugin(c);var s=n(15);r.registerFilter(s);var l=n(14);r.registerFilter(l);var f=n(13);r.registerFilter(f);n(16);e.exports=r},,,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u={PluginExists:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,'Plugin with same "'+e.identifier+'" identifier found.'))}return o(t,e),t}(Error),TypeNotFound:function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Media Tag could not find the content type of an instance.}."))}return o(t,e),t}(Error),FilterExists:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,'Filter with same "'+e.identifier+' identifier found."'))}return o(t,e),t}(Error),FetchFail:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,'Could not fetch "'+e.url+'", received "'+e.status+": "+e.statusText+'".'))}return o(t,e),t}(Error),InvalidCryptoKey:function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Invalid cryptographic key."))}return o(t,e),t}(Error),InvalidCryptoLib:function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Invalid cryptographic algorithm name."))}return o(t,e),t}(Error),FailedCrypto:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Failed to decrypt file"+(e&&e.message?" "+e.message:"")+"."))}return o(t,e),t}(Error)};e.exports=u},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1?t[0]:window.location.protocol}},{key:"hostname",value:function(e){var t=e.getAttribute("src").split("://");return t.length>1?t[1].split("/")[0]:window.location.hostname}},{key:"source",value:function(e){return e.getAttribute("src")}},{key:"parse",value:function(t){return{protocol:e.protocol(t),hostname:e.hostname(t),src:e.source(t),type:e.type(t),extension:e.extension(t),mime:e.mime(t)}}}]),e}();e.exports=o},function(e,t,n){"use strict";var r=n(0),i={identifier:"clear-key",startup:function(e){var t=e.getAttribute("data-clear-key"),n=t.substring(0,32),i=t.substring(33,65);e.setAttribute("id",n),e.setAttribute("key",i),e.removeAttribute("data-clear-key"),r.chain(e)}};e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1?{modules:t}:null}},{key:"findModuleChain",value:function(t){var n=e.findRequiredModuleIdentifiers(t),r=n.map(function(e){var t=u.getFilter(e)||a.getPlugin(e);if(t)return t;throw new Error("Module "+e+" not found")}),i=e.searchLogicCollision(r);if(i){var o=i.modules.map(function(e){return e.identifier});throw new Error("Has collision between ["+o+"]'s logics")}return r}},{key:"startup",value:function(t){if(o.hasLogics()===!1)return void console.warn("Guidelines havn't logics ... The orchestrator cannot do anything !");var n=t.getId();e.chains[n]=e.findModuleChain(t),e.history[n]={identifiers:[e.findRequiredModuleIdentifiers(t)],cycles:{}},e.chains[n].length>0&&e.run(t)}},{key:"coherence",value:function(t){var n=t.getId(),r=e.history[n].identifiers.length-1;if(Object.keys(e.history[n].cycles).some(function(t){return e.history[n].cycles[t]>e.allowedCycles}))throw console.log(e.history[n]),new Error("Maximum cycles exceed "+e.history[n].cycles);var i=e.history[n].identifiers[r-1].every(function(t){return e.history[n].identifiers[r].includes(t)})||e.history[n].identifiers[r-1][0]===e.history[n].identifiers[r][0],o=e.history[n].identifiers[r][0];i&&(console.info('Chain has not evolved since the last module execution, the module "%s" is skipped',o),e.chains[n].shift())}},{key:"run",value:function(t){var n=t.getId();e.chains[n][0]?e.chains[n][0].startup(t):console.warn("Attempts to run a empty chain ...","History : ",e.history[n])}},{key:"chain",value:function(t){e.update(t),e.coherence(t),e.run(t)}},{key:"update",value:function(t){var n=t.getId(),r=e.chains[n].shift();e.findModuleChain(t).filter(function(t){return!e.chains[n].includes(t)}).forEach(function(t){e.chains[n].unshift(t)});var i=e.history[n].cycles[r.identifier];e.history[n].cycles[r.identifier]="number"==typeof i?i+1:1;var o=e.chains[n].map(function(e){return e.identifier});e.history[n].identifiers.push(o)}}]),e}();c.chains={},c.history={},c.allowedCycles=1,c.forbiddenIdentifiers=[],e.exports=c},,,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n0}}]),e}();o.logicsMap={},e.exports=o},function(e,t,n){"use strict";var r=n(11),i=n(27);r.registerPlugin(i);var o=n(29);r.registerPlugin(o);var u=n(25);r.registerPlugin(u);var a=n(26);r.registerPlugin(a);var c=n(28);r.registerPlugin(c);var s=n(15);r.registerFilter(s);var l=n(14);r.registerFilter(l);var f=n(13);r.registerFilter(f);n(16);e.exports=r},,,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u={PluginExists:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,'Plugin with same "'+e.identifier+'" identifier found.'))}return o(t,e),t}(Error),TypeNotFound:function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Media Tag could not find the content type of an instance.}."))}return o(t,e),t}(Error),FilterExists:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,'Filter with same "'+e.identifier+' identifier found."'))}return o(t,e),t}(Error),FetchFail:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,'Could not fetch "'+e.url+'", received "'+e.status+": "+e.statusText+'".'))}return o(t,e),t}(Error),InvalidCryptoKey:function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Invalid cryptographic key."))}return o(t,e),t}(Error),InvalidCryptoLib:function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Invalid cryptographic algorithm name."))}return o(t,e),t}(Error),FailedCrypto:function(e){function t(e){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Failed to decrypt file"+(e&&e.message?" "+e.message:"")+"."))}return o(t,e),t}(Error)};e.exports=u},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1?t[0]:window.location.protocol}},{key:"hostname",value:function(e){var t=e.getAttribute("src").split("://");return t.length>1?t[1].split("/")[0]:window.location.hostname}},{key:"source",value:function(e){return e.getAttribute("src")}},{key:"parse",value:function(t){return{protocol:e.protocol(t),hostname:e.hostname(t),src:e.source(t),type:e.type(t),extension:e.extension(t),mime:e.mime(t)}}}]),e}();e.exports=o},function(e,t,n){"use strict";var r=n(0),i={identifier:"clear-key",startup:function(e){var t=e.getAttribute("data-clear-key"),n=t.substring(0,32),i=t.substring(33,65);e.setAttribute("id",n),e.setAttribute("key",i),e.removeAttribute("data-clear-key"),r.chain(e)}};e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n + + + CryptPad + + + + + + + + + + +
+
+ +
+ +
+

+
+
+ + diff --git a/www/examples/file/inner.html b/www/examples/file/inner.html new file mode 100644 index 000000000..bba73059e --- /dev/null +++ b/www/examples/file/inner.html @@ -0,0 +1,25 @@ + + + + + + + + + + + +
+ + + + diff --git a/www/examples/file/main.js b/www/examples/file/main.js new file mode 100644 index 000000000..9a0d142fc --- /dev/null +++ b/www/examples/file/main.js @@ -0,0 +1,52 @@ +define([ + 'jquery', + '/bower_components/chainpad-crypto/crypto.js', + '/bower_components/chainpad-netflux/chainpad-netflux.js', + '/common/toolbar.js', + '/common/cryptpad-common.js', + '/common/visible.js', + '/common/notify.js', + '/bower_components/tweetnacl/nacl-fast.min.js', +], function ($, Crypto, realtimeInput, Toolbar, Cryptpad, Visible, Notify) { + var Messages = Cryptpad.Messages; + window.Nacl = window.nacl; + $(function () { + + var ifrw = $('#pad-iframe')[0].contentWindow; + var $iframe = $('#pad-iframe').contents(); + + Cryptpad.addLoadingScreen(); + + var andThen = function () { + var $bar = $iframe.find('.toolbar-container'); + var secret = Cryptpad.getSecrets(); + var readOnly = secret.keys && !secret.keys.editKeyStr; + if (!secret.keys) { + secret.keys = secret.key; + } + + var $mt = $iframe.find('#encryptedFile'); + $mt.attr('src', './assets/image.png-encrypted'); + $mt.attr('data-crypto-key', 'TBo77200c0e/FdldQFcnQx4Y'); + $mt.attr('data-type', 'image/png'); + require(['/common/media-tag.js'], function (MediaTag) { + MediaTag($mt[0]); + Cryptpad.removeLoadingScreen(); + var configTb = { + displayed: ['useradmin', 'newpad'], + ifrw: ifrw, + common: Cryptpad + }; + toolbar = Toolbar.create($bar, null, null, null, null, configTb); + + }); + + }; + + Cryptpad.ready(function (err, anv) { + andThen(); + Cryptpad.reportAppUsage(); + }); + + }); +});