UNPKG

464 BJavaScriptView Raw
1const crypto = require('crypto');
2
3const fetch = require('node-fetch');
4const api = require('./api');
5
6module.exports = ({crdsUrl}) => api({
7 random: () => {
8 const array = new Uint32Array(1);
9 const setArray = new Uint8Array(array.buffer);
10 setArray.set(crypto.randomBytes(setArray.byteLength));
11 return Math.abs(array[0] / 0xFFFFFFFF);
12 },
13 fetch: fetch,
14 Headers: fetch.Headers,
15 encodeUtf8: s => new Buffer(s, 'utf8'),
16 crdsUrl: crdsUrl,
17});