-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-webhook.sh
26 lines (19 loc) · 1006 Bytes
/
test-webhook.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# Define the payload
payload='{"event":"user.created","data":{"id":"1","full_name":"Faizan","email":"[email protected]","contact":"+923338184261"}}'
# Generate the current Unix timestamp
timestamp=$(date +%s)
# Define the webhook shared token
webhook_token='your_shared_webhook_token'
# Define the shared secret
shared_secret='your_shared_secret'
# Generate the HMAC SHA-256 signature in hexadecimal format
signature=$(echo -n "$payload$timestamp" | openssl dgst -sha256 -hmac "$shared_secret" | sed 's/^.* //')
# Print the generated signature
echo "Payload: $payload"
echo "Webhook Token: $webhook_token"
echo "Shared Secret: $shared_secret"
echo "Generated timestamp: $timestamp"
echo "Generated signature: $signature"
# Send the payload with the signature and timestamp to the webhook
curl -X POST -H "Content-Type: application/json" -H "x-signature: $signature" -H "x-webhook-token: $webhook_token" -H "x-timestamp: $timestamp" -d "$payload" "http://localhost:3000/webhook"