feat: deprecate request and implement axios. bump ws. cleaning. expose request options for proxy support. resolves #12. resolves #4.

This commit is contained in:
tiagosiebler
2020-10-04 19:37:26 +01:00
parent b201d364bf
commit 3a2125e77b
10 changed files with 223 additions and 4992 deletions

21
lib/util/requestUtils.js Normal file
View File

@@ -0,0 +1,21 @@
const { createHmac } = require('crypto');
module.exports = {
signMessage(message, secret) {
return createHmac('sha256', secret)
.update(message)
.digest('hex');
},
serializeParams(params, strict_validation) {
return Object.keys(params)
.sort()
.map(key => {
const value = params[key];
if (strict_validation === true && typeof value === 'undefined') {
throw new Error('Failed to sign API request due to undefined parameter');
}
return `${key}=${value}`;
})
.join('&');
}
};