const crypto = require('crypto');
function buildAuthHeaders(publicKey, secretKey, path, method, body = '') {
const timestamp = Math.floor(Date.now() / 1000).toString();
const data = method !== 'GET' ? JSON.stringify(body) : '';
const toSign = path + timestamp + method + data;
const signature = crypto
.createHmac('sha256', secretKey)
.update(toSign)
.digest('hex');
return {
'X-Digest-Key': publicKey,
'X-Digest-Timestamp': timestamp,
'X-Digest-Signature': signature,
'Content-Type': 'application/json',
};
}