update to use new style crypto module

This commit is contained in:
ansuz
2016-06-21 15:17:09 +02:00
parent f94c06abc0
commit 849683d586
9 changed files with 64 additions and 108 deletions

View File

@@ -3,44 +3,23 @@ define([
'/bower_components/chainpad-netflux/chainpad-netflux.js',
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/textpatcher/TextPatcher.amd.js',
'/common/cryptpad-common.js',
'/bower_components/jquery/dist/jquery.min.js'
], function (Config, Realtime, Crypto, TextPatcher) {
], function (Config, Realtime, Crypto, TextPatcher, Cryptpad) {
var $ = window.jQuery;
var key;
var channel = '';
if (window.location.href.indexOf('#') === -1) {
key = Crypto.genKey();
//window.location.href = window.location.href + '#' + Crypto.genKey();
//return;
} else {
var hash = window.location.hash.substr(1);
channel = hash.substr(0,32);
key = hash.substr(32);
}
var secret = Cryptpad.getSecrets();
var $textarea = $('textarea'),
$run = $('#run');
var module = {};
/*
onRemote
onInit
onReady
onAbort
transformFunction
*/
var userName = Crypto.rand64(8);
var config = {
initialState: '',
websocketURL: Config.websocketURL,
userName: userName,
channel: channel,
cryptKey: key,
crypto: Crypto,
channel: secret.channel,
crypto: Crypto.createEncryptor(secret.key),
};
var initializing = true;
@@ -50,7 +29,7 @@ define([
setEditable(false);
var onInit = config.onInit = function (info) {
window.location.hash = info.channel + key;
window.location.hash = info.channel + secret.key;
$(window).on('hashchange', function() { window.location.reload(); });
};