diff --git a/www/common/common-util.js b/www/common/common-util.js index e09577553..8cbde420c 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -7,6 +7,11 @@ define([], function () { }, map)); }; + Util.uid = function () { + return Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)) + .toString(32).replace(/\./g, ''); + }; + Util.fixHTML = function (str) { if (!str) { return ''; } return str.replace(/[<>&"']/g, function (x) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 88ad0fde7..ab936914f 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -98,6 +98,7 @@ define([ common.createRandomInteger = Util.createRandomInteger; common.getAppType = Util.getAppType; common.notAgainForAnother = Util.notAgainForAnother; + common.uid = Util.uid; // import hash utilities for export var createRandomHash = common.createRandomHash = Hash.createRandomHash; diff --git a/www/common/rpc.js b/www/common/rpc.js index aee717a0a..f088ec0fd 100644 --- a/www/common/rpc.js +++ b/www/common/rpc.js @@ -1,13 +1,10 @@ define([ + '/common/common-util.js', '/bower_components/tweetnacl/nacl-fast.min.js', -], function () { +], function (Util) { var Nacl = window.nacl; - var uid = function () { - return Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)) - .toString(32).replace(/\./g, ''); - }; - + var uid = Util.uid; var signMsg = function (data, signKey) { var buffer = Nacl.util.decodeUTF8(JSON.stringify(data)); return Nacl.util.encodeBase64(Nacl.sign.detached(buffer, signKey));