File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,15 @@ if (!fs.existsSync(payloadFile)) {
24
24
process . exit ( 1 ) ;
25
25
}
26
26
27
- console . log ( `Calculating HMAC signature with payload from ' ${ payloadFile } ' ` ) ;
27
+ console . log ( `Calculating HMAC signature... ` ) ;
28
28
29
29
// Load and parse JSON file
30
30
let jsonData ;
31
+ let payload ;
32
+
31
33
try {
32
- const fileContent = fs . readFileSync ( payloadFile , 'utf8' ) ;
33
- jsonData = JSON . parse ( fileContent ) ;
34
+ payload = fs . readFileSync ( payloadFile , 'utf8' ) ;
35
+ jsonData = JSON . parse ( payload ) ;
34
36
} catch ( error ) {
35
37
console . error ( "Error: Invalid JSON in payload file." ) ;
36
38
process . exit ( 1 ) ;
@@ -55,5 +57,17 @@ if (!notificationRequestItem) {
55
57
const validator = new hmacValidator ( )
56
58
const hmacSignature = validator . calculateHmac ( notificationRequestItem , hmacKey ) ;
57
59
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 ( '********' ) ;
58
72
console . log ( `HMAC signature: ${ hmacSignature } ` ) ;
59
73
process . exit ( 0 ) ;
You can’t perform that action at this time.
0 commit comments