1 | const crypto = require('crypto');
|
2 |
|
3 | const fetch = require('node-fetch');
|
4 | const api = require('./api');
|
5 |
|
6 | module.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 | });
|