depend on main passing in the crypto module for now
This commit is contained in:
parent
f76dc615c0
commit
288b4d5b66
@ -1,13 +1,12 @@
|
|||||||
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
|
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
|
||||||
define([
|
define([
|
||||||
'/common/crypto.js',
|
'/common/realtime-input.js', // TODO publish on bower
|
||||||
'/common/realtime-input.js',
|
|
||||||
'/bower_components/chainpad-json-validator/json-ot.js',
|
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||||
'json.sortify',
|
'json.sortify',
|
||||||
'/bower_components/textpatcher/TextPatcher.amd.js',
|
'/bower_components/textpatcher/TextPatcher.amd.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/bower_components/proxy-polyfill/proxy.min.js', // https://github.com/GoogleChrome/proxy-polyfill
|
'/bower_components/proxy-polyfill/proxy.min.js', // https://github.com/GoogleChrome/proxy-polyfill
|
||||||
], function (Crypto, Realtime, JsonOT, Sortify, TextPatcher) {
|
], function (Realtime, JsonOT, Sortify, TextPatcher) {
|
||||||
var api = {};
|
var api = {};
|
||||||
// linter complains if this isn't defined
|
// linter complains if this isn't defined
|
||||||
var Proxy = window.Proxy;
|
var Proxy = window.Proxy;
|
||||||
@ -543,13 +542,26 @@ define([
|
|||||||
throw new Error('unsupported datatype: '+ DeepProxy.type(cfg.data));
|
throw new Error('unsupported datatype: '+ DeepProxy.type(cfg.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cfg.crypto) {
|
||||||
|
// complain and stub
|
||||||
|
console.log("[chainpad-listmap] no crypto module provided. messages will not be encrypted");
|
||||||
|
cfg.crypto = {
|
||||||
|
encrypt: function (msg) {
|
||||||
|
return msg;
|
||||||
|
},
|
||||||
|
descrypt: function (msg) {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
initialState: Sortify(cfg.data),
|
initialState: Sortify(cfg.data),
|
||||||
transformFunction: JsonOT.validate,
|
transformFunction: JsonOT.validate,
|
||||||
userName: Crypto.rand64(8),
|
userName: cfg.crypto.rand64(8), // TODO stub this in case there is no crypto module provided?
|
||||||
channel: cfg.channel,
|
channel: cfg.channel,
|
||||||
cryptKey: cfg.cryptKey,
|
cryptKey: cfg.cryptKey, // TODO make sure things work without this code
|
||||||
crypto: Crypto,
|
crypto: cfg.crypto, // stub if not provided
|
||||||
websocketURL: cfg.websocketURL,
|
websocketURL: cfg.websocketURL,
|
||||||
logLevel: 0
|
logLevel: 0
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user