I'm trying to handle some Amazon SES (simple email service) messages via SNS (Simple notification service) via http(s) to our server.
However, I can't get our domain confirmed. What is the right way to do this? I have tried the 'sns-validator' npm module but he says that the message is missing the required keys.
We are using Node.JS with express. What is the right way to parse the validation message?
validator.validate(req.headers, function (err, message) {
if (err) {
console.error(err);
return;
}
if (message['Type'] === 'SubscriptionConfirmation') {
https.get(message['SubscribeURL'], function (res) {
// You have confirmed your endpoint subscription
console.log("confirmed");
});
}
});
Edit:
I have logged the req
and I only see the amazon headers in req.headers
accept-encoding:"gzip,deflate"
content-length:"1517"
content-type:"text/plain; charset=UTF-8"
host:"[nrgokurl].ngrok.io"
user-agent:"Amazon Simple Notification Service Agent"
x-amz-sns-message-id:"[id]"
x-amz-sns-message-type:"SubscriptionConfirmation"
x-amz-sns-topic-arn:"arn:[arn]:complaints"
x-forwarded-for:"54.240.197.14"
x-forwarded-proto:"https"
I do not have the data as subscribed on http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html#SendMessageToHttp.prepare where can I find that data?