import crypto from "crypto";
function signRequest(method, path, body, apiKey, apiSecret) {
const timestamp = String(Math.floor(Date.now() / 1000));
const nonce = crypto.randomUUID();
const signingString = [method.toUpperCase(), path, body, timestamp, nonce].join("\n");
const signature = crypto.createHmac("sha256", apiSecret).update(signingString).digest("hex");
return {
"Content-Type": "application/json",
"x-api-key": apiKey,
"x-timestamp": timestamp,
"x-nonce": nonce,
"x-signature": signature,
};
}