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,9 +3,10 @@ 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',
'/customize/pad.js'
], function (Config, Realtime, Crypto, TextPatcher) {
], function (Config, Realtime, Crypto, TextPatcher, Cryptpad) {
// TODO consider adding support for less.js
var $ = window.jQuery;
@@ -14,21 +15,11 @@ define([
var module = window.APP = {};
var key;
var channel = '';
if (!/#/.test(window.location.href)) {
key = Crypto.genKey();
} else {
var hash = window.location.hash.slice(1);
channel = hash.slice(0, 32);
key = hash.slice(32);
}
var secret = Cryptpad.getSecrets();
var config = {
websocketURL: Config.websocketURL,
channel: channel,
cryptKey: key,
crypto: Crypto,
channel: secret.channel,
crypto: Crypto.createEncryptor(secret.key),
};
var userName = module.userName = config.userName = Crypto.rand64(8);
@@ -49,7 +40,7 @@ define([
var initializing = true;
var onInit = config.onInit = function (info) {
window.location.hash = info.channel + key;
window.location.hash = info.channel + secret.key;
var realtime = module.realtime = info.realtime;
module.patchText = TextPatcher.create({
realtime: realtime,