"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var bytes_1 = require("@ethersproject/bytes"); var logger_1 = require("@ethersproject/logger"); var _version_1 = require("./_version"); var logger = new logger_1.Logger(_version_1.version); var shuffle_1 = require("./shuffle"); exports.shuffled = shuffle_1.shuffled; var crypto = global.crypto || global.msCrypto; if (!crypto || !crypto.getRandomValues) { logger.warn("WARNING: Missing strong random number source"); crypto = { getRandomValues: function (buffer) { return logger.throwError("no secure random source avaialble", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "crypto.getRandomValues" }); } }; } function randomBytes(length) { if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { logger.throwArgumentError("invalid length", "length", length); } var result = new Uint8Array(length); crypto.getRandomValues(result); return bytes_1.arrayify(result); } exports.randomBytes = randomBytes; ;