feat: deprecate request and implement axios. bump ws. cleaning. expose request options for proxy support. resolves #12. resolves #4.
This commit is contained in:
21
lib/util/requestUtils.js
Normal file
21
lib/util/requestUtils.js
Normal 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('&');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user