2015-07-14 17:45:00 +02:00
|
|
|
var olm_exports = {};
|
|
|
|
var get_random_values;
|
2015-07-20 17:33:45 +02:00
|
|
|
var process; // Shadow the process object so that emscripten won't get
|
|
|
|
// confused by browserify
|
2016-12-12 17:52:03 +01:00
|
|
|
|
|
|
|
if (typeof(window) !== 'undefined') {
|
|
|
|
// We've in a browser (directly, via browserify, or via webpack).
|
2015-07-14 17:45:00 +02:00
|
|
|
get_random_values = function(buf) {
|
|
|
|
window.crypto.getRandomValues(buf);
|
|
|
|
};
|
|
|
|
} else if (module["exports"]) {
|
|
|
|
// We're running in node.
|
|
|
|
var nodeCrypto = require("crypto");
|
|
|
|
get_random_values = function(buf) {
|
|
|
|
var bytes = nodeCrypto.randomBytes(buf.length);
|
|
|
|
buf.set(bytes);
|
2016-12-12 17:52:03 +01:00
|
|
|
};
|
2015-07-21 15:30:46 +02:00
|
|
|
process = global["process"];
|
2015-07-14 17:45:00 +02:00
|
|
|
} else {
|
|
|
|
throw new Error("Cannot find global to attach library to");
|
|
|
|
}
|
|
|
|
|
2016-12-12 17:52:03 +01:00
|
|
|
(function() {
|
2016-12-14 12:41:51 +01:00
|
|
|
/* applications should define OLM_OPTIONS in the environment to override
|
|
|
|
* emscripten module settings */
|
|
|
|
var Module = {};
|
|
|
|
if (typeof(OLM_OPTIONS) !== 'undefined') {
|
|
|
|
for (var key in OLM_OPTIONS) {
|
|
|
|
if (OLM_OPTIONS.hasOwnProperty(key)) {
|
|
|
|
Module[key] = OLM_OPTIONS[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|