Files
bybit-api/lib/util/requestUtils.js

22 lines
568 B
JavaScript

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('&');
}
};