@lazy-random/cross-crypto
Version:
36 lines (35 loc) • 1.35 kB
JavaScript
!function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define([ "exports" ], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).LazyRandomCrossCrypto = {});
}(this, (function(e) {
"use strict";
const t = (() => {
let e;
return () => {
if (void 0 === e) {
var t;
let r;
try {
r = e = require("crypto");
} catch (t) {
var o;
r = global.crypto || global.msCrypto, null !== (o = r) && void 0 !== o && o.getRandomValues && (e = r);
}
null !== (t = e) && void 0 !== t && t.randomBytes || (e.randomBytes = e.randomBytes || function randomBytes(e, t) {
if (e > 65536) throw new Error("requested too many random bytes");
let o = new Uint8Array(e);
e > 0 && r.getRandomValues(o);
let n = Buffer.from(o.buffer);
return "function" == typeof t && t(null, n), n;
});
}
if (!e) throw e = null, new Error("not support crypto");
return e;
};
})();
e.crossCrypto = t, e.default = t, e.randomBytes = function randomBytes(e, o) {
return t().randomBytes(e, o);
}, Object.defineProperty(e, "__esModule", {
value: !0
});
}));
//# sourceMappingURL=index.umd.production.min.cjs.map