File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ const isValidSignature = (
65
65
66
66
### Timestamp Verification
67
67
68
- The timestamp will be sent as ` X-Engine-Timestamp ` header in the request. You can verify the timestamp using the below code:
68
+ The timestamp will be sent as ` x-engine-timestamp ` header in the request. You can verify the timestamp using the below code:
69
69
70
70
``` ts
71
71
export const isExpired = (
@@ -96,8 +96,8 @@ const WEBHOOK_SECRET = "YOUR_WEBHOOK_AUTH_TOKEN"; // Replace with your secret
96
96
app .use (bodyParser .text ());
97
97
98
98
app .post (" /webhook" , (req , res ) => {
99
- const signatureFromHeader = req .header (" X-Engine-Signature " );
100
- const timestampFromHeader = req .header (" X-Engine-Timestamp " );
99
+ const signatureFromHeader = req .header (" x-engine-signature " );
100
+ const timestampFromHeader = req .header (" x-engine-timestamp " );
101
101
102
102
if (! signatureFromHeader || ! timestampFromHeader ) {
103
103
return res .status (401 ).send (" Missing signature or timestamp header" );
@@ -178,6 +178,6 @@ The payload sent to the webhook URL will be in the below format:
178
178
"sentAtBlockNumber" : 40660021 ,
179
179
"blockNumber" : 40660026 ,
180
180
"queueId" : " 1411246e-b1c8-4f5d-9a25-8c1f40b54e55" ,
181
- "status" : " mined"
181
+ "status" : " mined" ,
182
182
}
183
183
```
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ export const generateSignature = (
16
16
timestamp : string ,
17
17
secret : string ,
18
18
) : string => {
19
- const payload = `${ timestamp } .${ body } ` ;
19
+ const _body = JSON . stringify ( body ) ;
20
+ const payload = `${ timestamp } .${ _body } ` ;
20
21
return crypto . createHmac ( "sha256" , secret ) . update ( payload ) . digest ( "hex" ) ;
21
22
} ;
22
23
You can’t perform that action at this time.
0 commit comments