Skip to content

Commit 8ada552

Browse files
committed
Improve output
1 parent 46919db commit 8ada552

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tools/hmac/calculateHmacPayments.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ if (!fs.existsSync(payloadFile)) {
2424
process.exit(1);
2525
}
2626

27-
console.log(`Calculating HMAC signature with payload from '${payloadFile}'`);
27+
console.log(`Calculating HMAC signature...`);
2828

2929
// Load and parse JSON file
3030
let jsonData;
31+
let payload;
32+
3133
try {
32-
const fileContent = fs.readFileSync(payloadFile, 'utf8');
33-
jsonData = JSON.parse(fileContent);
34+
payload = fs.readFileSync(payloadFile, 'utf8');
35+
jsonData = JSON.parse(payload);
3436
} catch (error) {
3537
console.error("Error: Invalid JSON in payload file.");
3638
process.exit(1);
@@ -55,5 +57,17 @@ if (!notificationRequestItem) {
5557
const validator = new hmacValidator()
5658
const hmacSignature = validator.calculateHmac(notificationRequestItem, hmacKey);
5759

60+
console.log('********');
61+
console.log(`Payload file: ${payloadFile}`);
62+
console.log(`Payload length: ${payload.length} characters`);
63+
/*
64+
// uncomment if needed
65+
const newlineCount = (payload.match(/\n/g) || []).length;
66+
const spaceCount = (payload.match(/ /g) || []).length;
67+
68+
console.log(`Newline count: ${newlineCount}`);
69+
console.log(`Space count: ${spaceCount}`);
70+
*/
71+
console.log('********');
5872
console.log(`HMAC signature: ${hmacSignature}`);
5973
process.exit(0);

0 commit comments

Comments
 (0)